Comments (12)
Did you take a thread dump? Maybe you intercept a method and invoke the proxy again? Or you lock the same object from different threads.
from byte-buddy.
Did you take a thread dump? Maybe you intercept a method and invoke the proxy again? Or you lock the same object from different threads.
Perhaps so, I tried to configure the class that was not enhanced, and the result was successful. However, this is not safe. I tried the following code again, hoping to block the classes that have already been enhanced by cglib, but it still hasn't been blocked
why?
private static class InnerTransformer implements AgentBuilder.Transformer {
@OverRide
public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription,
ClassLoader classLoader, JavaModule module, ProtectionDomain protectionDomain) {
return builder.visit(Advice.to(MethodServiceAdvice.class)
.on(ElementMatchers.not(ElementMatchers.isConstructor())
.and(ElementMatchers
.noneOf(ElementMatchers.hasSuperType(ElementMatchers.named("StaticApplicationContext"))))
.and(ElementMatchers.not(ElementMatchers.isTypeInitializer()))
.and(ElementMatchers.not(ElementMatchers.isSetter()))
.and(ElementMatchers.not(ElementMatchers.isGetter()))
.and(ElementMatchers.not(ElementMatchers.nameStartsWith("net.bytebuddy.generated")))
.and(ElementMatchers.not(ElementMatchers.nameContains("EnhancerBySpringCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("$$")))
.and(ElementMatchers.not(ElementMatchers.nameContains("FastClassByCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("MethodInterceptor")))));
}
}
from byte-buddy.
take a thread dump
I tried to take a thread dump, but the PID of tomcat kept changing, so I couldn't get it
from byte-buddy.
You can use jps to find it.
from byte-buddy.
You can use jps to find it.
I used JPS, but you can see that the displayed PID keeps changing
![image](https://private-user-images.githubusercontent.com/90837835/343998995-35fdd9e4-af2d-4a1b-b7ac-82358b721537.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwMjkzMjgsIm5iZiI6MTcyNDAyOTAyOCwicGF0aCI6Ii85MDgzNzgzNS8zNDM5OTg5OTUtMzVmZGQ5ZTQtYWYyZC00YTFiLWI3YWMtODIzNThiNzIxNTM3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE5VDAwNTcwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNkNzU0NzE3NGYyYzViZWM0ZDlhNTdlZGY4NTBiYTcxOTU0ZGUyODEyYjg1ODAwNTk2Nzg5MzRjZDgyZTA3ZTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.iKXTQxj_joDJmPIOfyy7C3r-OtC2K9NK1MnN6j2MJvk)
from byte-buddy.
You can use jps to find it.
I used JPS, but you can see that the displayed PID keeps changing![]()
Can you take a look at why the filtering above doesn't work
private static class InnerTransformer implements AgentBuilder.Transformer {
@OverRide
public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription,
ClassLoader classLoader, JavaModule module, ProtectionDomain protectionDomain) {
return builder.visit(Advice.to(MethodServiceAdvice.class)
.on(ElementMatchers.not(ElementMatchers.isConstructor())
.and(ElementMatchers
.noneOf(ElementMatchers.hasSuperType(ElementMatchers.named("StaticApplicationContext"))))
.and(ElementMatchers.not(ElementMatchers.isTypeInitializer()))
.and(ElementMatchers.not(ElementMatchers.isSetter()))
.and(ElementMatchers.not(ElementMatchers.isGetter()))
.and(ElementMatchers.not(ElementMatchers.nameStartsWith("net.bytebuddy.generated")))
.and(ElementMatchers.not(ElementMatchers.nameContains("EnhancerBySpringCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("$$")))
.and(ElementMatchers.not(ElementMatchers.nameContains("FastClassByCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("MethodInterceptor")))));
}
}
from byte-buddy.
I used JPS, but you can see that the displayed PID keeps changing
from byte-buddy.
Are those processes short lived? If so, it's hard to hit a target. Maybe you should change JAVA_TOOL_OPTIONS
to add your agent when any Java process is starting up?
from byte-buddy.
Can you take a look at why the filtering above doesn't work
private static class InnerTransformer implements AgentBuilder.Transformer {
@OverRide
public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription,
ClassLoader classLoader, JavaModule module, ProtectionDomain protectionDomain) {
return builder.visit(Advice.to(MethodServiceAdvice.class)
.on(ElementMatchers.not(ElementMatchers.isConstructor())
.and(ElementMatchers
.noneOf(ElementMatchers.hasSuperType(ElementMatchers.named("StaticApplicationContext"))))
.and(ElementMatchers.not(ElementMatchers.isTypeInitializer()))
.and(ElementMatchers.not(ElementMatchers.isSetter()))
.and(ElementMatchers.not(ElementMatchers.isGetter()))
.and(ElementMatchers.not(ElementMatchers.nameStartsWith("net.bytebuddy.generated")))
.and(ElementMatchers.not(ElementMatchers.nameContains("EnhancerBySpringCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("$$")))
.and(ElementMatchers.not(ElementMatchers.nameContains("FastClassByCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("MethodInterceptor")))));
}
}
from byte-buddy.
What filtering do you mean?
from byte-buddy.
What I mean is that based on the previous investigation, it seems that the classes enhanced by cglib have been enhanced again by bytebuddy.
Therefore, I want to use the ElementMatchers provided by bytebuddy to filter all the classes enhanced by cglib,
which is this code, but it still cannot be successfully filtered
private static class InnerTransformer implements AgentBuilder.Transformer {
@OverRide
public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription,
ClassLoader classLoader, JavaModule module, ProtectionDomain protectionDomain) {
return builder.visit(Advice.to(MethodServiceAdvice.class)
.on(ElementMatchers.not(ElementMatchers.isConstructor())
.and(ElementMatchers
.noneOf(ElementMatchers.hasSuperType(ElementMatchers.named("StaticApplicationContext"))))
.and(ElementMatchers.not(ElementMatchers.isTypeInitializer()))
.and(ElementMatchers.not(ElementMatchers.isSetter()))
.and(ElementMatchers.not(ElementMatchers.isGetter()))
.and(ElementMatchers.not(ElementMatchers.nameStartsWith("net.bytebuddy.generated")))
.and(ElementMatchers.not(ElementMatchers.nameContains("EnhancerBySpringCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("$$")))
.and(ElementMatchers.not(ElementMatchers.nameContains("FastClassByCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("MethodInterceptor")))));
}
}
from byte-buddy.
You combine all these matchers. You likely want to use .or
which implies that any condition holds.
from byte-buddy.
Related Issues (20)
- AndroidClassLoadingStrategy Injecting problem in Android SDK 33 HOT 3
- [maven plugin] transform-extended does not include dependency classes HOT 14
- latest guava cause [ unexpected type reference on method: 16 ] HOT 5
- `MemberSubstitution` can't replace instructions within synthetic methods. HOT 2
- IllegalArgumentException for Kotlin bytecode with erased type argument HOT 9
- Can byte-buddy modify bytecode in parallel? HOT 4
- Java 17 reflection changes
- A lazy `TypePool` will change with type resolution and thus deviate from its initial configuration. HOT 2
- JDK 23 Valhalla-EA: IllegalState Illegal modifiers 33 for class HOT 2
- Multiple transformation issue with JMH benchmarks HOT 1
- [question] How can replace field access with another class? HOT 2
- Eclipse project compilation error using mockito and byte-buddy HOT 5
- Runtime attachment causing VerifyError during class transformation HOT 8
- not able to intercept java.lang package HOT 9
- Questions about alternatives to the LocalVariablesSorter class obsoletization HOT 1
- How to create a class with updated private field using ByteBuddy? HOT 2
- Byte buddy access to package protected class HOT 4
- mockito-android:5.12.0 cannot mock class HOT 1
- How to invoke the method of injecting objects into a class? HOT 2
- [Question] Why would a new field var2 be added after replace field access with method? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from byte-buddy.