Analysis on JDK-8022321 java/lang/ref/ fails intermittently

Peter Levart peter.levart at
Wed Jan 29 13:09:45 UTC 2014

On 01/28/2014 04:46 PM, Alan Bateman wrote:
> On 28/01/2014 08:44, Peter Levart wrote:
>> Yes, I tried that too and it results in even more unsafe casts.
>> It's odd yes, since the compile-time error is not present when 
>> building via OpenJDK build system make files (using "make images" in 
>> top directory for example) but only if I compile the class from 
>> command line (using javac directly) or from IDEA. I use JDK 8 ea-b121 
>> in all cases as a build JDK. Are there any special options passed to 
>> javac for compiling those classes in JDK build system that allow such 
>> code?
> jdk/make/Setup.gmk has the -Xlint options that are used in the build 
> but I suspect it more than that all the classes in java/lang/ref are 
> compiled together.
> -Alan

That's right. If I add the source for into a 
directory where resides and then compile with:

     javac -d /tmp

...then Reference as well as ReferenceQueue gets compiled and there's no 
error. If there is sole in the directory, a compile time 
error is emitted. I checked the source of in JDK 8 
ea-b121 (the JDK used for compiling) and it only differs in copyright 
year from the source in jdk9-dev. So there seems to be inconsistency in 
javac's handling of types that are read from .class vs. .java files.

I'll try to create a reproducer example and post it to compiler-dev.

Since I don't know what should be the correct behaviour of javac, I can 
leave the changes as proposed since it compiles in both 
cases. Or should I revert the change to declaration of local variable 'q' ?

Regards, Peter

More information about the core-libs-dev mailing list