Test indy instrumentation with security manager#18634
Merged
Merged
Conversation
trask
approved these changes
May 9, 2026
| return java.security.AccessController.doPrivileged( | ||
| (PrivilegedAction<CallSite>) | ||
| () -> internalBootstrap(lookup, adviceMethodName, adviceMethodType, args)); | ||
| new PrivilegedAction<CallSite>() { |
Member
There was a problem hiding this comment.
Suggested change
| new PrivilegedAction<CallSite>() { | |
| // must be an anonymous class, not a lambda: a lambda here would trigger | |
| // LambdaMetafactory.spinInnerClass -> defineClass -> re-entrant indy bootstrap | |
| new PrivilegedAction<CallSite>() { |
SylvainJuge
approved these changes
May 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds smoke-test coverage for running the Javaagent with SecurityManager enabled and invokedynamic (“indy”) instrumentation turned on, and adjusts indy/bootstrap + class-define handling to avoid problematic re-entrancy and unnecessary work.
Changes:
- Add a new
SecurityManagerIndySmokeTestvariant that enablesOTEL_JAVAAGENT_EXPERIMENTAL_INDY=true. - Strengthen
SecurityManagerSmokeTestassertions to fail if logs contain stack-trace frames. - Avoid lambda usage in
IndyBootstrap’sdoPrivilegedpath and introduce an ignored-classloader predicate to skip supertype resolution for ignored class loaders.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| smoke-tests/src/test/java/io/opentelemetry/smoketest/SecurityManagerSmokeTest.java | Captures container output and asserts the run doesn’t emit stack traces. |
| smoke-tests/src/test/java/io/opentelemetry/smoketest/SecurityManagerIndySmokeTest.java | New smoke test enabling indy mode under the SecurityManager image. |
| javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/indy/IndyBootstrap.java | Replaces a doPrivileged lambda with an anonymous class to avoid nested indy/lambda bootstrapping recursion. |
| javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/DefineClassHandler.java | Adds an ignored-classloader predicate to skip define-class supertype loading work for ignored loaders. |
| javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentInstaller.java | Wires ignored classloader configuration into DefineClassHandler and reuses the built ignored-classloader trie. |
Comment on lines
+22
to
+28
| private static Predicate<ClassLoader> ignoredClassLoaders = (classLoader) -> false; | ||
|
|
||
| private DefineClassHandler() {} | ||
|
|
||
| public static void setIgnoredClassLoadersPredicate(Predicate<ClassLoader> predicate) { | ||
| ignoredClassLoaders = predicate; | ||
| } |
Comment on lines
+40
to
+43
| // skip ignore class loaders, class is not going to be instrumented anyway | ||
| if (ignoredClassLoaders.test(classLoader)) { | ||
| return null; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #16821