10000 feat(bootstrap): Introduce Java 8 bytecode bridge for instrumentation… · DataDog/dd-trace-java@856a0d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 856a0d8

Browse files
feat(bootstrap): Introduce Java 8 bytecode bridge for instrumentation API (#8736)
Add has context API helpers
1 parent e8a2156 commit 856a0d8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package datadog.trace.bootstrap.instrumentation.api;
2+
3+
import datadog.context.Context;
4+
5+
/**
6+
* A helper for accessing methods that rely on new Java 8 bytecode features such as calling a static
7+
* interface methods. In instrumentation, we may need to call these methods in code that is inlined
8+
* into an instrumented class, however many times the instrumented class has been compiled to a
9+
* previous version of bytecode, and so we cannot inline calls to static interface methods, as those
10+
* were not supported prior to Java 8 and will lead to a class verification error.
11+
*/
12+
public class Java8BytecodeBridge {
13+
/** @see Context#root() */
14+
public static Context getRootContext() {
15+
return Context.root();
16+
}
17+
18+
/** @see Context#current() */
19+
public static Context getCurrentContext() {
20+
return Context.current();
21+
}
22+
23+
/** @see Context#from(Object) */
24+
public static Context getContextFrom(Object carrier) {
25+
return Context.from(carrier);
26+
}
27+
28+
/** @see Context#detachFrom(Object) */
29+
public static Context detachContextFrom(Object carrier) {
30+
return Context.detachFrom(carrier);
31+
}
32+
}

0 commit comments

Comments
 (0)
0