Native image configuration not compatible with Java 11
See original GitHub issueDescribe the bug
micrometer-core-1.7.1.jar fails to compile without --allow-incomplete-classpath
/-H:+AllowIncompleteClasspath
when using GraalVM’s native-image
with JDK 11.
The reason is that Micrometer adds getCpuLoad()
to the reflection configuration, however getCpuLoad()
is only available since JDK 14 resulting in the following error when using GraalVM CE with Java 11:
Error: Error parsing reflection configuration in jar:file:/home/zakkak/code/tmp/micrometer-reproducer/reproducer/target/reproducer-1.0-SNAPSHOT.jar!/META-INF/native-image/io.micrometer/micrometer-core/reflect-config.json:
Method com.sun.management.OperatingSystemMXBean.getCpuLoad() not found. To allow unresolvable reflection configuration, use option -H:+AllowIncompleteClasspath
source: https://github.com/quarkusio/quarkus/pull/18120
Environment
- Micrometer version: 1.7.1
- Micrometer registry: prometheus
- OS: Ubuntu 20.04
- Java version: 11
To Reproduce How to reproduce the bug:
https://github.com/zakkak/micrometer-native-image-reproducer.git
- cd micrometer-native-image-reproducer
- mvn package
native-image
-jar target/reproducer-1.0-SNAPSHOT.jar
Using native-image
from GraalVM CE java11 21.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Getting Started - GraalVM
First, the native-image tool performs static analysis of your code to determine the classes and methods that are reachable when your application runs....
Read more >Working with Native Image efficiently | graalvm - Medium
One of the most frequent reasons why a native image fails, is incomplete or completely missing configuration for the dynamic features which ...
Read more >GraalVM Native Image Support - Spring
There are some limitations around some aspects of Java applications that are not fully supported. The Native Image Compatibility Guide section ...
Read more >Native Image - Oracle Help Center
Native Image is a technology to ahead-of-time compile Java code to a standalone executable, called a native image. This executable includes the application ......
Read more >Gradle plugin for GraalVM Native Image building
No compatible toolchains found for request filter: {languageVersion=11, ... Adds a native image configuration file directory, containing files like ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also let us know how urgent a patch release with this fix is for you. Our next scheduled round of patch releases will probably be July 14, but we can do a round of patch releases sooner if you need it.
It was on a private slack channel.
@shakuzen using the
--allow-incomplete-classpath
option has numerous consequences and we don’t support it in Quarkus.I’m not sure exactly what a good solution could be (conditional reflection probably… @zakkak any chance you could bring that up with the Mandrel/GraalVM team?) but for now, given the Java 16 GraalVM is only preview, I would support Java 11.
And hopefully a solution could be found before 16 gets out of preview.