pacomendes commented on issue #312: Compilation on jdk11 for release 8
URL: https://github.com/apache/curator/pull/312#issuecomment-494850625
 
 
   I created https://issues.apache.org/jira/browse/CURATOR-523
   
   If you build on JDK 11.0.2 using --source 1.8 and --target 1.8 options, the 
classfile version will be 52, but due to changes in covariant return types in 
the JDK, it fails at runtime. This is a very odd edge case we picked up in 
production...
   
   If you compile the following code on JDK9+ using --source 1.8 --target 1.8 
and fun on JDK8 it will fail at runtime with a `java.lang.NoSuchMethodError`. 
   
   If you compile with JDK9+ using --release 8, it will cast and resolve the 
correct method correctly (http://openjdk.java.net/jeps/247)
   ```
       public Buffer doSomething() {
           ByteBuffer byteBuffer = ByteBuffer.allocate(0x800);
           return byteBuffer.flip();
       }
   ```
   
   Maven compiler plugin provides a --release option if you're building on 
JDK11, if you're also compiling and testing on JDK8, we would need to switch 
this using a maven profile. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to