Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to avoid incompatibility if compile with jdk9 #114

Open
wants to merge 10,000 commits into
base: trunk
Choose a base branch
from
Open

Fix to avoid incompatibility if compile with jdk9 #114

wants to merge 10,000 commits into from

Conversation

nroduit
Copy link

@nroduit nroduit commented Jul 31, 2017

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.

stefanseifert and others added 30 commits March 9, 2017 21:04
Also fixed an issue in which sometimes objects were considered as JavaBeans when they shouldn't have.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1786376 13f79535-47bb-0310-9956-ffa450edef68
…Add new mapping rule for 20$ to hyphen

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1787016 13f79535-47bb-0310-9956-ffa450edef68
…for multiple cardinality reference with multiple component instances

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1787202 13f79535-47bb-0310-9956-ffa450edef68
…tion.Annotation methods properly

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1787280 13f79535-47bb-0310-9956-ffa450edef68
…ttributes containing non color attributes

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1788071 13f79535-47bb-0310-9956-ffa450edef68
Patch applied on behalf of Kerry Billingham with many thanks!
This closes #98


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1788110 13f79535-47bb-0310-9956-ffa450edef68
adamhooper added a commit to overview/mime-types that referenced this pull request Dec 8, 2020
In some JVMs it returns a ByteBuffer; in others, it returns a Buffer. So
we can't compile in one JVM and use it in another.

Simplest solution is to stop using .rewind() altogether.

See apache/felix#114

[closes #10]
ProgrammerDan added a commit to ProgrammerDan/hafen-client that referenced this pull request Mar 27, 2021
ProgrammerDan added a commit to ProgrammerDan/hafen-client that referenced this pull request Mar 31, 2021
agibsonccc added a commit to deeplearning4j/deeplearning4j that referenced this pull request Apr 1, 2021
ProgrammerDan added a commit to ProgrammerDan/hafen-client that referenced this pull request Apr 2, 2021
ProgrammerDan added a commit to ProgrammerDan/hafen-client that referenced this pull request Apr 2, 2021
ProgrammerDan added a commit to ProgrammerDan/hafen-client that referenced this pull request Apr 4, 2021
ProgrammerDan added a commit to ProgrammerDan/hafen-client that referenced this pull request Apr 7, 2021
Pandrex247 pushed a commit to payara/patched-src-felix that referenced this pull request May 31, 2022
* Made inner Circle class static in service-based demo project

* Fixed Javadoc errors in sample project

* Removed redundant modifiers from SimpleShape interfaces in sample project

* Added license comment to source file to fix build failure about unlicensed files

* Fixed typos in comment and private method name

* Updated version numbers and parent coordinates in demo project to fix build errors
EnderWiggin added a commit to EnderWiggin/hafen-client that referenced this pull request Oct 31, 2022
@DCNick3 DCNick3 mentioned this pull request Jun 15, 2023
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 11, 2023
Incompatible code can be used/generated when using JDK8 on the command line and JDK11 in Eclipse (or vice versa).

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.

Signed-off-by: Wouter Born <github@maindrain.net>
GitOrigin-RevId: 648cfac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants