-
Notifications
You must be signed in to change notification settings - Fork 613
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
NoSuchMethodError when parsing a JSON stream on Java 8 #2326
Comments
Workaround: fun InputStream.asString(): String = String(readBytes())
// and then
Json.decodeFromString<DatabaseFiles>(it.asString()) |
shanshin
added a commit
that referenced
this issue
Jun 12, 2023
Fixes #2326 An explicit cast is needed here due to an API change in Java 9, see #2218. In Java 8 and earlier, the `position(I)` method was final in `Buffer`, and returned a `Buffer`. In Java 9 and later, the method was opened, and `ByteFuffer` overrides it, returning a `ByteBuffer`. This causes a `NoSuchMethodError` when running a class, compiled with a newer Java version, on Java 8.
shanshin
added a commit
that referenced
this issue
Jun 12, 2023
Fixes #2326 In Java 8 and earlier, the `position(I)` method was final in `Buffer`, and returned a `Buffer`. In Java 9 and later, the method was opened, and `ByteBuffer` overrides it, returning a `ByteBuffer`. This causes a `NoSuchMethodError` when running a class, compiled with a newer Java version, on Java 8. Adding `-Xjdk-release=1.8` parameter allows the compiler to generate bytecode compatible with JVM 1.8
shanshin
added a commit
that referenced
this issue
Jun 12, 2023
Fixes #2326 In Java 8 and earlier, the `position(I)` method was final in `Buffer`, and returned a `Buffer`. In Java 9 and later, the method was opened, and `ByteBuffer` overrides it, returning a `ByteBuffer`. This causes a `NoSuchMethodError` when running a class, compiled with a newer Java version, on Java 8. Adding `-Xjdk-release=1.8` parameter allows the compiler to generate bytecode compatible with JVM 1.8
woainikk
pushed a commit
that referenced
this issue
Jun 20, 2023
Fixes #2326 An explicit cast is needed here due to an API change in Java 9, see #2218. In Java 8 and earlier, the `position(I)` method was final in `Buffer`, and returned a `Buffer`. In Java 9 and later, the method was opened, and `ByteBuffer` overrides it, returning a `ByteBuffer`. This causes a `NoSuchMethodError` when running a class, compiled with a newer Java version, on Java 8.
JesusMcCloud
pushed a commit
to a-sit-plus/kotlinx.serialization
that referenced
this issue
Jul 5, 2023
…2328) Fixes Kotlin#2326 An explicit cast is needed here due to an API change in Java 9, see Kotlin#2218. In Java 8 and earlier, the `position(I)` method was final in `Buffer`, and returned a `Buffer`. In Java 9 and later, the method was opened, and `ByteBuffer` overrides it, returning a `ByteBuffer`. This causes a `NoSuchMethodError` when running a class, compiled with a newer Java version, on Java 8.
JellyBrick
added a commit
to JellyBrick/kotlinx.serialization
that referenced
this issue
Jul 24, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Similar issue just with a different method:
#2218
Java changed some function signatures on java 9, when building on java 9+ with targeting java 8, invalid bytecode is produced.
java 9+ function:
ByteBuffer position(int newPosition)
java 8 function:
Buffer position(int newPosition)
To Reproduce
Attach a code snippet or test data if possible.
will produce
Expected behavior
Not crashing
Environment
The text was updated successfully, but these errors were encountered: