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 ReferenceQueue.java into a directory where Reference.java resides and then compile with:

    javac -d /tmp Reference.java

...then Reference as well as ReferenceQueue gets compiled and there's no error. If there is sole Reference.java in the directory, a compile time error is emitted. I checked the source of ReferenceQueue.java 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 Reference.java changes as proposed since it compiles in both cases. Or should I revert the change to declaration of local variable 'q' ?

Regards, Peter

Reply via email to