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

Adapt to DirectByteBuffer constructor in Java 21 #13366

Merged
merged 2 commits into from
May 2, 2023
Merged

Conversation

luhenry
Copy link
Contributor

@luhenry luhenry commented Apr 28, 2023

Motivation:

The signature changed between Java 20 and 21 for the DirectByteBuffer constructor.
See openjdk/jdk@a56598f

Modification:

Simply add a check for <init>(long, long) on top of <init>(long, int)

Result:

It's able to compile and run on Java 21

The signature changed between Java 20 and 21 for the DirectByteBuffer constructor.

See openjdk/jdk@a56598f
@normanmaurer
Copy link
Member

@luhenry can you sign our icla: https://netty.io/s/icla ?

@luhenry
Copy link
Contributor Author

luhenry commented Apr 30, 2023

@normanmaurer I've signed it and updated per your review.

@normanmaurer normanmaurer added this to the 4.1.93.Final milestone May 2, 2023
@normanmaurer normanmaurer merged commit 96dcfc6 into netty:4.1 May 2, 2023
@normanmaurer
Copy link
Member

@luhenry thanks a lot!

normanmaurer pushed a commit that referenced this pull request May 2, 2023
Motivation:

The signature changed between Java 20 and 21 for the DirectByteBuffer constructor.
See openjdk/jdk@a56598f

Modification:

Simply add a check for `<init>(long, long)` on top of `<init>(long, int)`

Result:

It's able to compile and run on Java 21
dongjoon-hyun pushed a commit to apache/spark that referenced this pull request Jun 28, 2023
### What changes were proposed in this pull request?
This pr aims to upgrade netty from 4.1.92 to 4.1.93.

### Why are the changes needed?
1.v4.1.92 VS v4.1.93
netty/netty@netty-4.1.92.Final...netty-4.1.93.Final

