Package io.quarkus.netty.deployment
Class NettyProcessor
java.lang.Object
io.quarkus.netty.deployment.NettyProcessor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItembuild(NettyBuildTimeConfig config, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem> reflectiveClass, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem> reflectiveMethods, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.nativeimage.ReflectiveFieldBuildItem> reflectiveFields, List<MinNettyAllocatorMaxOrderBuildItem> minMaxOrderBuildItems) (package private) io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItembuild25Specific(io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem> reflectiveMethods, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.nativeimage.ReflectiveFieldBuildItem> reflectiveFields, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.ModuleOpenBuildItem> moduleOpenBuildItem) JEP 471 locks down access to sun.misc.Unsafe, Netty needs to adapt to this to maintain its efficiency.(package private) io.quarkus.deployment.logging.LogCleanupFilterBuildItemOn mac, if you do not have the `MacOSDnsServerAddressStreamProvider` class, Netty prints a warning saying it falls back to the default system DNS provider.(package private) io.quarkus.deployment.logging.LogCleanupFilterBuildItemio.quarkus.deployment.builditem.SystemPropertyBuildItem(package private) voidindexTransports(io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.IndexDependencyBuildItem> producer) io.quarkus.deployment.builditem.SystemPropertyBuildItemlimitArenaSize(NettyBuildTimeConfig config, List<MinNettyAllocatorMaxOrderBuildItem> minMaxOrderBuildItems) io.quarkus.deployment.builditem.nativeimage.NativeImageSystemPropertyBuildItemlimitMem()(package private) voidnativeTransportsEnableNativeAccess(io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.ModuleEnableNativeAccessBuildItem> nativeAccess) (package private) io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem`Version.identify()` in netty-common uses the resource to determine the version of netty.(package private) voidregisterEventLoopBeans(io.quarkus.deployment.annotations.BuildProducer<io.quarkus.arc.deployment.SyntheticBeanBuildItem> syntheticBeans, Optional<EventLoopSupplierBuildItem> loopSupplierBuildItem, io.quarkus.netty.runtime.NettyRecorder recorder, io.quarkus.deployment.annotations.BuildProducer<EventLoopGroupBuildItem> eventLoopGroups) (package private) io.quarkus.arc.deployment.AdditionalBeanBuildItemio.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem(package private) io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItemio.quarkus.deployment.builditem.GeneratedRuntimeSystemPropertyBuildItem(package private) io.quarkus.deployment.builditem.BytecodeTransformerBuildItemTransformsio.netty.util.internal.CleanerJava9to take advantage of the fact that we know we are in Java 17+ Generated bytecode structure:(package private) voidtransformDefaultChannelId(io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.BytecodeTransformerBuildItem> bytecodeTransformers) RewritesDefaultChannelId#processHandlePid(ClassLoader)to avoid reflection as we know we are using Java 17+.(package private) voidtransformIsSharable(io.quarkus.deployment.builditem.CombinedIndexBuildItem indexBuildItem, io.quarkus.netty.runtime.NettyRecorder recorder, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.BytecodeTransformerBuildItem> producer) (package private) voidtransformPlatformDependent0(io.quarkus.deployment.pkg.builditem.CompiledJavaVersionBuildItem compiledJavaVersion, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.BytecodeTransformerBuildItem> producer) When the application targets Java 21+, then we can convertio.netty.util.internal.PlatformDependent0to depend explicitly on Virtual Threads instead of Netty needing to use reflection (that has a noticeable impact on startup).List<io.quarkus.deployment.builditem.nativeimage.UnsafeAccessedFieldBuildItem>
-
Constructor Details
-
NettyProcessor
NettyProcessor()
-
-
Method Details
-
limitMem
public io.quarkus.deployment.builditem.nativeimage.NativeImageSystemPropertyBuildItem limitMem() -
limitArenaSize
public io.quarkus.deployment.builditem.SystemPropertyBuildItem limitArenaSize(NettyBuildTimeConfig config, List<MinNettyAllocatorMaxOrderBuildItem> minMaxOrderBuildItems) -
setNettyMachineId
public io.quarkus.deployment.builditem.GeneratedRuntimeSystemPropertyBuildItem setNettyMachineId() -
disableFinalizers
public io.quarkus.deployment.builditem.SystemPropertyBuildItem disableFinalizers() -
build25Specific
io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItem build25Specific(io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem> reflectiveMethods, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.nativeimage.ReflectiveFieldBuildItem> reflectiveFields, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.ModuleOpenBuildItem> moduleOpenBuildItem) JEP 471 locks down access to sun.misc.Unsafe, Netty needs to adapt to this to maintain its efficiency. As this work progresses in upstream Netty to handle this better automatically, we can already apply the following recommendations by the Netty team. See also #39907 and Java 24 and sun.misc.unsafe. Unfortunately, "--sun-misc-unsafe-memory-access=allow" should also be set for Java runtime, but it can't be applied automatically as the JAR Manifest format doesn't allow setting such an option. -
build
io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItem build(NettyBuildTimeConfig config, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem> reflectiveClass, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem> reflectiveMethods, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.nativeimage.ReflectiveFieldBuildItem> reflectiveFields, List<MinNettyAllocatorMaxOrderBuildItem> minMaxOrderBuildItems) -
registerEventLoopBeans
void registerEventLoopBeans(io.quarkus.deployment.annotations.BuildProducer<io.quarkus.arc.deployment.SyntheticBeanBuildItem> syntheticBeans, Optional<EventLoopSupplierBuildItem> loopSupplierBuildItem, io.quarkus.netty.runtime.NettyRecorder recorder, io.quarkus.deployment.annotations.BuildProducer<EventLoopGroupBuildItem> eventLoopGroups) -
registerQualifiers
io.quarkus.arc.deployment.AdditionalBeanBuildItem registerQualifiers() -
reinitScheduledFutureTask
public io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem reinitScheduledFutureTask() -
unsafeAccessedFields
public List<io.quarkus.deployment.builditem.nativeimage.UnsafeAccessedFieldBuildItem> unsafeAccessedFields() -
runtimeInitBcryptUtil
io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem runtimeInitBcryptUtil() -
cleanupUnsafeLog
io.quarkus.deployment.logging.LogCleanupFilterBuildItem cleanupUnsafeLog() -
cleanupMacDNSInLog
io.quarkus.deployment.logging.LogCleanupFilterBuildItem cleanupMacDNSInLog()On mac, if you do not have the `MacOSDnsServerAddressStreamProvider` class, Netty prints a warning saying it falls back to the default system DNS provider. This is not a problem and generates tons of questions.- Returns:
- the log cleanup item removing the message
-
nettyVersions
io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem nettyVersions()`Version.identify()` in netty-common uses the resource to determine the version of netty. -
transformCleanerJava9
io.quarkus.deployment.builditem.BytecodeTransformerBuildItem transformCleanerJava9()Transformsio.netty.util.internal.CleanerJava9to take advantage of the fact that we know we are in Java 17+ Generated bytecode structure:final class CleanerJava9 implements Cleaner { private static final InternalLogger logger = InternalLoggerFactory.getInstance(CleanerJava9.class); private static final boolean SUPPORTED; private static void freeDirectBufferPrivileged(ByteBuffer buffer) { Exception error = AccessController.doPrivileged(new PrivilegedAction(buffer)); if (error != null) { PlatformDependent0.throwException(error); } } static { boolean var2 = false; Throwable var3 = null; if (!PlatformDependent0.hasUnsafe()) { var3 = new UnsupportedOperationException("sun.misc.Unsafe unavailable"); } else { try { ByteBuffer var0 = ByteBuffer.allocateDirect(1); PlatformDependent0.UNSAFE.invokeCleaner(var0); var2 = true; } catch (Throwable var4) { var3 = var4; } } SUPPORTED = var2; if (var3 != null) { logger.debug("java.nio.ByteBuffer.cleaner(): unavailable", var3); } else { logger.debug("java.nio.ByteBuffer.cleaner(): available"); } } public void freeDirectBuffer(ByteBuffer var1) { if (System.getSecurityManager() != null) { freeDirectBufferPrivileged(var1); } else { PlatformDependent0.UNSAFE.invokeCleaner(var1); } } public static boolean isSupported() { return SUPPORTED; } } -
transformPlatformDependent0
void transformPlatformDependent0(io.quarkus.deployment.pkg.builditem.CompiledJavaVersionBuildItem compiledJavaVersion, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.BytecodeTransformerBuildItem> producer) When the application targets Java 21+, then we can convertio.netty.util.internal.PlatformDependent0to depend explicitly on Virtual Threads instead of Netty needing to use reflection (that has a noticeable impact on startup). The change makes theIS_VIRTUAL_THREAD_METHODandBASE_VIRTUAL_THREAD_CLASSfieldsnullwhile also converting theisVirtualThreadmethod to:
The reason we don't remove the aforementioned fields is that to do that we would have to transform the class loading initialization method, which would be to brittle.static boolean isVirtualThread() { return thread != null && thread.isVirtual(); } -
transformDefaultChannelId
void transformDefaultChannelId(io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.BytecodeTransformerBuildItem> bytecodeTransformers) RewritesDefaultChannelId#processHandlePid(ClassLoader)to avoid reflection as we know we are using Java 17+.Generates:
public static int processHandlePid(ClassLoader classLoader) { int resultVar; try { ProcessHandle processHandle = ProcessHandle.current(); long pid = processHandle.pid(); long maxInt = 2147483647L; int cmp = Long.compare(pid, maxInt); if (cmp > 0) { resultVar = -1; } else { resultVar = (int) pid; } } catch (Exception e) { logger.debug("Could not invoke ProcessHandle.current().pid();", e); resultVar = -1; } return resultVar; } -
nativeTransportsEnableNativeAccess
void nativeTransportsEnableNativeAccess(io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.ModuleEnableNativeAccessBuildItem> nativeAccess) -
indexTransports
void indexTransports(io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.IndexDependencyBuildItem> producer) -
transformIsSharable
void transformIsSharable(io.quarkus.deployment.builditem.CombinedIndexBuildItem indexBuildItem, io.quarkus.netty.runtime.NettyRecorder recorder, io.quarkus.deployment.annotations.BuildProducer<io.quarkus.deployment.builditem.BytecodeTransformerBuildItem> producer)
-