[ 
https://issues.apache.org/jira/browse/MRESOLVER-85?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16816333#comment-16816333
 ] 

Sylwester Lachiewicz commented on MRESOLVER-85:
-----------------------------------------------

I thought that we are trying to have reproducible builds that will be somehow 
independent of JDK version - that's why I proposed to add this workaround with 
casting. I hope in the near future more developers will use LTS JDK 11 to 
develop code and also our release managers will drop older JDK (and probably 
only use CI to run compatibility tests).

I also reverted to a state where we need JDK 7/8 to release maven-resolver. 

If you think that this change is not necessary, then we can close the issue - 
no problem.

> Avoid ByteBuffer incompatibility when compiling with JDK9+
> ----------------------------------------------------------
>
>                 Key: MRESOLVER-85
>                 URL: https://issues.apache.org/jira/browse/MRESOLVER-85
>             Project: Maven Resolver
>          Issue Type: Improvement
>    Affects Versions: 1.3.2, 1.3.3
>            Reporter: Sylwester Lachiewicz
>            Assignee: Sylwester Lachiewicz
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Restore possibility to create a release with Java9+
>  
> The explanation for this is given in 
> [apache/felix#114|https://github.com/apache/felix/pull/114] :
> Java 9 introduces overridden methods with covariant return types for the 
> following methods in java.nio.ByteBuffer:
> position (int newPosition)
> limit (int newLimit)
> flip ()
> clear ()
> mark ()
> reset ()
> rewind ()
> In Java 9 they all now return ByteBuffer, whereas the methods they override 
> return Buffer,
> resulting in exceptions like this when executing on Java 8 and lower:
>  {{java.lang.NoSuchMethodError: 
> java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer}}
> This is because the generated byte code includes the static return type of 
> the method, which is not found on Java 8 and lower because the overloaded 
> methods with covariant return types don't exist (the issue appears even with 
> source and target 8 or lower in compilation parameters).
> The solution is to cast ByteBuffer instances to Buffer before calling the 
> method.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to