From 80340d00529d1bc77888c3c03af734e88a2d90c1 Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Fri, 3 Mar 2023 12:18:02 +0200 Subject: [PATCH] Reinitialize sun.security.pkcs11.P11Util at runtime Fixes build error: ``` Error: Detected a java.lang.ref.Cleaner object in the image heap which uses a daemon thread that invokes cleaning actions, but threads running in the image generator are no longer running at image runtime. To see how this object got instantiated use --trace-object-instantiation=java.lang.ref.Cleaner. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point. Detailed message: Trace: Object was reached by trying to constant fold static field sun.security.pkcs11.P11Util.cleaner at sun.security.pkcs11.wrapper.PKCS11.(PKCS11.java:170) parsing method sun.security.pkcs11.wrapper.PKCS11.(PKCS11.java:154) reachable via the parsing context at static root method.(Unknown Source) ``` --- .../java/io/quarkus/security/deployment/SecurityProcessor.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/security/deployment/src/main/java/io/quarkus/security/deployment/SecurityProcessor.java b/extensions/security/deployment/src/main/java/io/quarkus/security/deployment/SecurityProcessor.java index ec9bd2f7adec5..134b3e042e96e 100644 --- a/extensions/security/deployment/src/main/java/io/quarkus/security/deployment/SecurityProcessor.java +++ b/extensions/security/deployment/src/main/java/io/quarkus/security/deployment/SecurityProcessor.java @@ -231,6 +231,8 @@ private static void prepareBouncyCastleProvider(CurateOutcomeBuildItem curateOut runtimeReInitialized.produce(new RuntimeReinitializedClassBuildItem("org.bouncycastle.jcajce.spec.ECUtil")); } + // Reinitialize class because it embeds a java.lang.ref.Cleaner instance in the image heap + runtimeReInitialized.produce(new RuntimeReinitializedClassBuildItem("sun.security.pkcs11.P11Util")); } @BuildStep