[DO NOT MERGE] JFR API usage
@open-telemetry/java-maintainers I'd like to read a JFR file, convert it to OTel profiling format and export it. The JFR consumer API is 9+ only. As seen here, building the profiling exporter with 11 works for the single module, but breaks the parent :exporters:otlp:all build. Any preference on how to change the build deps to support this without making the blast radius of the change too big? Worst case I can split the JFR layer of the export code off into its own module, but I'd prefer to keep it bundled with the rest of the profiling code. Thx.
The JFR consumer API is 9+ only
That isn't completely true. Openjdk contains jfr apis backported from 11 since 8u262. It is a bit weird in the sense that the oracle jdk doesn't contain the backported apis but rather an older version of the jfr api. So actually you don't need to set the java version to 11. One way to make it build would be to use.
tasks {
compileJava {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
options.release.set(null as Int?)
}
}
The issue you have happens because gradle is smart and prevents you adding a dependency that works only with 11 to code that should work with 8. You can disable it with
java {
disableAutoTargetJvm()
}
@laurit hmm, interesting plot twist there, thanks! That almost but not quite works - the compiler is happy, but animal sniffer is not. I assume it's either no longer sure what version it's supposed to be testing against, or thinks jfr isn't in 8.
@laurit hmm, interesting plot twist there, thanks! That almost but not quite works - the compiler is happy, but animal sniffer is not. I assume it's either no longer sure what version it's supposed to be testing against, or thinks jfr isn't in 8.
animal sniffer checks run agains apis supported by android, see https://github.com/open-telemetry/opentelemetry-java/blob/da295cfa3c93b73376e4c32f2dd450b2035483b3/animal-sniffer-signature/build.gradle.kts#L27-L28 I doubt that these will pass no matter what java version you use for compiling. You will probably have to disable animal sniffer (could remove https://github.com/open-telemetry/opentelemetry-java/blob/da295cfa3c93b73376e4c32f2dd450b2035483b3/exporters/otlp/profiles/build.gradle.kts#L6) for the module if you wish to use jfr or move jfr code into separate module or maybe a separate source set would also be enough to trick it (see https://github.com/open-telemetry/opentelemetry-java/blob/da295cfa3c93b73376e4c32f2dd450b2035483b3/buildSrc/src/main/kotlin/otel.animalsniffer-conventions.gradle.kts#L14)