Skip to content

[MRESOLVER-85] Avoid ByteBuffer incompatibility when compiling with JDK9+ #826

@jira-importer

Description

@jira-importer

Sylwester Lachiewicz opened MRESOLVER-85 and commented

Restore possibility to create a release with Java9+

 

The explanation for this is given in apache/felix#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.


Affects: 1.3.2, 1.3.3

Issue Links:

  • MRESOLVER-67 The Maven resolver API 1.3.2 JAR deployed on Maven central has been built with Java 11

Remote Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority:minorMinor loss of function, or other problem where easy workaround is present

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions