20
20
*/
21
21
public class CacheConstructorsFeature implements Feature {
22
22
23
- private final AtomicBoolean triggered = new AtomicBoolean ( false ) ;
23
+ public static final String REGISTER_RECORD_STATS_IMPLEMENTATIONS = "io.quarkus.caffeine.graalvm.recordStats" ;
24
24
25
25
/**
26
26
* To set this, add `-J-Dio.quarkus.caffeine.graalvm.diagnostics=true` to the native-image parameters
27
27
*/
28
28
private static final boolean log = Boolean .getBoolean ("io.quarkus.caffeine.graalvm.diagnostics" );
29
29
30
+ private final AtomicBoolean triggered = new AtomicBoolean (false );
31
+
30
32
@ Override
31
33
public void beforeAnalysis (BeforeAnalysisAccess access ) {
32
34
Class <?> caffeineCoreClazz = access .findClassByName ("com.github.benmanes.caffeine.cache.Caffeine" );
@@ -49,6 +51,12 @@ private void registerCaffeineReflections(DuringAnalysisAccess duringAnalysisAcce
49
51
for (String className : needsHavingSimpleConstructors ) {
50
52
registerForReflection (className , duringAnalysisAccess );
51
53
}
54
+
55
+ if (Boolean .getBoolean (REGISTER_RECORD_STATS_IMPLEMENTATIONS )) {
56
+ for (String className : typesNeedingConstructorsRegisteredWhenRecordingStats ()) {
57
+ registerForReflection (className , duringAnalysisAccess );
58
+ }
59
+ }
52
60
}
53
61
54
62
private void registerForReflection (
@@ -60,11 +68,13 @@ private void registerForReflection(
60
68
RuntimeReflection .register (z );
61
69
}
62
70
71
+ /**
72
+ * This list is not complete, but a selection of the types we expect being most useful.
73
+ * unfortunately registering all of them has been shown to have a very significant impact
74
+ * on executable sizes. See https://github.com/quarkusio/quarkus/issues/12961
75
+ */
63
76
public static String [] typesNeedingConstructorsRegistered () {
64
77
return new String [] {
65
- //N.B. this list is not complete, but a selection of the types we expect being most useful.
66
- //unfortunately registering all of them has been shown to have a very significant impact
67
- //on executable sizes. See https://github.com/quarkusio/quarkus/issues/12961
68
78
"com.github.benmanes.caffeine.cache.PDMS" ,
69
79
"com.github.benmanes.caffeine.cache.PSA" ,
70
80
"com.github.benmanes.caffeine.cache.PSMS" ,
@@ -82,4 +92,16 @@ public static String[] typesNeedingConstructorsRegistered() {
82
92
};
83
93
}
84
94
95
+ public static String [] typesNeedingConstructorsRegisteredWhenRecordingStats () {
96
+ return new String [] {
97
+ "com.github.benmanes.caffeine.cache.SILSMS" ,
98
+ "com.github.benmanes.caffeine.cache.SSSA" ,
99
+ "com.github.benmanes.caffeine.cache.SSLSA" ,
100
+ "com.github.benmanes.caffeine.cache.SSLSMS" ,
101
+ "com.github.benmanes.caffeine.cache.SSSMS" ,
102
+ "com.github.benmanes.caffeine.cache.SSSMSA" ,
103
+ "com.github.benmanes.caffeine.cache.SSSMSW" ,
104
+ "com.github.benmanes.caffeine.cache.SSSW"
105
+ };
106
+ }
85
107
}
0 commit comments