You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Quarkus project, @zakkak is leading an effort to allow throwing exceptions when GraalVM/Mandrel tries to do reflection calls on elements that were not registered for reflection. This effort leads to all sort of discoveries and in the issue above we discovered that Jackson tries to collect information on java.* classes, which should probably be avoided: these classes can't be annotated with Jackson classes and they are well known so we could probably hardcode what's needed.
We are having this issue with at least AnnotatedFieldCollector/AnnotatedMethodCollector/AnnotatedCreatorCollector. There might be others.
Examples of this issue with stacktraces:
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access
java.util.Date.getDeclaredFields()
without it being registered for runtime reflection. Add java.util.Date.getDeclaredFields() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getDeclaredFields(DynamicHub.java:1251)
com.fasterxml.jackson.databind.introspect.AnnotatedFieldCollector._findFields(AnnotatedFieldCollector.java:73)
com.fasterxml.jackson.databind.introspect.AnnotatedFieldCollector._findFields(AnnotatedFieldCollector.java:71)
com.fasterxml.jackson.databind.introspect.AnnotatedFieldCollector.collect(AnnotatedFieldCollector.java:48)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access
java.sql.Date.getDeclaredFields()
without it being registered for runtime reflection. Add java.sql.Date.getDeclaredFields() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getDeclaredFields(DynamicHub.java:1251)
com.fasterxml.jackson.databind.introspect.AnnotatedFieldCollector._findFields(AnnotatedFieldCollector.java:73)
com.fasterxml.jackson.databind.introspect.AnnotatedFieldCollector.collect(AnnotatedFieldCollector.java:48)
com.fasterxml.jackson.databind.introspect.AnnotatedFieldCollector.collectFields(AnnotatedFieldCollector.java:43)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access
java.sql.Date.getDeclaredMethods()
without it being registered for runtime reflection. Add java.sql.Date.getDeclaredMethods() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getDeclaredMethods(DynamicHub.java:1258)
com.fasterxml.jackson.databind.util.ClassUtil.getClassMethods(ClassUtil.java:1300)
com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector._addMemberMethods(AnnotatedMethodCollector.java:115)
com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector.collect(AnnotatedMethodCollector.java:49)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access
java.util.Date.getDeclaredMethods()
without it being registered for runtime reflection. Add java.util.Date.getDeclaredMethods() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getDeclaredMethods(DynamicHub.java:1258)
com.fasterxml.jackson.databind.util.ClassUtil.getClassMethods(ClassUtil.java:1300)
com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector._addMemberMethods(AnnotatedMethodCollector.java:115)
com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector.collect(AnnotatedMethodCollector.java:54)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access
java.io.Serializable.getDeclaredMethods()
without it being registered for runtime reflection. Add java.io.Serializable.getDeclaredMethods() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getDeclaredMethods(DynamicHub.java:1258)
com.fasterxml.jackson.databind.util.ClassUtil.getClassMethods(ClassUtil.java:1300)
com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector._addMemberMethods(AnnotatedMethodCollector.java:115)
com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector.collect(AnnotatedMethodCollector.java:54)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access
java.lang.Cloneable.getDeclaredMethods()
without it being registered for runtime reflection. Add java.lang.Cloneable.getDeclaredMethods() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getDeclaredMethods(DynamicHub.java:1258)
com.fasterxml.jackson.databind.util.ClassUtil.getClassMethods(ClassUtil.java:1300)
com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector._addMemberMethods(AnnotatedMethodCollector.java:115)
com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector.collect(AnnotatedMethodCollector.java:54)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access
java.lang.Comparable.getDeclaredMethods()
without it being registered for runtime reflection. Add java.lang.Comparable.getDeclaredMethods() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getDeclaredMethods(DynamicHub.java:1258)
com.fasterxml.jackson.databind.util.ClassUtil.getClassMethods(ClassUtil.java:1300)
com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector._addMemberMethods(AnnotatedMethodCollector.java:115)
com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector.collect(AnnotatedMethodCollector.java:54)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access
java.sql.Date.getDeclaredConstructors()
without it being registered for runtime reflection. Add java.sql.Date.getDeclaredConstructors() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getDeclaredConstructors(DynamicHub.java:1264)
com.fasterxml.jackson.databind.util.ClassUtil.getConstructors(ClassUtil.java:1345)
com.fasterxml.jackson.databind.introspect.AnnotatedCreatorCollector._findPotentialConstructors(AnnotatedCreatorCollector.java:115)
com.fasterxml.jackson.databind.introspect.AnnotatedCreatorCollector.collect(AnnotatedCreatorCollector.java:70)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access
java.sql.Date.getDeclaredMethods()
without it being registered for runtime reflection. Add java.sql.Date.getDeclaredMethods() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
[email protected]/java.lang.Class.getDeclaredMethods(DynamicHub.java:1258)
com.fasterxml.jackson.databind.util.ClassUtil.getClassMethods(ClassUtil.java:1300)
com.fasterxml.jackson.databind.introspect.AnnotatedCreatorCollector._findPotentialFactories(AnnotatedCreatorCollector.java:197)
com.fasterxml.jackson.databind.introspect.AnnotatedCreatorCollector.collect(AnnotatedCreatorCollector.java:71)
Describe the solution you'd like
Ideally, we should avoid dynamically resolving this information for java.* classes.
Usage example
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
Hmmmh. Ok, now I remember the challenge: although there is existing mechanism to avoid annotation introspection for JDK classes (although only applied to JDK collection types), actual introspection of declared fields etc is still performed. So that'd need to be changed and it's bigger change.
Preventing this traversal would also prevent use of mix-in annotations on JDK types.
I'll probably make this a MapperFeature but one that is opt-out (i.e. default being to skip introspection).
Another question: once I get to implement something, is there some tool I could use to see if access is violated? It'd be good for me to verify changes locally before asking others to check.
Is your feature request related to a problem? Please describe.
This is a follow-up to this discussion in the Quarkus tracker: quarkusio/quarkus#45537 (comment) .
In the Quarkus project, @zakkak is leading an effort to allow throwing exceptions when GraalVM/Mandrel tries to do reflection calls on elements that were not registered for reflection. This effort leads to all sort of discoveries and in the issue above we discovered that Jackson tries to collect information on
java.*
classes, which should probably be avoided: these classes can't be annotated with Jackson classes and they are well known so we could probably hardcode what's needed.We are having this issue with at least
AnnotatedFieldCollector
/AnnotatedMethodCollector
/AnnotatedCreatorCollector
. There might be others.Examples of this issue with stacktraces:
Describe the solution you'd like
Ideally, we should avoid dynamically resolving this information for
java.*
classes.Usage example
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: