Skip to content

Introduce Java 8 bytecode bridge for instrumentation API #8736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package datadog.trace.bootstrap.instrumentation.api;

import datadog.context.Context;

/**
* A helper for accessing methods that rely on new Java 8 bytecode features such as calling a static
* interface methods. In instrumentation, we may need to call these methods in code that is inlined
* into an instrumented class, however many times the instrumented class has been compiled to a
* previous version of bytecode, and so we cannot inline calls to static interface methods, as those
* were not supported prior to Java 8 and will lead to a class verification error.
*/
public class Java8BytecodeBridge {
/** @see Context#root() */
public static Context getRootContext() {
return Context.root();
}

/** @see Context#current() */
public static Context getCurrentContext() {
return Context.current();
}

/** @see Context#from(Object) */
public static Context getContextFrom(Object carrier) {
return Context.from(carrier);
}

/** @see Context#detachFrom(Object) */
public static Context detachContextFrom(Object carrier) {
return Context.detachFrom(carrier);
}
}
Loading