Skip to content

Conversation

jhalliday
Copy link
Contributor

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

@jhalliday jhalliday requested a review from a team as a code owner October 10, 2025 12:07
@laurit
Copy link
Contributor

laurit commented Oct 10, 2025

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()
}

@jhalliday
Copy link
Contributor Author

@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
Copy link
Contributor

laurit commented Oct 13, 2025

@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

signature("com.toasttab.android:gummy-bears-api-23:0.12.0@signature")
signatureJar("com.android.tools:desugar_jdk_libs")
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
id("otel.animalsniffer-conventions")
) 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
sourceSets = listOf(java.sourceSets.main.get())
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants