Closed
Description
This code:
public class Introspectors {
public static void main(String[] args) throws Exception {
new Introspectors().run();
}
private void run() throws Exception {
PropertyDescriptor[] pds = Introspector.getBeanInfo(Bar.class)
.getPropertyDescriptors();
for (PropertyDescriptor pd : pds) {
System.err.println("Property: " + pd);
}
}
}
runs fine as a normal Java program. As a native image it blows big chunks:
$ cat reflect.json
[
{
"name" : "Bar",
"allPublicFields": true,
"allPublicMethods": true,
"allDeclaredMethods": true,
"allDeclaredFields": true
}
]
$ native-image -H:Name=intro -H:ReflectionConfigurationFiles=reflect.json -H:+ReportUnsupportedElementsAtRuntime -cp target/classes/:target/graal-test-0.0.1-SNAPSHOT-shaded.jar Introspectors
./intro
...
Full Stacktrace:
RSP 00007ffca0b377c0 RIP 00000000004b8230 [image code] java.lang.reflect.Method.getTypeParameters(Method.java:214)
RSP 00007ffca0b377e0 RIP 00000000004b6230 [image code] java.lang.reflect.Executable.sharedToGenericString(Executable.java:148)
RSP 00007ffca0b37860 RIP 00000000004b87af [image code] java.lang.reflect.Method.toGenericString(Method.java:415)
RSP 00007ffca0b37880 RIP 000000000046ce4f [image code] java.beans.MethodRef.set(MethodRef.java:46)
RSP 00007ffca0b378b0 RIP 000000000046be92 [image code] java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:117)
RSP 00007ffca0b378e0 RIP 000000000046b568 [image code] java.beans.MethodDescriptor.<init>(MethodDescriptor.java:72)
RSP 00007ffca0b37900 RIP 00000000004650cf [image code] java.beans.MethodDescriptor.<init>(MethodDescriptor.java:56)
RSP 00007ffca0b37900 RIP 00000000004650cf [image code] java.beans.Introspector.getTargetMethodInfo(Introspector.java:1205)
RSP 00007ffca0b37950 RIP 0000000000461321 [image code] java.beans.Introspector.getBeanInfo(Introspector.java:426)
RSP 00007ffca0b379b0 RIP 0000000000461551 [image code] java.beans.Introspector.getBeanInfo(Introspector.java:173)
RSP 00007ffca0b37a00 RIP 0000000000461800 [image code] java.beans.Introspector.getBeanInfo(Introspector.java:260)
RSP 00007ffca0b37a30 RIP 000000000045f41d [image code] java.beans.Introspector.<init>(Introspector.java:407)
RSP 00007ffca0b37a80 RIP 0000000000461543 [image code] java.beans.Introspector.getBeanInfo(Introspector.java:173)
RSP 00007ffca0b37ad0 RIP 0000000000403018 [image code] Introspectors.run(Introspectors.java:11)
RSP 00007ffca0b37b40 RIP 00000000004518e9 [image code] Introspectors.main(Introspectors.java:7)
RSP 00007ffca0b37b40 RIP 00000000004518e9 [image code] com.oracle.svm.reflect.proxies.Proxy_1_Introspectors_main.invoke(Unknown Source)
RSP 00007ffca0b37b80 RIP 00000000004b843d [image code] java.lang.reflect.Method.invoke(Method.java:498)
RSP 00007ffca0b37bc0 RIP 00000000004036b3 [image code] com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:173)
RSP 00007ffca0b37c10 RIP 00000000004092e3 [image code] com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0)
Use runtime option -R:-InstallSegfaultHandler if you don't want to use SubstrateSegfaultHandler.
Bye bye ...
It might be interesting that without the JSON configuration the program runs successfully, but doesn't detect any property descriptors.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
dsyer commentedon Jul 5, 2018
Doing some more research here it seems that the problem is that introspecting the
getClass()
method causes this exception. If you avoid that method you can step around the problem, but I don't think that's an option withIntrospectors
in the standard Open JDK libraries.dsyer commentedon Jul 5, 2018
Here's another data point. This simple program fails at runtime as a native image in the same way as above:
If you omit the "converters" property, or make it just a plain
List
it works fine, so it seems like it's something connected with the generic signature of the setter?Add a couple of new samples
dsyer commentedon Apr 1, 2019
This app works for me with GraalVM rc14, as long as I have
java.util.List
in the reflection config JSON. I guess that's expected (and therefore this is fixed)? Sample app with full build config: https://github.com/sdeleuze/graal-issues/tree/master/property-descriptor.Add a couple of new samples
cstancu commentedon Apr 1, 2019
@dsyer yes, if adding
java.util.List
to the reflection config fixes the problem then I wouldn't consider this a bug. Thank you for reporting back!