You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2019/11/04 20:38:43 UTC

[groovy] branch master updated: sync with groovy-eclipse

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new e8f8f3d  sync with groovy-eclipse
e8f8f3d is described below

commit e8f8f3dbbde12a9701ca236d1ba9c9f5e377d901
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Nov 4 14:37:54 2019 -0600

    sync with groovy-eclipse
---
 .../groovy/classgen/AsmClassGenerator.java         | 12 ++--
 .../org/codehaus/groovy/classgen/EnumVisitor.java  |  2 -
 .../org/codehaus/groovy/classgen/Verifier.java     |  7 +--
 .../groovy/classgen/asm/BytecodeHelper.java        |  2 +-
 .../groovy/classgen/asm/StatementWriter.java       |  4 +-
 .../codehaus/groovy/control/ProcessingUnit.java    |  7 ++-
 .../codehaus/groovy/control/ResolveVisitor.java    |  8 +--
 .../org/codehaus/groovy/control/SourceUnit.java    |  8 +--
 .../groovy/control/StaticImportVisitor.java        | 25 +++++---
 .../groovy/control/messages/LocatedMessage.java    | 14 ++---
 .../org/codehaus/groovy/tools/GroovyClass.java     | 15 ++---
 .../transform/AnnotationCollectorTransform.java    | 73 +++++++++++-----------
 .../{Groovy7300Bug.groovy => Groovy7300.groovy}    | 73 ++++++++++------------
 13 files changed, 118 insertions(+), 132 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
