-
-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Q] How to remove/replace existing annotation #354
Comments
It is possible but a bit tricky, there is not yet a good API for such transformations. The problem is that Byte Buddy cannot generally know if a value is represented as a default value or if it is explicitly defined but to this default value. It sounds irrellevant but as a matter of fact, it does matter for (too manny) applications. I hopefully can add better support for this in the future. For now, using ASM is the easiest way of getting this done. |
@raphw did you find a time to add API for removing annotation? |
Not yet, unfortunately. I use this issue to track the progress. With modules and the sun.misc.Unsafe cleanup, I did not had much time for features recently. |
Hi, I am new to byte buddy, and I am trying to modify the value of an annotation in an agent.
do you mean that it's possible to do this when transforming a class in an agent? I couldn't find any example of a transformer for that case. What I am trying to do is to transform:
and change the value of
The agent is correctly setup and processes the class:
But I don't know what to do in the transformer, since annotateType is creating a duplicate like mentioned before:
Thanks for your help! |
As mentioned, it is not currently possible to remove the existing annotation. This is not currently solved fully satisfactory in Byte Buddy such that you have to reapply all annotations what means filtering out the first annotation using an AsmClassVisitorWrapper where the second one is picked up correctly. |
Do you have an example of a visitor which would remove that annotation (or all annotations?). At least for some use case, where you can rebuild the whole annotation or set of annotations, that would work. |
Basically, you need to implement a |
Closing this in favor of #917 |
Is there a way to replace (or remove so it can be re-added) an existing annotation from a type?
Let's say the input is:
and I want
How would I do that?
A simple
annotateType
makes the annotation appear twice.Thanks!
The text was updated successfully, but these errors were encountered: