You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/08/12 23:52:48 UTC
[groovy] 01/01: Attach annotations to internal method `$getLookup`
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch danielsun/mark-generated
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit ac55b0b54e63f1d4ab5c7af7f79fc902967febf3
Author: Daniel Sun <su...@apache.org>
AuthorDate: Fri Aug 13 07:52:34 2021 +0800
Attach annotations to internal method `$getLookup`
---
src/main/java/org/codehaus/groovy/classgen/Verifier.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/Verifier.java b/src/main/java/org/codehaus/groovy/classgen/Verifier.java
index 5425c24..809d7f2 100644
--- a/src/main/java/org/codehaus/groovy/classgen/Verifier.java
+++ b/src/main/java/org/codehaus/groovy/classgen/Verifier.java
@@ -416,7 +416,7 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
modifiers |= ACC_STATIC;
}
- node.addSyntheticMethod(
+ MethodNode getLookupMethodNode = node.addSyntheticMethod(
"$getLookup",
modifiers,
ClassHelper.make(MethodHandles.Lookup.class),
@@ -430,6 +430,11 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
}
})
);
+ boolean shouldAnnotate = classNode.getModule().getContext() != null;
+ if (shouldAnnotate) {
+ getLookupMethodNode.addAnnotation(new AnnotationNode(ClassHelper.make(GENERATED_ANNOTATION)));
+ getLookupMethodNode.addAnnotation(new AnnotationNode(ClassHelper.make(INTERNAL_ANNOTATION)));
+ }
}
private void addStaticMetaClassField(final ClassNode node, final String classInternalName) {