Comments (3)
In advice, you can skip the original code. Look at: OnMethodEnter(skipOn = ...)
.
A common way of doing this is:
class MyAdvice {
@Advice.OnMethodEnter(skipOn = Advice.NonDefaultValue.class)
static boolean onEnter(@Advice.Local Object returnValue) {
if (...) {
// do alternative
returnValue = ...;
return true;
} else {
return false;
}
}
@Advice.OnMethodExit
static void exit(@Advice.Enter boolean skipped, @Advice.Local Object returnValue, @Advice.Return Object returnedValue) {
if (skipped) {
returnedValue = returnValue;
}
}
}
from byte-buddy.
Advice.NonDefaultValue.class
This worked. Thanks @raphw. I do have a question about what exactly does this mean ?
skipOn = Advice.NonDefaultValue.class
from byte-buddy.
The default value is null, false or 0. It means that if this default value is returned, the method is not skipped, in this case. It's also explained in the javadoc.
from byte-buddy.
Related Issues (20)
- Strange interaction with method implementations for methods from composite interfaces HOT 1
- Can I replace the new byte[] in the onTransformation method? HOT 1
- I want to use bytebuddy to advice java.time.LocalDateTime HOT 3
- BUG: instrumentation error HOT 3
- No classes have been predefined during the image build to load from bytecodes at runtime HOT 8
- Verify Error on Byte Buddy generated class HOT 1
- Question: copy class hierarchy in an environment without Java Agent HOT 1
- Can 'private final method' in 'public final class' be redefined? HOT 4
- Method matchers works by chance HOT 2
- Why does ClassNotFoundException appear in Interceptor when running in SpringBoot? HOT 1
- Compilation error after adding lombok to classpath HOT 1
- why is the byte-buudy AgentBuilder source code so long ? HOT 2
- Invalid module descriptor of byte-buddy `jar` when `JAVA_HOME` is set to version 21 HOT 16
- matched class wasn't transformered and the issue appears just twice, and i didn't reproducing the issue HOT 10
- Fail to read property due to `IllegalArgumentException` when using it on withX methods HOT 4
- Improve diagnostics/troubleshooting features for agent installation HOT 1
- ByteBudy agent required by Mockito fails to install on GraalVM HOT 1
- Error when trying to modify the response of a method assigned to a public static final config variable HOT 9
- How to change the loaded class in javaagent? HOT 5
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.