tjwatson/atomos

MalformedParameterizedTypeException when building service.substrate

Closed this issue · 6 comments

I was able to build atomos and the tests seem to run fine. I switched to Graal 19.2.1 and ran mvn clean package. Here is the result:

Build on Server(pid: 43989, port: 64230)*
[atomos:43989] classlist: 2,348.92 ms
[atomos:43989] (cap): 2,325.04 ms
[atomos:43989] setup: 3,194.65 ms
[atomos:43989] analysis: 5,234.43 ms
Fatal error: java.lang.reflect.MalformedParameterizedTypeException
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:58)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.(ParameterizedTypeImpl.java:51)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:92)
at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.repository.FieldRepository.getGenericType(FieldRepository.java:85)
at java.lang.reflect.Field.getGenericType(Field.java:247)
at com.oracle.svm.reflect.hosted.ReflectionMetadataFeature.replacer(ReflectionMetadataFeature.java:72)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.replaceObject(AnalysisUniverse.java:532)
at com.oracle.graal.pointsto.ObjectScanner.scanArray(ObjectScanner.java:259)
at com.oracle.graal.pointsto.ObjectScanner.doScan(ObjectScanner.java:349)
at com.oracle.graal.pointsto.ObjectScanner.access$400(ObjectScanner.java:62)
at com.oracle.graal.pointsto.ObjectScanner$3$1.run(ObjectScanner.java:414)
at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:171)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error: Image build request failed with exit status 1

I just cloned a fresh repository to try this out and could not reproduce. What OS/Arch are you using? The exception is a bit mysterious because it doesn't give any indication what class it is complaining about from any of the libraries we are including in the image.

Also, have you tried stopping all of your substrate build servers, for example the one with the PID Build on Server(pid: 43989, port: 64230)*. I've found that sometimes the build server for substrate gets into a bad state and I have to kill them to get it to work.

MacOS 10.14.6. I built Atomos with Java SE 11.0.5 and have GraalVM CE 19.2.1 installed. I tried killing the build server but it started a new one with the same result. Here's the command that fails FWIW:

/Library/Java/JavaVirtualMachines/graalvm-ce-19.2.1/Contents/Home/jre/bin/native-image -cp /Users/gw6/.m2/repository/org/eclipse/platform/org.eclipse.osgi/3.16.0.tjwatson_osgiConnect01/org.eclipse.osgi-3.16.0.tjwatson_osgiConnect01.jar:/Users/gw6/.m2/repository/org/atomos/atomos.framework/0.0.1-SNAPSHOT/atomos.framework-0.0.1-SNAPSHOT.jar:/Users/gw6/.m2/repository/org/atomos/service.contract/0.0.1-SNAPSHOT/service.contract-0.0.1-SNAPSHOT.jar:/Users/gw6/.m2/repository/org/atomos/service.impl/0.0.1-SNAPSHOT/service.impl-0.0.1-SNAPSHOT.jar:/Users/gw6/.m2/repository/org/osgi/org.osgi.service.component.annotations/1.4.0/org.osgi.service.component.annotations-1.4.0.jar:/Users/gw6/.m2/repository/org/atomos/service.impl.activator/0.0.1-SNAPSHOT/service.impl.activator-0.0.1-SNAPSHOT.jar:/Users/gw6/.m2/repository/org/apache/felix/org.apache.felix.scr/2.1.16/org.apache.felix.scr-2.1.16.jar:/Users/gw6/.m2/repository/org/codehaus/mojo/animal-sniffer-annotations/1.9/animal-sniffer-annotations-1.9.jar:/Users/gw6/.m2/repository/org/osgi/osgi.promise/7.0.1/osgi.promise-7.0.1.jar:/Users/gw6/.m2/repository/org/apache/felix/org.apache.felix.gogo.command/1.1.0/org.apache.felix.gogo.command-1.1.0.jar:/Users/gw6/.m2/repository/org/apache/felix/org.apache.felix.gogo.runtime/1.1.2/org.apache.felix.gogo.runtime-1.1.2.jar:/Users/gw6/.m2/repository/org/apache/felix/org.apache.felix.gogo.shell/1.1.2/org.apache.felix.gogo.shell-1.1.2.jar:/Users/gw6/.m2/repository/org/apache/felix/org.apache.felix.http.jetty/3.1.0/org.apache.felix.http.jetty-3.1.0.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/jetty-servlet/9.2.12.v20150709/jetty-servlet-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/jetty-server/9.2.12.v20150709/jetty-server-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/jetty-http/9.2.12.v20150709/jetty-http-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/jetty-io/9.2.12.v20150709/jetty-io-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/jetty-util/9.2.12.v20150709/jetty-util-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/jetty-jmx/9.2.12.v20150709/jetty-jmx-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/jetty-security/9.2.12.v20150709/jetty-security-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/jetty-webapp/9.2.12.v20150709/jetty-webapp-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/jetty-xml/9.2.12.v20150709/jetty-xml-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/websocket/websocket-servlet/9.2.12.v20150709/websocket-servlet-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/websocket/websocket-api/9.2.12.v20150709/websocket-api-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/websocket/websocket-server/9.2.12.v20150709/websocket-server-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/websocket/websocket-common/9.2.12.v20150709/websocket-common-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/eclipse/jetty/websocket/websocket-client/9.2.12.v20150709/websocket-client-9.2.12.v20150709.jar:/Users/gw6/.m2/repository/org/apache/felix/org.apache.felix.http.base/3.0.0/org.apache.felix.http.base-3.0.0.jar:/Users/gw6/.m2/repository/com/google/code/findbugs/jsr305/3.0.0/jsr305-3.0.0.jar:/Users/gw6/.m2/repository/org/apache/felix/org.apache.felix.http.api/3.0.0/org.apache.felix.http.api-3.0.0.jar:/Users/gw6/.m2/repository/org/apache/felix/org.apache.felix.http.whiteboard/3.0.0/org.apache.felix.http.whiteboard-3.0.0.jar:/Users/gw6/.m2/repository/org/apache/felix/org.apache.felix.webconsole/4.3.16/org.apache.felix.webconsole-4.3.16-all.jar:/Users/gw6/.m2/repository/org/apache/felix/org.apache.felix.http.servlet-api/1.1.2/org.apache.felix.http.servlet-api-1.1.2.jar:/Users/gw6/.m2/repository/org/apache/tomcat/tomcat-servlet-api/8.0.9/tomcat-servlet-api-8.0.9.jar:/Users/gw6/.m2/repository/org/osgi/org.osgi.service.cm/1.5.0/org.osgi.service.cm-1.5.0.jar:/Users/gw6/.m2/repository/org/osgi/org.osgi.service.event/1.4.0/org.osgi.service.event-1.4.0.jar:/Users/gw6/Work/git/atomos/atomos.tests/service.substrate/target/service.substrate-0.0.1-SNAPSHOT.jar -Dosgi.connect.substrate=/Users/gw6/Work/git/atomos/atomos.tests/service.substrate/target -H:+ReportUnsupportedElementsAtRuntime --allow-incomplete-classpath --no-fallback -H:ReflectionConfigurationFiles=/Users/gw6/Work/git/atomos/atomos.tests/service.substrate/graal_class_config.json -H:ResourceConfigurationFiles=/Users/gw6/Work/git/atomos/atomos.tests/service.substrate/graal_resource_config.json --initialize-at-build-time=org.eclipse.osgi,org.eclipse.equinox.log,org.atomos.framework,org.osgi.framework,org.osgi.dto,org.osgi.service.condpermadmin,org.osgi.service.log,org.osgi.service.packageadmin,org.osgi.service.permissionadmin,org.osgi.service.resolver,org.osgi.service.startlevel,org.osgi.service.url,org.osgi.util.tracker,org.osgi.resource,org.apache.felix.resolver,javax.servlet -H:+ReportExceptionStackTraces -H:+TraceClassInitialization -H:Class=org.atomos.service.substrate.GogoConsole -H:Name=atomos