index 2111e0a..61b6346 100644
--- a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
+++ b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
@@ -155,7 +155,6 @@ public class AsmClassGenerator extends ClassGenerator {
     static final MethodCaller spreadMap = MethodCaller.newStatic(ScriptBytecodeAdapter.class, "spreadMap");
     static final MethodCaller despreadList = MethodCaller.newStatic(ScriptBytecodeAdapter.class, "despreadList");
 
-
     // type conversions
     static final MethodCaller createListMethod = MethodCaller.newStatic(ScriptBytecodeAdapter.class, "createList");
     static final MethodCaller createMapMethod = MethodCaller.newStatic(ScriptBytecodeAdapter.class, "createMap");
@@ -2220,16 +2219,14 @@ public class AsmClassGenerator extends ClassGenerator {
     }
 
     public void onLineNumber(ASTNode statement, String message) {
-        MethodVisitor mv = controller.getMethodVisitor();
+        if (statement == null || statement instanceof BlockStatement) return;
 
-        if (statement==null) return;
+        currentASTNode = statement;
         int line = statement.getLineNumber();
-        this.currentASTNode = statement;
-
-        if (line < 0) return;
-        if (!ASM_DEBUG && line==controller.getLineNumber()) return;
+        if (line < 0 || (!ASM_DEBUG && line == controller.getLineNumber())) return;
 
         controller.setLineNumber(line);
+        MethodVisitor mv = controller.getMethodVisitor();
         if (mv != null) {
             Label l = new Label();
             mv.visitLabel(l);
@@ -2255,5 +2252,4 @@ public class AsmClassGenerator extends ClassGenerator {
         mn.getUnit().addGeneratedInnerClass((InnerClassNode)innerClass);
         return innerClasses.add(innerClass);
     }
-
 }
diff --git a/src/main/java/org/codehaus/groovy/classgen/EnumVisitor.java b/src/main/java/org/codehaus/groovy/classgen/EnumVisitor.java
index 208a34e..86d1a29 100644
--- a/src/main/java/org/codehaus/groovy/classgen/EnumVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/EnumVisitor.java
@@ -72,7 +72,6 @@ public class EnumVisitor extends ClassCodeVisitorSupport {
 
     private final SourceUnit sourceUnit;
 
-
     public EnumVisitor(CompilationUnit cu, SourceUnit su) {
         sourceUnit = su;
     }
@@ -442,5 +441,4 @@ public class EnumVisitor extends ClassCodeVisitorSupport {
         InnerClassNode ic = (InnerClassNode) enumClass;
         return ic.getVariableScope() == null;
     }
-
 }
diff --git a/src/main/java/org/codehaus/groovy/classgen/Verifier.java b/src/main/java/org/codehaus/groovy/classgen/Verifier.java
index bb0402e..204e443 100644
--- a/src/main/java/org/codehaus/groovy/classgen/Verifier.java
+++ b/src/main/java/org/codehaus/groovy/classgen/Verifier.java
@@ -332,13 +332,10 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
     protected void addDefaultConstructor(ClassNode node) {
         if (!node.getDeclaredConstructors().isEmpty()) return;
 
-        BlockStatement empty = new BlockStatement();
-        empty.setSourcePosition(node);
-        ConstructorNode constructor = new ConstructorNode(ACC_PUBLIC, empty);
-        constructor.setSourcePosition(node);
+        ConstructorNode constructor = new ConstructorNode(ACC_PUBLIC, new BlockStatement());
         constructor.setHasNoRealSourcePosition(true);
-        node.addConstructor(constructor);
         markAsGenerated(node, constructor);
+        node.addConstructor(constructor);
     }
 
     private void addStaticMetaClassField(final ClassNode node, final String classInternalName) {
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java b/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
index c50f4bc..7491ca8 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
@@ -234,7 +234,7 @@ public class BytecodeHelper implements Opcodes {
         mv.visitLabel(endLabel);
     }
 
-    /* *
+    /**
      * load a message on the stack and remove it right away. Good for put a mark in the generated bytecode for debugging purpose.
      *
      * @param msg
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
index ad37efb..072d9ed 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/StatementWriter.java
@@ -215,7 +215,9 @@ public class StatementWriter {
 
         // visit increment
         mv.visitLabel(continueLabel);
-        for (int i = condIndex + 1; i < size; i++) {
+        // fix for being on the wrong line when debugging for loop
+        controller.getAcg().onLineNumber(loop, "increment condition");
+        for (int i = condIndex + 1; i < size; i += 1) {
             visitExpressionOfLoopStatement(expressions.get(i));
         }
 
diff --git a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
index 83146cf..af3f7c3 100644
--- a/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/ProcessingUnit.java
@@ -23,6 +23,8 @@ import groovy.lang.GroovyClassLoader;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import static java.util.Objects.requireNonNull;
+
 /**
  * A base class for data structures that can collect messages and errors
  * during processing.
@@ -58,8 +60,7 @@ public abstract class ProcessingUnit {
      * Initializes the ProcessingUnit to the empty state.
      */
     public ProcessingUnit(final CompilerConfiguration configuration, final GroovyClassLoader classLoader, final ErrorCollector errorCollector) {
-        setConfiguration(configuration != null ? configuration : CompilerConfiguration.DEFAULT);
-        setClassLoader(classLoader);
+        setConfiguration(configuration != null ? configuration : CompilerConfiguration.DEFAULT); setClassLoader(classLoader);
         this.errorCollector = errorCollector != null ? errorCollector : new ErrorCollector(getConfiguration());
         configure(getConfiguration());
     }
@@ -82,7 +83,7 @@ public abstract class ProcessingUnit {
      * Sets the CompilerConfiguration for this ProcessingUnit.
      */
     public final void setConfiguration(CompilerConfiguration configuration) {
-        this.configuration = configuration;
+        this.configuration = requireNonNull(configuration);
     }
 
     /**
diff --git a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
index 7b3fbea..5230044 100644
--- a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
@@ -28,9 +28,11 @@ import org.codehaus.groovy.ast.ClassCodeExpressionTransformer;
 import org.codehaus.groovy.ast.ClassHelper;
 import org.codehaus.groovy.ast.ClassNode;
 import org.codehaus.groovy.ast.CompileUnit;
+import org.codehaus.groovy.ast.CompileUnit.ConstructedOuterNestedClassNode;
 import org.codehaus.groovy.ast.DynamicVariable;
 import org.codehaus.groovy.ast.FieldNode;
 import org.codehaus.groovy.ast.GenericsType;
+import org.codehaus.groovy.ast.GenericsType.GenericsTypeName;
 import org.codehaus.groovy.ast.ImportNode;
 import org.codehaus.groovy.ast.InnerClassNode;
 import org.codehaus.groovy.ast.MethodNode;
@@ -84,8 +86,6 @@ import java.util.function.BiConsumer;
 import java.util.function.Predicate;
 
 import static groovy.lang.Tuple.tuple;
-import static org.codehaus.groovy.ast.CompileUnit.ConstructedOuterNestedClassNode;
-import static org.codehaus.groovy.ast.GenericsType.GenericsTypeName;
 import static org.codehaus.groovy.ast.tools.ClosureUtils.getParametersSafe;
 
 /**
@@ -470,7 +470,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
         GenericsType genericsType = genericParameterNames.get(new GenericsTypeName(typeName));
         if (genericsType != null) {
             type.setRedirect(genericsType.getType());
-            type.setGenericsTypes(new GenericsType[] {genericsType});
+            type.setGenericsTypes(new GenericsType[]{genericsType});
             type.setGenericsPlaceHolder(true);
             return true;
         }
@@ -1155,7 +1155,7 @@ public class ResolveVisitor extends ClassCodeExpressionTransformer {
             return be;
         }
         if (left instanceof ClassExpression && be.getOperation().isOneOf(
-                new int[] {Types.ARRAY_EXPRESSION, Types.SYNTH_LIST, Types.SYNTH_MAP})) {
+                new int[]{Types.ARRAY_EXPRESSION, Types.SYNTH_LIST, Types.SYNTH_MAP})) {
             if (be.getRightExpression() instanceof ListExpression) {
                 ListExpression list = (ListExpression) be.getRightExpression();
                 if (list.getExpressions().isEmpty()) {
diff --git a/src/main/java/org/codehaus/groovy/control/SourceUnit.java b/src/main/java/org/codehaus/groovy/control/SourceUnit.java
index 561f42d..f9b320c 100644
--- a/src/main/java/org/codehaus/groovy/control/SourceUnit.java
+++ b/src/main/java/org/codehaus/groovy/control/SourceUnit.java
@@ -122,7 +122,6 @@ public class SourceUnit extends ProcessingUnit {
         return name;
     }
 
-
     /**
      * Returns the Concrete Syntax Tree produced during parse()ing.
      */
@@ -138,7 +137,6 @@ public class SourceUnit extends ProcessingUnit {
         return this.ast;
     }
 
-
     /**
      * Convenience routine, primarily for use by the InteractiveShell,
      * that returns true if parse() failed with an unexpected EOF.
@@ -174,11 +172,9 @@ public class SourceUnit extends ProcessingUnit {
         return token.getType() == antlr.Token.EOF_TYPE;
     }
 
-
     //---------------------------------------------------------------------------
     // FACTORIES
 
-
     /**
      * A convenience routine to create a standalone SourceUnit on a String
      * with defaults for almost everything that is configurable.
@@ -190,7 +186,6 @@ public class SourceUnit extends ProcessingUnit {
         return new SourceUnit(name, source, configuration, null, new ErrorCollector(configuration));
     }
 
-
     /**
      * A convenience routine to create a standalone SourceUnit on a String
      * with defaults for almost everything that is configurable.
@@ -267,7 +262,8 @@ public class SourceUnit extends ProcessingUnit {
         XStreamUtils.serialize(name, ast);
     }
 
-    //---------------------------------------------------------------------------    // SOURCE SAMPLING
+    //---------------------------------------------------------------------------
+    // SOURCE SAMPLING
 
     /**
      * Returns a sampling of the source at the specified line and column,
diff --git a/src/main/java/org/codehaus/groovy/control/StaticImportVisitor.java b/src/main/java/org/codehaus/groovy/control/StaticImportVisitor.java
index 92b4c79..7d2db8d 100644
--- a/src/main/java/org/codehaus/groovy/control/StaticImportVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/StaticImportVisitor.java
@@ -63,7 +63,7 @@ import static org.apache.groovy.util.BeanUtils.capitalize;
 import static org.codehaus.groovy.ast.tools.ClosureUtils.getParametersSafe;
 
 /**
- * Visitor to resolve constants and method calls from static Imports
+ * Visitor to resolve constants and method calls from static imports.
  */
 public class StaticImportVisitor extends ClassCodeExpressionTransformer {
     private ClassNode currentClass;
@@ -237,7 +237,6 @@ public class StaticImportVisitor extends ClassCodeExpressionTransformer {
         if (mce.isImplicitThis() || isExplicitThisOrSuper) {
             if (mce.isImplicitThis()) {
                 if (null == currentClass.tryFindPossibleMethod(mce.getMethodAsString(), args)) {
-
                     Expression ret = findStaticMethodImportFromModule(method, args);
                     if (ret != null) {
                         setSourcePosition(ret, mce);
@@ -462,7 +461,7 @@ public class StaticImportVisitor extends ClassCodeExpressionTransformer {
             if (expression != null) return expression;
             expression = findStaticPropertyAccessorGivenArgs(importNode.getType(), getPropNameForAccessor(importNode.getFieldName()), args);
             if (expression != null) {
-                return new StaticMethodCallExpression(importNode.getType(), importNode.getFieldName(), args);
+                return newStaticMethodCallX(importNode.getType(), importNode.getFieldName(), args);
             }
         }
         // look for one of these:
@@ -478,7 +477,7 @@ public class StaticImportVisitor extends ClassCodeExpressionTransformer {
                 if (expression != null) return expression;
                 expression = findStaticPropertyAccessorGivenArgs(importClass, importMember, args);
                 if (expression != null) {
-                    return new StaticMethodCallExpression(importClass, prefix(name) + capitalize(importMember), args);
+                    return newStaticMethodCallX(importClass, prefix(name) + capitalize(importMember), args);
                 }
             }
         }
@@ -496,7 +495,7 @@ public class StaticImportVisitor extends ClassCodeExpressionTransformer {
                 if (expression != null) return expression;
                 expression = findStaticPropertyAccessorGivenArgs(starImportType, getPropNameForAccessor(name), args);
                 if (expression != null) {
-                    return new StaticMethodCallExpression(starImportType, name, args);
+                    return newStaticMethodCallX(starImportType, name, args);
                 }
             }
         }
@@ -525,9 +524,9 @@ public class StaticImportVisitor extends ClassCodeExpressionTransformer {
         if (accessor == null && hasStaticProperty(staticImportType, propName)) {
             // args will be replaced
             if (inLeftExpression)
-                accessor = new StaticMethodCallExpression(staticImportType, accessorName, ArgumentListExpression.EMPTY_ARGUMENTS);
+                accessor = newStaticMethodCallX(staticImportType, accessorName, ArgumentListExpression.EMPTY_ARGUMENTS);
             else
-                accessor = new PropertyExpression(new ClassExpression(staticImportType), propName);
+                accessor = newStaticPropertyX(staticImportType, propName);
         }
         return accessor;
     }
@@ -543,7 +542,7 @@ public class StaticImportVisitor extends ClassCodeExpressionTransformer {
         if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) {
             FieldNode field = getField(staticImportType, fieldName);
             if (field != null && field.isStatic())
-                return new PropertyExpression(new ClassExpression(staticImportType), fieldName);
+                return newStaticPropertyX(staticImportType, fieldName);
         }
         return null;
     }
@@ -551,12 +550,20 @@ public class StaticImportVisitor extends ClassCodeExpressionTransformer {
     private static Expression findStaticMethod(ClassNode staticImportType, String methodName, Expression args) {
         if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) {
             if (staticImportType.hasPossibleStaticMethod(methodName, args)) {
-                return new StaticMethodCallExpression(staticImportType, methodName, args);
+                return newStaticMethodCallX(staticImportType, methodName, args);
             }
         }
         return null;
     }
 
+    private static PropertyExpression newStaticPropertyX(ClassNode type, String name) {
+        return new PropertyExpression(new ClassExpression(type), name);
+    }
+
+    private static StaticMethodCallExpression newStaticMethodCallX(ClassNode type, String name, Expression args) {
+        return new StaticMethodCallExpression(type, name, args);
+    }
+
     protected SourceUnit getSourceUnit() {
         return source;
     }
diff --git a/src/main/java/org/codehaus/groovy/control/messages/LocatedMessage.java b/src/main/java/org/codehaus/groovy/control/messages/LocatedMessage.java
index 98c0c5f..773777b 100644
--- a/src/main/java/org/codehaus/groovy/control/messages/LocatedMessage.java
+++ b/src/main/java/org/codehaus/groovy/control/messages/LocatedMessage.java
@@ -24,24 +24,27 @@ import org.codehaus.groovy.syntax.CSTNode;
 
 import java.io.PrintWriter;
 
-
 /**
  * A base class for compilation messages.
  */
 public class LocatedMessage extends SimpleMessage {
-    protected CSTNode context;  // The CSTNode that indicates the location to which the message applies
+
+    /** The CSTNode that indicates the location to which the message applies. */
+    private CSTNode context;
 
     public LocatedMessage(String message, CSTNode context, SourceUnit source) {
         super(message, source);
         this.context = context;
     }
 
-
     public LocatedMessage(String message, Object data, CSTNode context, SourceUnit source) {
         super(message, data, source);
         this.context = context;
     }
 
+    public CSTNode getContext() {
+        return context;
+    }
 
     public void write(PrintWriter writer, Janitor janitor) {
         if (owner instanceof SourceUnit) {
@@ -63,9 +66,4 @@ public class LocatedMessage extends SimpleMessage {
             writer.println("");
         }
     }
-
 }
-
-
-
-
diff --git a/src/main/java/org/codehaus/groovy/tools/GroovyClass.java b/src/main/java/org/codehaus/groovy/tools/GroovyClass.java
index 867181d..4dd12dd 100644
--- a/src/main/java/org/codehaus/groovy/tools/GroovyClass.java
+++ b/src/main/java/org/codehaus/groovy/tools/GroovyClass.java
@@ -18,27 +18,22 @@
  */
 package org.codehaus.groovy.tools;
 
-public class GroovyClass
-{
-    public static final GroovyClass[] EMPTY_ARRAY = new GroovyClass[ 0 ];
+public class GroovyClass {
+    public static final GroovyClass[] EMPTY_ARRAY = {};
 
     private final String name;
     private final byte[] bytes;
 
-    public GroovyClass(String name,
-                       byte[] bytes)
-    {
+    public GroovyClass(String name, byte[] bytes) {
         this.name  = name;
         this.bytes = bytes;
     }
 
-    public String getName()
-    {
+    public String getName() {
         return this.name;
     }
 
-    public byte[] getBytes()
-    {
+    public byte[] getBytes() {
         return this.bytes;
     }
 }
diff --git a/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java b/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java
index efe75e7..f41feac 100644
--- a/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java
+++ b/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java
@@ -26,7 +26,6 @@ import org.codehaus.groovy.ast.AnnotationNode;
 import org.codehaus.groovy.ast.ClassHelper;
 import org.codehaus.groovy.ast.ClassNode;
 import org.codehaus.groovy.ast.InnerClassNode;
-import org.codehaus.groovy.ast.MethodNode;
 import org.codehaus.groovy.ast.Parameter;
 import org.codehaus.groovy.ast.expr.AnnotationConstantExpression;
 import org.codehaus.groovy.ast.expr.ArrayExpression;
@@ -43,6 +42,7 @@ import org.codehaus.groovy.syntax.SyntaxException;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -61,7 +61,7 @@ import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
 import static org.objectweb.asm.Opcodes.ACC_STATIC;
 
 /**
- * This class is the base for any annotation alias processor. 
+ * This class is the base for any annotation alias processor.
  * @see AnnotationCollector
  * @see AnnotationCollectorTransform#visit(AnnotationNode, AnnotationNode, AnnotatedNode, SourceUnit)
  */
@@ -86,12 +86,12 @@ public class AnnotationCollectorTransform {
      * modifiers, interfaces and superclasses, as well as adding a static
      * value method returning our serialized version of the data for processing
      * from a pre-compiled state. By doing this the old annotations will be
-     * removed as well 
+     * removed as well
      */
     public static class ClassChanger {
-        
+
         /**
-         * Method to transform the given ClassNode, if it is annotated with 
+         * Method to transform the given ClassNode, if it is annotated with
          * {@link AnnotationCollector}. See class description for what the
          * transformation includes.
          */
@@ -115,7 +115,7 @@ public class AnnotationCollectorTransform {
             ClassNode helper = cn;
             if (legacySerialization) {
                 // force final class, remove interface, annotation, enum and abstract modifiers
-                helper.setModifiers((ACC_FINAL + helper.getModifiers()) & ~(ACC_ENUM | ACC_INTERFACE | ACC_ANNOTATION | ACC_ABSTRACT));
+                helper.setModifiers((ACC_FINAL | helper.getModifiers()) & ~(ACC_ENUM | ACC_INTERFACE | ACC_ANNOTATION | ACC_ABSTRACT));
                 // force Object super class
                 helper.setSuperClass(ClassHelper.OBJECT_TYPE);
                 // force no interfaces implemented
@@ -125,13 +125,12 @@ public class AnnotationCollectorTransform {
                         ACC_PUBLIC | ACC_STATIC | ACC_FINAL, ClassHelper.OBJECT_TYPE.getPlainNodeReference());
                 cn.getModule().addClass(helper);
                 helper.addAnnotation(new AnnotationNode(COMPILESTATIC_CLASSNODE));
-                MethodNode serializeClass = collector.getClassNode().getMethod("serializeClass", Parameter.EMPTY_ARRAY);
                 collector.setMember("serializeClass", new ClassExpression(helper.getPlainNodeReference()));
             }
 
             // add static value():Object[][] method
             List<AnnotationNode> meta = getMeta(cn);
-            List<Expression> outer = new ArrayList<Expression>(meta.size());
+            List<Expression> outer = new ArrayList<>(meta.size());
             for (AnnotationNode an : meta) {
                 Expression serialized = serialize(an);
                 outer.add(serialized);
@@ -139,7 +138,7 @@ public class AnnotationCollectorTransform {
 
             ArrayExpression ae = new ArrayExpression(ClassHelper.OBJECT_TYPE.makeArray(), outer);
             Statement code = new ReturnStatement(ae);
-            helper.addMethod("value", ACC_PUBLIC + ACC_STATIC,
+            helper.addMethod("value", ACC_PUBLIC | ACC_STATIC,
                     ClassHelper.OBJECT_TYPE.makeArray().makeArray(),
                     Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, code);
 
@@ -161,7 +160,7 @@ public class AnnotationCollectorTransform {
                 boolean annotationConstant = false;
                 ListExpression le = (ListExpression) e;
                 List<Expression> list = le.getExpressions();
-                List<Expression> newList = new ArrayList<Expression>(list.size());
+                List<Expression> newList = new ArrayList<>(list.size());
                 for (Expression exp: list) {
                     annotationConstant = annotationConstant || exp instanceof AnnotationConstantExpression;
                     newList.add(serialize(exp));
@@ -174,20 +173,23 @@ public class AnnotationCollectorTransform {
         }
 
         private Expression serialize(AnnotationNode an) {
+            ClassExpression type = new ClassExpression(an.getClassNode());
+            type.setSourcePosition(an.getClassNode());
+
             MapExpression map = new MapExpression();
-            for (String key : an.getMembers().keySet()) {
-                map.addMapEntryExpression(new ConstantExpression(key), serialize(an.getMember(key)));
+            for (Map.Entry<String, Expression> entry : an.getMembers().entrySet()) {
+                Expression key = new ConstantExpression(entry.getKey());
+                Expression val = serialize(entry.getValue());
+                map.addMapEntryExpression(key, val);
             }
-            List<Expression> l = new ArrayList<Expression>(2);
-            l.add(new ClassExpression(an.getClassNode()));
-            l.add(map);
-            return new ArrayExpression(ClassHelper.OBJECT_TYPE, l);
+
+            return new ArrayExpression(ClassHelper.OBJECT_TYPE, Arrays.asList(type, map));
         }
     }
-    
+
     /**
      * Adds a new syntax error to the source unit and then continues.
-     * 
+     *
      * @param message   the message
      * @param node      the node for the error report
      * @param source    the source unit for the error report
@@ -212,7 +214,7 @@ public class AnnotationCollectorTransform {
         if (memberList.isEmpty()) {
             return Collections.emptyList();
         }
-        List<AnnotationNode> ret = new ArrayList<AnnotationNode>();
+        List<AnnotationNode> ret = new ArrayList<>();
         for (Expression e : memberList) {
             AnnotationNode toAdd = new AnnotationNode(e.getType());
             toAdd.setSourcePosition(aliasAnnotationUsage);
@@ -229,7 +231,7 @@ public class AnnotationCollectorTransform {
 
     private static List<AnnotationNode> copy(List<AnnotationNode> orig, AnnotationNode aliasAnnotationUsage) {
         if (orig.isEmpty()) return orig;
-        List<AnnotationNode> ret = new ArrayList<AnnotationNode>(orig.size());
+        List<AnnotationNode> ret = new ArrayList<>(orig.size());
         for (AnnotationNode an : orig) {
             AnnotationNode newAn = new AnnotationNode(an.getClassNode());
             copyMembers(an, newAn);
@@ -244,7 +246,7 @@ public class AnnotationCollectorTransform {
         if (annotations.size() < 2) {
             return Collections.emptyList();
         }
-        List<AnnotationNode> ret = new ArrayList<AnnotationNode>(annotations.size());
+        List<AnnotationNode> ret = new ArrayList<>(annotations.size());
         for (AnnotationNode an : annotations) {
             ClassNode type = an.getClassNode();
             if (type.getName().equals(AnnotationCollector.class.getName()) || "java.lang.annotation".equals(type.getPackageName())) continue;
@@ -299,9 +301,9 @@ public class AnnotationCollectorTransform {
         if (data.length == 0) {
             return Collections.emptyList();
         }
-        List<AnnotationNode> ret = new ArrayList<AnnotationNode>(data.length);
+        List<AnnotationNode> ret = new ArrayList<>(data.length);
         for (Object[] inner : data) {
-            Class<?> anno = (Class) inner[0];
+            Class<?> anno = (Class<?>) inner[0];
             AnnotationNode toAdd = new AnnotationNode(ClassHelper.make(anno));
             ret.add(toAdd);
 
@@ -310,7 +312,7 @@ public class AnnotationCollectorTransform {
             if (member.isEmpty()) {
                 continue;
             }
-            Map<String, Expression> generated = new HashMap<String, Expression>(member.size());
+            Map<String, Expression> generated = new HashMap<>(member.size());
             for (Map.Entry<String, Object> entry : member.entrySet()) {
                 generated.put(entry.getKey(), makeExpression(entry.getValue()));
             }
@@ -321,7 +323,7 @@ public class AnnotationCollectorTransform {
 
     private static Expression makeExpression(Object o) {
         if (o instanceof Class) {
-            return new ClassExpression(ClassHelper.make((Class) o));
+            return new ClassExpression(ClassHelper.make((Class<?>) o));
         }
         //TODO: value as Annotation here!
         if (o instanceof Object[][]) {
@@ -341,11 +343,11 @@ public class AnnotationCollectorTransform {
         }
         return new ConstantExpression(o,true);
     }
-    
+
     /**
-     * Returns a list of AnnotationNodes for the value attribute of the given 
-     * AnnotationNode. 
-     * 
+     * Returns a list of AnnotationNodes for the value attribute of the given
+     * AnnotationNode.
+     *
      * @param collector     the node containing the value member with the list
      * @param source        the source unit for error reporting
      * @return              a list of string constants
@@ -353,25 +355,24 @@ public class AnnotationCollectorTransform {
     protected List<AnnotationNode> getTargetAnnotationList(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, SourceUnit source) {
         List<AnnotationNode> stored     = getStoredTargetList(aliasAnnotationUsage, source);
         List<AnnotationNode> targetList = getTargetListFromValue(collector, aliasAnnotationUsage, source);
-        int size = targetList.size()+stored.size();
+        int size = targetList.size() + stored.size();
         if (size == 0) {
             return Collections.emptyList();
         }
-        List<AnnotationNode> ret = new ArrayList<AnnotationNode>(size);
+        List<AnnotationNode> ret = new ArrayList<>(size);
         ret.addAll(stored);
         ret.addAll(targetList);
-
         return ret;
     }
 
     /**
-     * Implementation method of the alias annotation processor. This method will 
+     * Implementation method of the alias annotation processor. This method will
      * get the list of annotations we aliased from the collector and adds it to
-     * aliasAnnotationUsage. The method will also map all members from 
+     * aliasAnnotationUsage. The method will also map all members from
      * aliasAnnotationUsage to the aliased nodes. Should a member stay unmapped,
      * we will ad an error. Further processing of those members is done by the
      * annotations.
-     * 
+     *
      * @param collector                 reference to the annotation with {@link AnnotationCollector}
      * @param aliasAnnotationUsage      reference to the place of usage of the alias
      * @param aliasAnnotated            reference to the node that has been annotated by the alias
@@ -380,7 +381,7 @@ public class AnnotationCollectorTransform {
      */
     public List<AnnotationNode> visit(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, AnnotatedNode aliasAnnotated, SourceUnit source) {
         List<AnnotationNode> ret =  getTargetAnnotationList(collector, aliasAnnotationUsage, source);
-        Set<String> unusedNames = new HashSet<String>(aliasAnnotationUsage.getMembers().keySet());
+        Set<String> unusedNames = new HashSet<>(aliasAnnotationUsage.getMembers().keySet());
 
         for (AnnotationNode an: ret) {
             for (String name : aliasAnnotationUsage.getMembers().keySet()) {
diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7300Bug.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7300.groovy
similarity index 53%
rename from src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7300Bug.groovy
rename to src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7300.groovy
index 33a3cbd..4cc1598 100644
--- a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7300Bug.groovy
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7300.groovy
@@ -16,64 +16,59 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-
-
-
-
-
-
 package org.codehaus.groovy.classgen.asm.sc.bugs
 
 import groovy.transform.stc.StaticTypeCheckingTestCase
 import org.codehaus.groovy.classgen.asm.sc.StaticCompilationTestSupport
 
-class Groovy7300Bug extends StaticTypeCheckingTestCase implements StaticCompilationTestSupport {
+final class Groovy7300 extends StaticTypeCheckingTestCase implements StaticCompilationTestSupport {
+
     void testShouldNotThrowStackOverflow() {
         assertScript '''
-class A {
-    private String field1 = 'test'
+            class A {
+                private String field1 = 'test'
 
-    String getField1() {
-        return this.field1
-   }
-}
+                String getField1() {
+                    return this.field1
+               }
+            }
 
-class B extends A {
-    @Override
-    String getField1() {
-        super.field1
-    }
-}
+            class B extends A {
+                @Override
+                String getField1() {
+                    super.field1
+                }
+            }
 
-B b = new B()
+            B b = new B()
 
-assert b.field1 == 'test'
-'''
+            assert b.field1 == 'test'
+        '''
     }
 
     void testShouldNotThrowStackOverflowWithSuper() {
         assertScript '''
-class A {
-    private String field1 = 'test'
+            class A {
+                private String field1 = 'test'
 
-    void setField1(String val) { field1 = val }
+                void setField1(String val) { field1 = val }
 
-    String getField1() {
-        return this.field1
-   }
-}
+                String getField1() {
+                    return this.field1
+               }
+            }
 
-class B extends A {
-    @Override
-    String getField1() {
-        super.field1 = 'test 2'
-        super.field1
-    }
-}
+            class B extends A {
+                @Override
+                String getField1() {
+                    super.field1 = 'test 2'
+                    super.field1
+                }
+            }
 
-B b = new B()
+            B b = new B()
 
-assert b.field1 == 'test 2'
-'''
+            assert b.field1 == 'test 2'
+        '''
     }
 }