Fwd: inner class reading uninitialized value from outer class
list at xenhideout.nl
Thu Jun 23 09:47:43 UTC 2016
On Wed, 22 Jun 2016, Alex Buckley wrote:
> The access is not advisable, but definite assignment analysis cannot
> prevent it, so ultimately it's acceptable.
Alright. It seems out of the ordinary that you couldn't detect it, but
alright. Thanks for the reply in any case in advance ;-) :).
>>> Nothing odd here, but it does read a final value that has not been
>>> initialized yet. Maybe this should simply be a compiler error. I don't
>>> know what the spec says about this. It will just compile fine on
>>> openjdk 8 (I got a package error trying to install 9 on my system,
>>> hence I am using 8 for (this) now).
>>> Basically I wonder if the spec allows this, or whether this is a
>>> compiler error.
> The spec allows this. It is possible to do all kinds of crazy things as a
> result of the language allowing arbitrary code in instance variable
> initializers, instance initializers, static variable initializers, and static
Right, thanks. It was just a bug in my program ;-). Well, call it
unfamiliarity with the mechanics. I had expected a final variable
to not be able to have 2 different values during the lifetime of the
program / class. It took me a few .....minutes ;-) to discover what was
going on, but thankfully troubleshooting is much easier than in e.g. Bash,
where a million things can go wrong as a matter of joy.
Linux seems to be the agenda and the place of creating more and more
difficult problems, so that there are more problems to solve for
problem-solving minds. A way of keeping yourself busy I guess. That
saying: do not give him a fish, give him a rod with which to fish. Linux
is like: empty the river first.
Thankfully Java is very much isolated from that and this is really the
first peculiar thing I have ever come across. So well, thank you for your
More information about the compiler-dev