gemmellr commented on code in PR #6021: URL: https://github.com/apache/activemq-artemis/pull/6021#discussion_r2495054573
########## artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis: ########## @@ -119,6 +119,9 @@ if [ -f "$ARTEMIS_OOME_DUMP" ] ; then mv $ARTEMIS_OOME_DUMP $ARTEMIS_OOME_DUMP.bkp fi +# Netty needs access to unsafe, but this is turned off in Java 25 by default Review Comment: This comment could be confusing/misleading later, since Unsafe itself is _not_ turned off in Java 25 by default. It warns once on first use on 24+ but whats left of Unsafe (some has been removed already) is still usable. Setting `--sun-misc-unsafe-memory-access=allow` facilitates stopping printing the warning on Java 24+. On future JDKs, e.g perhaps 26+, that will not be permitted and the Unsafe methods will be disabled by default and the allowed fallback will become `--sun-misc-unsafe-memory-access=warn` to again permit them but always with the warning. On yet further future JDKs the Unsafe memory methods will be removed and `--sun-misc-unsafe-memory-access `will be ignored. At a later point `--sun-misc-unsafe-memory-access` will be removed (which may mean its presence prevents startup). _Netty 4.2 doesn't use Unsafe by default_ in Java 24+ so as to avoid the warning (whereas 4.1 still does use Unsafe by default [excepting 4.1.120-4.1.121], hence the warning mentioned on ARTEMIS-5711 when it uses Unsafe currently). Instead it uses the 'fallback MemorySegment' based cleaner on 25+ (it's broken on 24, so that seems to default to heap-buffers rather than direct buffers) rather than use Unsafe. Its possible to have it use a more performant alternative on 24+ by explicitly enabling native access (which is actually still enabled by default on 24+, for now, but again produces a warning, so Netty 4.2 doesn't do this by default to avoid those warnings, requiring the `--enable-native-access` flag). Yet alternatively again, you can make it just use Unsafe on Java 24+ [until they prevent 'allow', perhaps JDK26+] by explicitly specifying it can via `--sun-misc-unsafe-memory-access=allow`, or using the Netty-specific `io.netty.noUnsafe` prop. https://github.com/netty/netty/blob/netty-4.2.7.Final/common/src/main/java/io/netty/util/internal/PlatformDependent0.java#L547-L588 plus the monster starting at https://github.com/netty/netty/blob/4.2/common/src/main/java/io/netty/util/internal/PlatformDependent0.java#L85 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information, visit: https://activemq.apache.org/contact
