After using the native image agent for my runner jar, it produces an entry for org.graalvm.compiler.hotspot.management.AggregatedMemoryPoolBean in reflect-config.json
{
"name":"org.graalvm.compiler.hotspot.management.AggregatedMemoryPoolBean",
"allPublicConstructors":true
}
This entry resulting in the following during the native image build.
2020-10-31T21:03:23.8523119Z Error: type is not available in this platform: org.graalvm.compiler.hotspot.management.AggregatedMemoryPoolBean
2020-10-31T21:03:23.8528560Z com.oracle.svm.core.util.UserError$UserException: type is not available in this platform: org.graalvm.compiler.hotspot.management.AggregatedMemoryPoolBean
2020-10-31T21:03:23.8536935Z at com.oracle.svm.core.util.UserError.abort(UserError.java:79)
2020-10-31T21:03:23.8537718Z at com.oracle.svm.hosted.FallbackFeature.reportAsFallback(FallbackFeature.java:217)
2020-10-31T21:03:23.8538431Z at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:765)
2020-10-31T21:03:23.8539153Z at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:555)
2020-10-31T21:03:23.8539819Z at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:468)
2020-10-31T21:03:23.8540927Z at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
2020-10-31T21:03:23.8541595Z at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
2020-10-31T21:03:23.8542239Z at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
2020-10-31T21:03:23.8542910Z at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
2020-10-31T21:03:23.8543526Z at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
2020-10-31T21:03:23.8544204Z at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
2020-10-31T21:03:23.8553144Z Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: type is not available in this platform: org.graalvm.compiler.hotspot.management.AggregatedMemoryPoolBean
2020-10-31T21:03:23.8554097Z at com.oracle.graal.pointsto.meta.AnalysisUniverse.createType(AnalysisUniverse.java:218)
2020-10-31T21:03:23.8556617Z at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:209)
2020-10-31T21:03:23.8557722Z at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:186)
2020-10-31T21:03:23.8558475Z at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:76)
2020-10-31T21:03:23.8559176Z at com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess$1.apply(UniverseMetaAccess.java:52)
2020-10-31T21:03:23.8559895Z at com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess$1.apply(UniverseMetaAccess.java:49)
2020-10-31T21:03:23.8560923Z at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1737)
2020-10-31T21:03:23.8561709Z at com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess.lookupJavaType(UniverseMetaAccess.java:84)
2020-10-31T21:03:23.8562454Z at com.oracle.graal.pointsto.meta.AnalysisMetaAccess.lookupJavaType(AnalysisMetaAccess.java:47)
2020-10-31T21:03:23.8563319Z at com.oracle.svm.reflect.hosted.ReflectionDataBuilder.processClass(ReflectionDataBuilder.java:239)
2020-10-31T21:03:23.8564236Z at com.oracle.svm.reflect.hosted.ReflectionDataBuilder.lambda$processRegisteredElements$2(ReflectionDataBuilder.java:235)
2020-10-31T21:03:23.8564842Z at java.base/java.lang.Iterable.forEach(Iterable.java:75)
2020-10-31T21:03:23.8565408Z at com.oracle.svm.reflect.hosted.ReflectionDataBuilder.processRegisteredElements(ReflectionDataBuilder.java:235)
2020-10-31T21:03:23.8566101Z at com.oracle.svm.reflect.hosted.ReflectionDataBuilder.duringAnalysis(ReflectionDataBuilder.java:174)
2020-10-31T21:03:23.8566720Z at com.oracle.svm.reflect.hosted.ReflectionFeature.duringAnalysis(ReflectionFeature.java:79)
2020-10-31T21:03:23.8567504Z at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:732)
2020-10-31T21:03:23.8693268Z at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:70)
2020-10-31T21:03:23.8694369Z at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:732)
2020-10-31T21:03:23.8694935Z ... 8 more
2020-10-31T21:03:23.8981715Z Error: Image build request failed with exit status 1
GraalVM version: 20.2.0
OS: Ubuntu 18.04.1
Architecture: x86_64
@tzezula , seems like the libgraal classes need to be hidden from the native image agent.
@hakdogan Hi,
Can you share a reproducer of this?
@jramirez-isc sure
I have one class
@QuarkusMain
public class TopicListener implements QuarkusApplication {
@Override
public int run(String... args) throws Exception {
final Properties props = new Properties();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
props.put(ConsumerConfig.CLIENT_ID_CONFIG, "consumerClient01");
props.put(ConsumerConfig.GROUP_ID_CONFIG, "consumerGroup01");
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 100);
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
final Consumer<String, String> consumer = new KafkaConsumer<>(props, new StringDeserializer(), new StringDeserializer());
consumer.subscribe(Collections.singletonList("myTopic"));
ConsumerRecords<String, String> records;
try {
while (args.length != 3) {
records = consumer.poll(Duration.ofMillis(100));
for (ConsumerRecord<String, String> record : records) {
System.out.println("Consumed record key " +
record.key() +
" Value " + record.value() +
" Partition " + record.partition() +
" Offset " + record.offset());
}
consumer.commitSync();
}
} catch (Exception ex) {
System.out.println("An exception was thrown in handleCalculateRiskEvent method " + ex);
}
return 0;
}
}
My pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.acme</groupId>
<artifactId>code-with-quarkus</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.8.3.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.8.3.Final</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.4.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.0.8</version>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>
</project>
Hi,
I would like to share with you that my experiment with the latest version gave a similar result because the tracing agent produced the same entry in reflect-config.json
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 20.3.0 (Java Version 11.0.9+10-jvmci-20.3-b06)
...
Error: type is not available in this platform: org.graalvm.compiler.hotspot.management.AggregatedMemoryPoolBean
com.oracle.svm.core.util.UserError$UserException: type is not available in this platform: org.graalvm.compiler.hotspot.management.AggregatedMemoryPoolBean
While we will be able to fix that particular case (a GraalVM internal class that is annotated as hosted only), I want to note that by principle the agent is not able to produce 100% correct reflection configuration files. It is always possible that a HotSpot-only class from the JDK ends up in the reflection configuration. So it will always be necessary to manually inspect the reflection configuration and add / remove some elements.
by principle the agent is not able to produce 100% correct reflection configuration files
I'm aware of this, tbh it would not be realistic to expect otherwise. I just wanted to contribute to your getting one step closer to better by giving feedback.
Most helpful comment
While we will be able to fix that particular case (a GraalVM internal class that is annotated as hosted only), I want to note that by principle the agent is not able to produce 100% correct reflection configuration files. It is always possible that a HotSpot-only class from the JDK ends up in the reflection configuration. So it will always be necessary to manually inspect the reflection configuration and add / remove some elements.