2.The new version brings some bug fix, eg:
- Reset byte buffer in loop for AbstractDiskHttpData.setContent ([#13320](netty/netty#13320))
- OpenSSL MAX_CERTIFICATE_LIST_BYTES option supported ([#13365](netty/netty#13365))
- Adapt to DirectByteBuffer constructor in Java 21 ([#13366](netty/netty#13366))
- HTTP/2 encoder: allow HEADER_TABLE_SIZE greater than Integer.MAX_VALUE ([#13368](netty/netty#13368))
- Upgrade to latest netty-tcnative to fix memory leak ([#13375](netty/netty#13375))
- H2/H2C server stream channels deactivated while write still in progress ([#13388](netty/netty#13388))
- Channel#bytesBefore(un)writable off by 1 ([#13389](netty/netty#13389))
- HTTP/2 should forward shutdown user events to active streams ([#13394](netty/netty#13394))
- Respect the number of bytes read per datagram when using recvmmsg ([#13399](netty/netty#13399))

3.The release notes as follows:
- https://netty.io/news/2023/05/25/4-1-93-Final.html

4.Why not upgrade to `4-1-94-Final` version?
Because the return value of the 'threadCache()' (from `PoolThreadCache` to `PoolArenasCache`) method of the netty Inner class used in the 'arrow memory netty' version '12.0.1' has changed and belongs to break change, let's wait for the upgrade of the 'arrow memory netty' before upgrading to the '4-1-94-Final' version.

The reference is as follows:
https://github.com/apache/arrow/blob/6af660f48472b8b45a5e01b7136b9b040b185eb1/java/memory/memory-netty/src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java#L164
https://github.com/netty/netty/blob/da1a448d5bc4f36cc1744db93fcaf64e198db2bd/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java#L732-L736

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Pass GA.

Closes #41681 from panbingkun/upgrade_netty.

Authored-by: panbingkun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
lidavidm pushed a commit to apache/arrow that referenced this pull request Jun 29, 2023
### Rationale for this change

Java 21 switched `DirectByteBuffer(long,int)` constructor to `DirectByteBuffer(long,long)` via openjdk/jdk@a56598f
 
### What changes are included in this PR?
In order to avoid `NoSuchMethodException` error in Java 21 environment, this PR aims to choose one of constructors based on the Java version like netty/netty#13366 .
 
### Are these changes tested?

```
$ java -version
openjdk version "21-ea" 2023-09-19
OpenJDK Runtime Environment (build 21-ea+28-2377)
OpenJDK 64-Bit Server VM (build 21-ea+28-2377, mixed mode, sharing)

$ cd java

$ mvn clean package --am --pl memory/memory-core
...
[INFO] Apache Arrow Java Root POM ......................... SUCCESS [  5.693 s]
[INFO] Arrow Memory ....................................... SUCCESS [  1.703 s]
[INFO] Arrow Memory - Core ................................ SUCCESS [  7.050 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  14.630 s
[INFO] Finished at: 2023-06-28T20:43:29-07:00
[INFO] ------------------------------------------------------------------------
```

### Are there any user-facing changes?

* Closes: #35053

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: David Li <[email protected]>
violetagg added a commit to violetagg/graalvm-reachability-metadata that referenced this pull request Jan 16, 2024
…en JDK 21

Netty project has added a reflection specific for JDK 21 with netty/netty#13366
The reflection hints need to be updated to cover also this JDK version.

java.lang.NoSuchMethodException: java.nio.DirectByteBuffer.<init>(long, long)
        at [email protected]/java.lang.Class.checkMethod(DynamicHub.java:1065) ~[spring.graalvm:na]
        at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:1228) ~[spring.graalvm:na]
        at [email protected]/java.lang.Class.getDeclaredConstructor(DynamicHub.java:2930) ~[spring.graalvm:na]
        at io.netty.util.internal.PlatformDependent0$5.run(PlatformDependent0.java:291) ~[na:na]
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:129) ~[na:na]
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319) ~[na:na]
        at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:286) ~[na:na]
        at io.netty.util.internal.PlatformDependent.isAndroid(PlatformDependent.java:331) ~[na:na]
        at io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:86) ~[na:na]
violetagg added a commit to violetagg/graalvm-reachability-metadata that referenced this pull request Jan 16, 2024
…en JDK 21

Netty project has added a reflection specific for JDK 21 with netty/netty#13366
The reflection hints need to be updated to cover also this JDK version.

java.lang.NoSuchMethodException: java.nio.DirectByteBuffer.<init>(long, long)
        at [email protected]/java.lang.Class.checkMethod(DynamicHub.java:1065) ~[spring.graalvm:na]
        at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:1228) ~[spring.graalvm:na]
        at [email protected]/java.lang.Class.getDeclaredConstructor(DynamicHub.java:2930) ~[spring.graalvm:na]
        at io.netty.util.internal.PlatformDependent0$5.run(PlatformDependent0.java:291) ~[na:na]
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:129) ~[na:na]
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319) ~[na:na]
        at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:286) ~[na:na]
        at io.netty.util.internal.PlatformDependent.isAndroid(PlatformDependent.java:331) ~[na:na]
        at io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:86) ~[na:na]
dnestoro pushed a commit to oracle/graalvm-reachability-metadata that referenced this pull request Jan 18, 2024
…en JDK 21 (#434)

Netty project has added a reflection specific for JDK 21 with netty/netty#13366
The reflection hints need to be updated to cover also this JDK version.

java.lang.NoSuchMethodException: java.nio.DirectByteBuffer.<init>(long, long)
        at [email protected]/java.lang.Class.checkMethod(DynamicHub.java:1065) ~[spring.graalvm:na]
        at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:1228) ~[spring.graalvm:na]
        at [email protected]/java.lang.Class.getDeclaredConstructor(DynamicHub.java:2930) ~[spring.graalvm:na]
        at io.netty.util.internal.PlatformDependent0$5.run(PlatformDependent0.java:291) ~[na:na]
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:129) ~[na:na]
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319) ~[na:na]
        at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:286) ~[na:na]
        at io.netty.util.internal.PlatformDependent.isAndroid(PlatformDependent.java:331) ~[na:na]
        at io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:86) ~[na:na]
kou pushed a commit to apache/arrow-java that referenced this pull request Nov 25, 2024
### Rationale for this change

Java 21 switched `DirectByteBuffer(long,int)` constructor to `DirectByteBuffer(long,long)` via openjdk/jdk@a56598f
 
### What changes are included in this PR?
In order to avoid `NoSuchMethodException` error in Java 21 environment, this PR aims to choose one of constructors based on the Java version like netty/netty#13366 .
 
### Are these changes tested?

```
$ java -version
openjdk version "21-ea" 2023-09-19
OpenJDK Runtime Environment (build 21-ea+28-2377)
OpenJDK 64-Bit Server VM (build 21-ea+28-2377, mixed mode, sharing)

$ cd java

$ mvn clean package --am --pl memory/memory-core
...
[INFO] Apache Arrow Java Root POM ......................... SUCCESS [  5.693 s]
[INFO] Arrow Memory ....................................... SUCCESS [  1.703 s]
[INFO] Arrow Memory - Core ................................ SUCCESS [  7.050 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  14.630 s
[INFO] Finished at: 2023-06-28T20:43:29-07:00
[INFO] ------------------------------------------------------------------------
```

### Are there any user-facing changes?

* Closes: #35053

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: David Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants