Skip to content

Commit

Permalink
fix format issue during merging with master
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Zhou committed Apr 3, 2024
1 parent f546ee7 commit c7a1ef9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 47 deletions.
10 changes: 5 additions & 5 deletions subprojects/parseq-lambda-names/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ configurations {
}

dependencies {
shadow group: 'net.bytebuddy', name: 'byte-buddy-agent', version: '1.14.5'
shadow group: 'net.bytebuddy', name: 'byte-buddy-dep', version: '1.14.5'
shadow group: 'org.ow2.asm', name: 'asm-tree', version: '9.5'
shadow group: 'org.ow2.asm', name: 'asm', version: '9.5'
shadow group: 'org.ow2.asm', name: 'asm-analysis', version: '9.5'
shadow group: 'net.bytebuddy', name: 'byte-buddy-agent', version: '1.14.13'
shadow group: 'net.bytebuddy', name: 'byte-buddy-dep', version: '1.14.13'
shadow group: 'org.ow2.asm', name: 'asm-tree', version: '9.6'
shadow group: 'org.ow2.asm', name: 'asm', version: '9.6'
shadow group: 'org.ow2.asm', name: 'asm-analysis', version: '9.6'
testCompile group: 'org.testng', name: 'testng', version: '7.3.0'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,47 +102,45 @@ static void onExit(@Advice.Argument(0) Class<?> hostClass, @Advice.Argument(1) b
} catch (ClassNotFoundException e) {
}

if (isJdkUnsafe) {
// Code path that supports OpenJDK Java 11 and up

/*
* Inject AnalyzerAdvice to boot ClassLoader.
* It has to be reachable from jdk.internal.misc.Unsafe.
*/
ClassInjector.UsingUnsafe.ofBootLoader()
.inject(Collections.singletonMap(
new TypeDescription.ForLoadedType(AnalyzerAdvice.class),
ClassFileLocator.ForClassLoader.read(AnalyzerAdvice.class)
)
);

/*
* Inject the analyze(byte[] byteCode, ClassLoader loader) method from this ClassLoader
* to the AnalyzerAdvice class from boot ClassLoader.
*/
Class<?> injectedInt = ClassLoader.getSystemClassLoader().getParent().loadClass(AnalyzerAdvice.class.getName());
injectedInt.getField("_method").set(null, Analyzer.class.getDeclaredMethod("analyze", byte[].class, ClassLoader.class));

JavaModule module = JavaModule.ofType(injectedInt);

new AgentBuilder.Default()
.disableClassFormatChanges()
.ignore(noneOf(unsafe))
.with(AgentBuilder.InitializationStrategy.NoOp.INSTANCE)
.with(AgentBuilder.RedefinitionStrategy.REDEFINITION)
.with(AgentBuilder.TypeStrategy.Default.REDEFINE)
.with(AgentBuilder.InjectionStrategy.UsingUnsafe.INSTANCE)
.assureReadEdgeTo(inst, module)
.type(is(unsafe))
.transform(new AgentBuilder.Transformer() {
@Override
public Builder<?> transform(Builder<?> builder, TypeDescription typeDescription,
ClassLoader classLoader, JavaModule module, ProtectionDomain protectionDomain) {
return builder.visit(Advice.to(AnalyzerAdvice.class).on(ElementMatchers.named("defineAnonymousClass")));
}
}).installOnByteBuddyAgent();
} else {
// Code path that supports Oracle Java 8 and 9
if (isJdkUnsafe) {
// Code path that supports OpenJDK Java 11 and up

/*
* Inject AnalyzerAdvice to boot ClassLoader.
* It has to be reachable from jdk.internal.misc.Unsafe.
*/
ClassInjector.UsingUnsafe.ofBootLoader()
.inject(Collections.singletonMap(new TypeDescription.ForLoadedType(AnalyzerAdvice.class),
ClassFileLocator.ForClassLoader.read(AnalyzerAdvice.class)));

/*
* Inject the analyze(byte[] byteCode, ClassLoader loader) method from this ClassLoader
* to the AnalyzerAdvice class from boot ClassLoader.
*/
Class<?> injectedInt = ClassLoader.getSystemClassLoader().getParent().loadClass(AnalyzerAdvice.class.getName());
injectedInt.getField("_method")
.set(null, Analyzer.class.getDeclaredMethod("analyze", byte[].class, ClassLoader.class));

JavaModule module = JavaModule.ofType(injectedInt);

new AgentBuilder.Default().disableClassFormatChanges()
.ignore(noneOf(unsafe))
.with(AgentBuilder.InitializationStrategy.NoOp.INSTANCE)
.with(AgentBuilder.RedefinitionStrategy.REDEFINITION)
.with(AgentBuilder.TypeStrategy.Default.REDEFINE)
.with(AgentBuilder.InjectionStrategy.UsingUnsafe.INSTANCE)
.assureReadEdgeTo(inst, module)
.type(is(unsafe))
.transform(new AgentBuilder.Transformer() {
@Override
public Builder<?> transform(Builder<?> builder, TypeDescription typeDescription, ClassLoader classLoader,
JavaModule module, ProtectionDomain protectionDomain) {
return builder.visit(Advice.to(AnalyzerAdvice.class).on(ElementMatchers.named("defineAnonymousClass")));
}
})
.installOnByteBuddyAgent();
} else {
// Code path that supports Oracle Java 8 and 9
inst.addTransformer(new Analyzer());
}
} catch (Exception e) {
Expand Down Expand Up @@ -273,4 +271,4 @@ public static void analyze(byte[] byteCode, ClassLoader loader) {
EXECUTOR_SERVICE.submit(AnalyzerRunnable.of(byteCode, loader, e));
}
}
}
}

0 comments on commit c7a1ef9

Please sign in to comment.