Hi I get the same error, on Mac OS too, with the identical setup.

The reason is the change from yesterday.

19282a8

Removing reflection config felix.scr for SCR resolved the problem.

==> remove this from graal_class_config.json
{
"name" : "org.apache.felix.scr.impl.ComponentCommands",
"allPublicMethods" : true,
"allDeclaredMethods" : true,
"allPublicFields" : true,
"allDeclaredFields" : true
},
<==

Build on Server(pid: 22336, port: 58967)
[atomos:22336] classlist: 1,053.85 ms
[atomos:22336] (cap): 1,517.00 ms
[atomos:22336] setup: 1,819.30 ms
[atomos:22336] analysis: 4,078.35 ms
Fatal error: java.lang.reflect.MalformedParameterizedTypeException
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:58)

Removing reflection config felix.scr for SCR resolved the problem.

==> remove this from graal_class_config.json
{
"name" : "org.apache.felix.scr.impl.ComponentCommands",
"allPublicMethods" : true,
"allDeclaredMethods" : true,
"allPublicFields" : true,
"allDeclaredFields" : true
},
<==

This resolves the issue for me as well.

I clear my m2 cache and see the issue now. I cannot figure out what is in my old backed up m2 cache that makes it work though. I also noticed that the classpath being passed to the native-image is way to much. I need to add a bunch of exclusions to the parent pom to avoid this. There is no need to pull in all the transitive dependencies of each bundle.

I did this locally and now it fails with my old backed up m2!!! I'm going to open a graal issue for this because the error message is incomprehensible and I suspect a bug in substrate native compilation.

I fixed this by explicitly listing the required methods from ComponentCommands:

  {
    "name" : "org.apache.felix.scr.impl.ComponentCommands",
    "methods" : [
      { "name" : "list", "parameterTypes" : [] },
      { "name" : "list", "parameterTypes" : ["long"] },
      { "name" : "info", "parameterTypes" : ["java.lang.String"] },
      { "name" : "info", "parameterTypes" : ["long"] },
      { "name" : "enable", "parameterTypes" : ["java.lang.String"] },
      { "name" : "disable", "parameterTypes" : ["java.lang.String"] },
      { "name" : "config", "parameterTypes" : [] }
    ]
  },

Note that I did rewrite history in master against all git best practices because I noticed master still had a binary JAR contained in one of its commits and I wanted that all cleaned out of the repository.