ben-manes / caffeine

A high performance caching library for Java
Apache License 2.0
15.85k stars 1.59k forks source link

The GraalVM image building is successful, however, the execution fails #1675

Closed 1ssqq1lxr closed 6 months ago

1ssqq1lxr commented 6 months ago

Exception in thread "main" java.lang.IllegalStateException: SSA at com.github.benmanes.caffeine.cache.LocalCacheFactory.newFactory(LocalCacheFactory.java:114) at java.base@21.0.1/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708) at com.github.benmanes.caffeine.cache.LocalCacheFactory.loadFactory(LocalCacheFactory.java:97) at com.github.benmanes.caffeine.cache.LocalCacheFactory.newBoundedLocalCache(LocalCacheFactory.java:46) at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache.(BoundedLocalCache.java:3953) at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache.(BoundedLocalCache.java:3949) at com.github.benmanes.caffeine.cache.Caffeine.build(Caffeine.java:1048) at io.github.quickmsg.edge.mqtt.RetainStore.(RetainStore.java:36) at io.github.quickmsg.edge.mqtt.MqttContext.(MqttContext.java:70) at io.github.quickmsg.edge.mqtt.MqttContext.(MqttContext.java:61) at io.github.quickmsg.edge.mqtt.NodeStarter.main(NodeStarter.java:10) at java.base@21.0.1/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH) Caused by: java.lang.ClassNotFoundException: com.github.benmanes.caffeine.cache.SSA at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:122) at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:86) at java.base@21.0.1/java.lang.Class.forName(DynamicHub.java:1346) at java.base@21.0.1/java.lang.Class.forName(DynamicHub.java:1335) at java.base@21.0.1/java.lang.invoke.MethodHandles$Lookup.findClass(MethodHandles.java:2869) at com.github.benmanes.caffeine.cache.LocalCacheFactory.newFactory(LocalCacheFactory.java:104) ... 11 more

ben-manes commented 6 months ago

Graal is an AOT compiler that discards classes unless you let it know otherwise. You can see our examples directory for how to use it. You will have to configure your project appropriately.

ben-manes commented 6 months ago

https://github.com/ben-manes/caffeine/blob/master/examples/graal-native/src/main/resources/META-INF/native-image/reflect-config.json