Open phxql opened 3 years ago
Similar issue in Quarkus: https://github.com/quarkusio/quarkus/issues/10420.
Looks like some additional reflect-config.json
entries will be needed for the Caffeine classes. @phxql, doe sthis as a workaround for you? https://github.com/quarkusio/quarkus/issues/10420#issuecomment-653021260
As per https://github.com/quarkusio/quarkus/issues/12961 we are in the same boat, we can't register all the different caffeine combinations because it would increase memory by a lot, users need to add the @TypeHint
definitions for each CNFE produced
In https://github.com/quarkusio/quarkus/issues/10420#issuecomment-654483795, @Sanne suggested an API to "warmup" with so that the AOT could determine which classes to include. I'm not sure how to implement this so if someone more familiar with Graal and how this might work wants to iterate with me, we can try to find a suitable factory construct.
I got it working with this config: https://github.com/qaware/microservices-with-micronaut/blob/master/github-scraper-graal/src/main/graal/reflect.json
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Here is a Kotlin solution with TypeHints. Maybe access types could be reduced, I added all of them for now.
@Context
@TypeHint(
typeNames = [
"com.github.benmanes.caffeine.cache.SSW",
"com.github.benmanes.caffeine.cache.SSMSW",
"com.github.benmanes.caffeine.cache.BLCHeader\$DrainStatusRef",
"com.github.benmanes.caffeine.cache.PSWMS",
"com.github.benmanes.caffeine.cache.PS",
"com.github.benmanes.caffeine.cache.PSW",
"com.github.benmanes.caffeine.cache.StripedBuffer",
"java.lang.Thread",
"com.github.benmanes.caffeine.cache.BBHeader\$ReadCounterRef",
"com.github.benmanes.caffeine.cache.BBHeader\$ReadAndWriteCounterRef",
], accessType = [
TypeHint.AccessType.ALL_DECLARED_CONSTRUCTORS,
TypeHint.AccessType.ALL_DECLARED_FIELDS,
TypeHint.AccessType.ALL_DECLARED_METHODS,
TypeHint.AccessType.ALL_PUBLIC,
TypeHint.AccessType.ALL_PUBLIC_CONSTRUCTORS,
TypeHint.AccessType.ALL_PUBLIC_FIELDS,
TypeHint.AccessType.ALL_PUBLIC_METHODS
]
)
class CaffeineGraalConfig()
Task List
Steps to Reproduce
@Cacheable
./mvnw package -Dpackaging=native-image
Expected Behaviour
It runs.
Actual Behaviour
Exception when accessing the cache:
Environment Information
Linux P1 5.10.10-200.fc33.x86_64 #1 SMP Sun Jan 24 19:58:54 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
OpenJDK 64-Bit Server VM GraalVM CE 21.0.0 (build 11.0.10+8-jvmci-21.0-b06, mixed mode, sharing)