You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by nroduit <gi...@git.apache.org> on 2017/07/31 17:52:23 UTC

[GitHub] felix pull request #114: Fix to avoid incompatibility if compile with jdk9

GitHub user nroduit opened a pull request:

    https://github.com/apache/felix/pull/114

    Fix to avoid incompatibility if compile with jdk9

    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.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nroduit/felix trunk

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/felix/pull/114.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #114
    
----
commit 2ef06ec9b432fd777ffc0c5a73b5f0f6cc190878
Author: Nicolas Roduit <ni...@gmail.com>
Date:   2017-07-31T16:38:59Z

    Compatibility with covariant return type on JDK 9's ByteBuffer

commit 9c64b1433185160cd18d423d925655eb3f7fa539
Author: Nicolas Roduit <ni...@gmail.com>
Date:   2017-07-31T16:44:27Z

    Merge remote-tracking branch 'origin/trunk' into trunk

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---