question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to remove/replace existing annotations?

See original GitHub issue

Thank you for this wonderful library. However, I am stuck at one point. I am able to add annotations to a field/method, but not able to replace or remove existing annotation.

I have the following requirement, on a method,

@OneToOne (fetch = FetchType.LAZY) // I want to remove / replace annotation values 
public Employee getEmployee()

I would like to,

  1. Remove the existing annotation @OneToOne (fetch = FetchType.LAZY)
  2. Replace the existing annotation’s values with @OneToOne (fetch = FetchType.EAGER)

I am using the bytebuddy maven plugin, using the DynamicType.Builder to visit the method to add new annotation using MemberAttributeExtension.ForMethod().annotateMethod(), but not sure how to remove or replace existing annotations.

I tried using MemberSubstitution, but did not get that to work for removing / replacing annotations

For your help I will be immensely grateful.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
raphwcommented, Sep 1, 2020

Thanks, glad you like it. Member removal is unfortunately not supported overly well. You’d need to register a AsmClassVisitorWrapper and override the visitAnnotation method to return null if such an annotation is discovered.

0reactions
chaudharydeepakcommented, Dec 25, 2021

thank you @raphw. I was able to make some progress with your inputs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AspectJ: How to replace an existing annotation - Stack Overflow
Using AspectJ, how do you replace an existing annotation? I have the following code declare @method : @Test * *(..) : @Test(timeout ...
Read more >
How To Replace Annotations with Cards and End Screens
Compatibility with desktop, mobile, and other viewing platforms made cards and end screens clear winners over annotations.
Read more >
Removing annotations
Right-click on the annotation icon in the document, and click Remove Annotation. Save the changes to a new document by clicking the menu...
Read more >
Find and Replace Annotation - SOLIDWORKS Utilities
This utility is most useful when multiple annotations need to be corrected or changed at one time. This can be a part, assembly,...
Read more >
Find and Replace Annotation - 2019 - SolidWorks Web Help
Finding and Replacing Annotations · For Find What, type the text to find or select it from the drop-down list if you previously...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found