quarkus: Caffeine error at runtime when using native build

Describe the bug

"causedBy": {
--
  | "exception": {
  | "refId": 5,
  | "exceptionType": "java.lang.ClassNotFoundException",
  | "message": "com.github.benmanes.caffeine.cache.SSMSW",
  | "frames": [
  | {
  | "class": "com.oracle.svm.core.hub.ClassForNameSupport",
  | "method": "forName",
  | "line": 60
  | },
  | {
  | "class": "java.lang.ClassLoader",
  | "method": "loadClass",
  | "line": 160
  | },
  | {
  | "class": "com.github.benmanes.caffeine.cache.LocalCacheFactory",
  | "method": "newBoundedLocalCache",
  | "line": 95
  | },

Expected behavior Should be working in Native build

Actual behavior Only works on JVM build and local dev. Build native is successful, but at runtime it triggers an error

To Reproduce Steps to reproduce the behavior:

  1. Error when a code is hit with caffeine implementation at runtime
  2. No problem with JVM build and local dev runtime

Environment (please complete the following information): Quarkus 1.5.2.Final GraalVM 20.1.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 37 (19 by maintainers)

Commits related to this issue

Most upvoted comments

@ben-manes I confirm it’s all good from my side with your snapshot.

Draft PR is here: https://github.com/quarkusio/quarkus/pull/12621 .

@geoand: com.github.benmanes.caffeine.cache.SSMSW should probably be registered for reflection in CaffeineProcessor.

All the more reason for the extension to be doing this work

A similar issue was raised in https://github.com/ben-manes/caffeine/issues/434. I am not familiar with GraalVM, so my question is naive:

Should libraries provide a manifest of for reflection, e.g. reflection-config.json, and would that be automatically picked up by Graal? If so, we could code generate this resource file in addition to the classes. Of course that would also mean including all of the generated classes, rather than the minimal subset an application is using. We use reflection because explicit switch/new was expensive to class load.

Thanks @geoand for that option

Btw these are the classes that was imported

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;