On Wed, 15 Dec 2021 14:40:34 GMT, kabutz <d...@openjdk.java.net> wrote:

>> src/java.base/share/classes/java/math/BigInteger.java line 1909:
>> 
>>> 1907:             @Override
>>> 1908:             public BigInteger compute() {
>>> 1909:                 return a.multiply(b, true, super.parallel, 
>>> super.depth);
>> 
>> Using `super.` is a little unusual, it's not wrong :-) but not really 
>> idiomatic in the source code base.
>
> I cannot remember ever using `super.` like this before either :-) I have a 
> static inner class, which in turn has two static inner classes, which are its 
> subclasses. The inner inner classes want to access the fields of their outer 
> static super class. Since the fields are private, we need to use `super` 
> otherwise we get this compiler error:
> 
> error: non-static variable parallel cannot be referenced from a static context
>                 return a.multiply(b, true, parallel, depth);
> 
> And if we move the inner inner class up one level, then we also get an error:
> 
> error: parallel has private access in RecursiveOp
>             return a.multiply(b, true, parallel, super.depth);
> 
> A solution of course is to make the fields non-private. Then the compiler is 
> happy and we can get rid of the `super`. Since the classes are private 
> anyway, making the fields private does not increase the encapsulation. I will 
> do that to get rid of the `super` FWIW.

Oh, i did not realize that was a forced move.

-------------

PR: https://git.openjdk.java.net/jdk/pull/6409

Reply via email to