Annotation Interface DoNotRename


@Target({TYPE,FIELD,METHOD}) @Retention(RUNTIME) public @interface DoNotRename
Annotation that prevents obfuscation tools from renaming the annotated element.

When code obfuscation is applied (such as ProGuard or similar tools), elements marked with @DoNotRename will retain their original names. This is useful for:

  • Classes that are loaded by reflection
  • Methods called from external code
  • Fields accessed via serialization or reflection
  • API endpoints that must maintain consistent naming

This annotation can be applied to types, fields, and methods:


 @DoNotRename
 public class MyApiClass {
     @DoNotRename
     private String importantField;

     @DoNotRename
     public void reflectedMethod() {
         // This method is called via reflection
     }
 }