question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Native image configuration not compatible with Java 11

See original GitHub issue

Describe 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:

  1. https://github.com/zakkak/micrometer-native-image-reproducer.git
  2. cd micrometer-native-image-reproducer
  3. mvn package
  4. native-image -jar target/reproducer-1.0-SNAPSHOT.jar

Using native-image from GraalVM CE java11 21.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
shakuzencommented, Jun 30, 2021

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.

did you do so on a public forum? If yes, could you please share the link to the discussion? Thanks

It was on a private slack channel.

1reaction
gsmetcommented, Jun 29, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found