Index: src/main/org/codehaus/groovy/classgen/Verifier.java =================================================================== --- src/main/org/codehaus/groovy/classgen/Verifier.java (revision 18216) +++ src/main/org/codehaus/groovy/classgen/Verifier.java (working copy) @@ -224,9 +224,9 @@ if (!node.hasMethod("getMetaClass", Parameter.EMPTY_ARRAY)) { metaClassField = setMetaClassFieldIfNotExists(node, metaClassField); - node.addSyntheticMethod( + addMethod(node,!Modifier.isAbstract(node.getModifiers()), "getMetaClass", - ACC_PUBLIC | ACC_SYNTHETIC, + ACC_PUBLIC, ClassHelper.METACLASS_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, @@ -275,7 +275,7 @@ setMetaClassCode = new BytecodeSequence(list); } - node.addSyntheticMethod( + addMethod(node,!Modifier.isAbstract(node.getModifiers()), "setMetaClass", ACC_PUBLIC, ClassHelper.VOID_TYPE, @@ -291,7 +291,8 @@ VariableScope blockScope = new VariableScope(); blockScope.putReferencedLocalVariable(vMethods); blockScope.putReferencedLocalVariable(vArguments); - node.addSyntheticMethod( + + addMethod(node,!Modifier.isAbstract(node.getModifiers()), "invokeMethod", ACC_PUBLIC, ClassHelper.OBJECT_TYPE, INVOKE_METHOD_PARAMS, @@ -311,7 +312,7 @@ } if (!node.hasMethod("getProperty", GET_PROPERTY_PARAMS)) { - node.addSyntheticMethod( + addMethod(node,!Modifier.isAbstract(node.getModifiers()), "getProperty", ACC_PUBLIC, ClassHelper.OBJECT_TYPE, @@ -331,7 +332,7 @@ } if (!node.hasMethod("setProperty", SET_PROPERTY_PARAMS)) { - node.addSyntheticMethod( + addMethod(node,!Modifier.isAbstract(node.getModifiers()), "setProperty", ACC_PUBLIC, ClassHelper.VOID_TYPE, @@ -351,6 +352,20 @@ } } + /** + * Helper method to add a new method to a ClassNode. Depending on the shouldBeSynthetic flag the + * call will either be made to ClassNode.addSyntheticMethod() or ClassNode.addMethod(). If a non-synthetic method + * is to be added the ACC_SYNTHETIC modifier is removed if it has been accidentally supplied. + */ + private void addMethod(ClassNode node, boolean shouldBeSynthetic, String name, int modifiers, ClassNode returnType, Parameter[] parameters, + ClassNode[] exceptions, Statement code) { + if (shouldBeSynthetic) { + node.addSyntheticMethod(name,modifiers,returnType,parameters,exceptions,code); + } else { + node.addMethod(name,modifiers&~ACC_SYNTHETIC,returnType,parameters,exceptions,code); + } + } + protected void addTimeStamp(ClassNode node) { FieldNode timeTagField = new FieldNode( Verifier.__TIMESTAMP,