open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.88k stars 823 forks source link

java agent is build with JDK 11, to build with JDK17 #9148

Closed pureiboi closed 1 year ago

pureiboi commented 1 year ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is.

Our project has upgraded to JDK17, when using java auto-instrumentation error is thrown since java agent is build with JDK11

Describe the solution you'd like A clear and concise description of what you want to happen.

java agent to be build with JDK17

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

will build java agent manually to support application, and continue with JDK17 upgrade within my project

Additional context Add any other context or screenshots about the feature request here.

the error message thrown during springboot runtime

java.lang.UnsupportedClassVersionError: - has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

laurit commented 1 year ago

java.lang.UnsupportedClassVersionError: - has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

Means that you are running your app with java 11 and trying to load a class compiled for 17. It has nothing to do with the agent.

pureiboi commented 1 year ago

my app is running on jdk 17.

I lookup the java class, i'm abit confused. the class is compiled in JDK1.8 Not sure if i'm looking at the wrong info?

from the CONTRIBUTING.md, the project stated that running on JDK17

https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/CONTRIBUTING.md

This project requires Java 17 to build and run tests. Newer JDK's may work, but this version is used in CI.

Classfile: opentelemetry-java-instrumentation/javaagent/build/libs/opentelemetry-javaagent-1.28.0/io/opentelemetry/javaagent/OpenTelemetryAgent.class
  Last modified 1 Feb 1980; size 4888 bytes
  SHA-256 checksum 22fedf84913f2a74f4ebb2b5c19d1878e36137b0186fe129b51b78900b908ab7
  Compiled from "OpenTelemetryAgent.java"
public final class io.opentelemetry.javaagent.OpenTelemetryAgent
  minor version: 0
  major version: 52
  flags: (0x0031) ACC_PUBLIC, ACC_FINAL, ACC_SUPER
  this_class: #2                          // io/opentelemetry/javaagent/OpenTelemetryAgent
  super_class: #4                         // java/lang/Object
  interfaces: 0, fields: 0, methods: 7, attributes: 1
laurit commented 1 year ago

my app is running on jdk 17.

The exception message this version of the Java Runtime only recognizes class file versions up to 55.0 indicates that it is running on java 11 not 17.

I lookup the java class, i'm abit confused. the class is compiled in JDK1.8 Not sure if i'm looking at the wrong info?

You are misinterpreting this information. Java compiler supports setting version for target class file so that applications compiled with newer compiler could run on older runtime. For example the agent is compiled with java 17, but the target version is set to either 8, 11 or 17 depending on the module compiled. The class file only says that it is compiled for java 8, it says nothing about the version of the compiler used. Classes compiled for java 8 run just fine on java 17, but not vice versa. Running class compiled for newer version on older runtime results in UnsupportedClassVersionError.

pureiboi commented 1 year ago

apologies. yes, i have misinterpreting the error message.

the container runtime used was not jdk17. you're right that i have build my app with jdk17 but runs on jdk11.

no issue on otel javaagent.

thanks!