Skip to content

Commit

Permalink
Merge pull request #30680 from geoand/generated-methods-synthetic
Browse files Browse the repository at this point in the history
Mark methods generatred by ASM transformations as synthetic
  • Loading branch information
mkouba authored Jan 30, 2023
2 parents d52544c + 39959c0 commit 70112c6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ public ClassVisitor apply(String className, ClassVisitor classVisitor) {
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
super.visit(version, access, name, signature, superName, interfaces);
MethodVisitor ctor = visitMethod(Modifier.PUBLIC, "<init>", "()V", null,
MethodVisitor ctor = visitMethod(Modifier.PUBLIC | Opcodes.ACC_SYNTHETIC, "<init>", "()V",
null,
null);
ctor.visitCode();
ctor.visitVarInsn(Opcodes.ALOAD, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ public void visit(int version, int access, String name, String signature,
String superName,
String[] interfaces) {
super.visit(version, access, name, signature, superName, interfaces);
MethodVisitor mv = visitMethod(Modifier.PUBLIC, Methods.INIT, "()V", null,
MethodVisitor mv = visitMethod(Modifier.PUBLIC | Opcodes.ACC_SYNTHETIC, Methods.INIT, "()V", null,
null);
mv.visitCode();
mv.visitVarInsn(Opcodes.ALOAD, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public FieldVisitor visitField(int access, String name, String descriptor, Strin

@Override
public void visitEnd() {
MethodVisitor injectMethod = visitMethod(Opcodes.ACC_PUBLIC, INJECT_METHOD_NAME, INJECT_METHOD_DESCRIPTOR, null,
MethodVisitor injectMethod = visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, INJECT_METHOD_NAME,
INJECT_METHOD_DESCRIPTOR, null,
null);
injectMethod.visitParameter("ctx", 0 /* modifiers */);
injectMethod.visitCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ public void visitEnd() {
public void visitEnd() {
// FIXME: handle setters
// FIXME: handle multi fields
MethodVisitor injectMethod = visitMethod(Opcodes.ACC_PUBLIC, INJECT_METHOD_NAME, INJECT_METHOD_DESCRIPTOR, null,
MethodVisitor injectMethod = visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, INJECT_METHOD_NAME,
INJECT_METHOD_DESCRIPTOR, null,
null);
injectMethod.visitParameter("ctx", 0 /* modifiers */);
injectMethod.visitCode();
Expand Down Expand Up @@ -333,7 +334,7 @@ public void visitEnd() {

if (!seenClassInit && !partTypes.isEmpty()) {
// add a class init method for the part types special fields
MethodVisitor mv = super.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null);
MethodVisitor mv = super.visitMethod(Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC, "<clinit>", "()V", null, null);
for (Entry<FieldInfo, ServerIndexedParameter> entry : partTypes.entrySet()) {
generateMultipartFormStaticInit(mv, entry.getKey(), entry.getValue());
}
Expand Down

0 comments on commit 70112c6

Please sign in to comment.