Bug in javac release flag?
Jan Lahoda
jan.lahoda at oracle.com
Mon Jan 22 16:33:38 UTC 2018
Hi Stephen,
I was looking at the historical data for 8 and 9 in JDK10, and the JDK 8
data appears to only declare the two overloads:
http://hg.openjdk.java.net/jdk/jdk10/file/48ce4b11bc17/make/data/symbols/java.base-8.sym.txt#l2361
And the JDK 9 data appears to add the additional overload:
http://hg.openjdk.java.net/jdk/jdk10/file/48ce4b11bc17/make/data/symbols/java.base-9.sym.txt#l525
So these appear to me to be OK.
I also checked the content of the ct.sym, and the sig files in there
appear to be OK as well - the JDK 8 version contains only two
[overloads, while the JDK 9 version contains three overloads. So this
appears to be reasonable.
I also tried to compile and run:
---
public class M {
public static void main(String... args) {
System.err.println(Math.floorDiv(0L, 1));
}
}
---
---
$ javac -fullversion
javac full version "9+181"
$ javac --release 8 M.java
$ java -fullversion
java full version "1.8.0_121-b13"
$ java M
0
---
So that appears to be OK as well.
I tried to compile the project using maven, and in debug output, I was
able to find "--release 9", but not "--release 8", only "-target 1.8
-source 1.8". This will produce JDK 8 classfiles, but compile against
the JDK 9 system modules. To get the new --release behavior, "--release
<VERSION>" must be used.
Jan
On 22.1.2018 16:34, Jonathan Gibbons wrote:
> Forwarding to compiler-dev, which is a better place to discuss this issue.
>
> -- Jon
>
>
> On 1/22/18 7:11 AM, Stephen Colebourne wrote:
>> I think I have a problem with the java release flag, reported by a
>> user here:
>> https://github.com/ThreeTen/threeten-extra/issues/91
>>
>> The particular case that is a problem are the new methods on
>> java.lang.Math.
>>
>> Java 8 had these methods:
>> floorDiv(long,long)
>> floorDiv(int,int)
>>
>> Java 9 has these methods:
>> floorDiv(long,long)
>> floorDiv(int,int)
>> floorDiv(long,int)
>>
>> (there are similar new overloads for other method names)
>>
>> Clearly, if you build on Java 9, code can link to the new(long,int)
>> overload, but that code will get a NoSuchMethodError on Java 8.
>>
>> But, I am using Java 9 with the javac release flag set to be 8. If I
>> understand the release flag correctly, the (long,int) overload should
>> not be visible, and thus a different overload should be selected.
>>
>> So, is this a bug? Perhaps the tool that captures new method
>> signatures doesn't handle overloads?
>>
>> (ThreeTen-Extra v1.3 was built using Maven on Java 9 using Maven's
>> implementation of the release flag, so it could be Maven that is
>> buggy, but I don't think so as it produces the correct classfile
>> version number).
>>
>> thanks
>> Stephen
>
More information about the compiler-dev
mailing list