Skip to content

Commit f351043

Browse files
committed
Review fixes
1 parent 106904e commit f351043

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

instrumentation/internal/internal-class-loader/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/internal/classloader/BootDelegationInstrumentation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public class BootDelegationInstrumentation implements TypeInstrumentation {
4747
public ElementMatcher<TypeDescription> typeMatcher() {
4848
// just an optimization to exclude common class loaders that are known to delegate to the
4949
// bootstrap loader (or happen to _be_ the bootstrap loader)
50+
// The AgentClassLoader and InstrumentationModuleClassloaders are required to be excluded
51+
// for the instrumentation to work properly. loadClass on those is invoked during Advice
52+
// bootstrapping
53+
// which therefore would cause an infinite recursion
5054
return not(namedOneOf(
5155
"java.lang.ClassLoader",
5256
"com.ibm.oti.vm.BootstrapClassLoader",

instrumentation/internal/internal-class-loader/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/internal/classloader/DefineClassInstrumentation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ public static DefineClassContext onEnter(
5252
classLoader, className, classBytes, offset, length);
5353
}
5454

55-
// TODO: the ToReturened does nothing except for signaling the AdviceTransformer that it must
55+
// TODO: the ToReturned does nothing except for signaling the AdviceTransformer that it must
5656
// not touch this advice
5757
// this is done to ensure that ClassLoaderInstrumentationModule.loadAdviceClassesEagerly works
5858
// correctly
59-
// we can therfore remove it, as soon as the AdviceTransformer is not applied anymore
59+
// we can therefore remove it, as soon as the AdviceTransformer is not applied anymore
6060
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
6161
@Advice.AssignReturned.ToReturned
6262
public static Class<?> onExit(
@@ -76,11 +76,11 @@ public static DefineClassContext onEnter(
7676
return DefineClassHelper.beforeDefineClass(classLoader, className, classBytes);
7777
}
7878

79-
// TODO: the ToReturened does nothing except for signaling the AdviceTransformer that it must
79+
// TODO: the ToReturned does nothing except for signaling the AdviceTransformer that it must
8080
// not touch this advice
8181
// this is done to ensure that ClassLoaderInstrumentationModule.loadAdviceClassesEagerly works
8282
// correctly
83-
// we can therfore remove it, as soon as the AdviceTransformer is not applied anymore
83+
// we can therefore remove it, as soon as the AdviceTransformer is not applied anymore
8484
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
8585
@Advice.AssignReturned.ToReturned
8686
public static Class<?> onExit(

javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentClassLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ private static int getJavaVersion() {
146146
public Class<?> loadClass(String name) throws ClassNotFoundException {
147147
// We explicitly override loadClass from ClassLoader to ensure
148148
// that loadClass is properly excluded from our internal ClassLoader Instrumentations
149+
// (e.g. LoadInjectedClassInstrumentation, BooDelegationInstrumentation)
149150
// Otherwise this will cause recursion in invokedynamic linkage
150151
return loadClass(name, false);
151152
}

javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/indy/InstrumentationModuleClassLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public void applyTransformer(AgentBuilder.Transformer transformer) {}
221221
public Class<?> loadClass(String name) throws ClassNotFoundException {
222222
// We explicitly override loadClass from ClassLoader to ensure
223223
// that loadClass is properly excluded from our internal ClassLoader Instrumentations
224+
// (e.g. LoadInjectedClassInstrumentation, BooDelegationInstrumentation)
224225
// Otherwise this will cause recursion in invokedynamic linkage
225226
return loadClass(name, false);
226227
}

0 commit comments

Comments
 (0)