Minor improvement in the writing-instrumentation-module.md doc (#2871)

This commit is contained in:
Mateusz Rzeszutek 2021-04-27 22:04:18 +02:00 committed by GitHub
parent 77f8be8add
commit 169f99554d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -195,9 +195,12 @@ Advice classes are not really "classes", they're raw pieces of code that will be
the instrumented library class files. You should not treat them as ordinary, plain Java classes -
unfortunately many standard practices do not apply to them:
* if they're inner classes they MUST be static;
* they MUST only contain static methods;
* they MUST NOT contain any state (fields) whatsoever - static constants included! Only the advice
methods' content is copied to the instrumented code, the constants are not;
* inner advice classes defined in an `InstrumentationModule` or a `TypeInstrumentation` MUST NOT use
anything from the outer class (loggers, constants, etc);
* reusing code by extracting a common method and/or parent class will most likely not work properly:
instead you can create additional helper classes to store any reusable code;
* they SHOULD NOT contain any methods other than `@Advice`-annotated method.