You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2022/10/29 06:20:43 UTC

[groovy] 01/09: Polish org.codehaus.groovy.classgen package documentation

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

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

commit 1288928c6792dfaab135fb0bc2beac1593dc63d4
Author: Marc Wrobel <ma...@gmail.com>
AuthorDate: Tue Oct 18 14:28:38 2022 +0200

    Polish org.codehaus.groovy.classgen package documentation
    
    Fix typos and improve documentation (javadoc, comments) in the org.codehaus.groovy.classgen package.
    
    Note that the following words / expressions were preferred :
    
    - meta data -> metadata (incorrect, see https://www.merriam-webster.com/dictionary/metadata),
    - meta class -> metaclass (incorrect, see https://en.wikipedia.org/wiki/Metaclass).
    
    Trailing whitespaces were also removed in the process.
---
 .../groovy/classgen/ClassCompletionVerifier.java         |  2 +-
 .../codehaus/groovy/classgen/FinalVariableAnalyzer.java  |  2 +-
 src/main/java/org/codehaus/groovy/classgen/Verifier.java |  4 ++--
 .../groovy/classgen/asm/BinaryExpressionHelper.java      |  2 +-
 .../asm/BinaryExpressionMultiTypeDispatcher.java         |  2 +-
 .../groovy/classgen/asm/BinaryIntExpressionHelper.java   | 16 ++++++++--------
 .../groovy/classgen/asm/BinaryLongExpressionHelper.java  |  6 +++---
 .../org/codehaus/groovy/classgen/asm/BytecodeDumper.java |  2 +-
 .../org/codehaus/groovy/classgen/asm/BytecodeHelper.java |  2 +-
 .../org/codehaus/groovy/classgen/asm/CallSiteWriter.java |  2 +-
 .../org/codehaus/groovy/classgen/asm/CompileStack.java   |  8 ++++----
 .../codehaus/groovy/classgen/asm/InvocationWriter.java   |  2 +-
 .../groovy/classgen/asm/OptimizingStatementWriter.java   |  6 +++---
 .../groovy/classgen/asm/WriterControllerFactory.java     |  2 +-
 .../groovy/classgen/asm/sc/StaticInvocationWriter.java   |  2 +-
 .../sc/StaticTypesMethodReferenceExpressionWriter.java   |  2 +-
 16 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/ClassCompletionVerifier.java b/src/main/java/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
index f2d31589b3..f5ad9e825f 100644
--- a/src/main/java/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
+++ b/src/main/java/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
@@ -674,7 +674,7 @@ public class ClassCompletionVerifier extends ClassCodeVisitorSupport {
 
             /*
              *  if it is static final but not accessed inside a static constructor, or,
-             *  if it is an instance final but not accessed inside a instance constructor, it is an error
+             *  if it is an instance final but not accessed inside an instance constructor, it is an error
              */
             boolean isFinal = fn.isFinal();
             boolean isStatic = fn.isStatic();
diff --git a/src/main/java/org/codehaus/groovy/classgen/FinalVariableAnalyzer.java b/src/main/java/org/codehaus/groovy/classgen/FinalVariableAnalyzer.java
index 907182ebea..bc92c77c2b 100644
--- a/src/main/java/org/codehaus/groovy/classgen/FinalVariableAnalyzer.java
+++ b/src/main/java/org/codehaus/groovy/classgen/FinalVariableAnalyzer.java
@@ -531,7 +531,7 @@ public class FinalVariableAnalyzer extends ClassCodeVisitorSupport {
 
     public interface VariableNotFinalCallback {
         /**
-         * Callback called whenever an assignment transforms an effectively final variable into a non final variable
+         * Callback called whenever an assignment transforms an effectively final variable into a non-final variable
          * (aka, breaks the "final" modifier contract)
          *
          * @param var  the variable detected as not final
diff --git a/src/main/java/org/codehaus/groovy/classgen/Verifier.java b/src/main/java/org/codehaus/groovy/classgen/Verifier.java
index d29925b789..f431ea8403 100644
--- a/src/main/java/org/codehaus/groovy/classgen/Verifier.java
+++ b/src/main/java/org/codehaus/groovy/classgen/Verifier.java
@@ -573,7 +573,7 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
                     @Override
                     public void visit(final MethodVisitor mv) {
                         /*
-                         * the code is (meta class is stored in 1):
+                         * the code is (metaclass is stored in 1):
                          * this.metaClass = <1>
                          */
                         mv.visitVarInsn(ALOAD, 0);
@@ -1672,7 +1672,7 @@ public class Verifier implements GroovyClassVisitor, Opcodes {
     }
 
     /**
-     * When constant expressions are created, the value is always wrapped to a non primitive type.
+     * When constant expressions are created, the value is always wrapped to a non-primitive type.
      * Some constant expressions are optimized to return primitive types, but not all primitives are
      * handled. This method guarantees to return a similar constant expression but with a primitive type
      * instead of a boxed type.
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionHelper.java b/src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionHelper.java
index e5810243ea..fa425da144 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionHelper.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionHelper.java
@@ -840,7 +840,7 @@ public class BinaryExpressionHelper {
         // jump depending on the value. For true we are done, for false we
         // have to load y, thus we first remove x and then load y.
         // But since x and y may have different stack lengths, this cannot work
-        // Thus we have to have to do the following:
+        // Thus we have to do the following:
         // Be X the type of x, Y the type of y and S the common supertype of
         // X and Y, then we have to see x?:y as
         //      var t=x;boolean(t)?S(t):S(y)
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionMultiTypeDispatcher.java b/src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionMultiTypeDispatcher.java
index d00bab2c20..2dff533249 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionMultiTypeDispatcher.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/BinaryExpressionMultiTypeDispatcher.java
@@ -397,7 +397,7 @@ public class BinaryExpressionMultiTypeDispatcher extends BinaryExpressionHelper
             // store value in array
             bew.arraySet(false);
 
-            // load return value && correct operand stack stack
+            // load return value && correct operand stack
             operandStack.remove(3);
             rhsValueLoader.visit(acg);
         } else {
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/BinaryIntExpressionHelper.java b/src/main/java/org/codehaus/groovy/classgen/asm/BinaryIntExpressionHelper.java
index 731dd3ac74..19307d287f 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/BinaryIntExpressionHelper.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/BinaryIntExpressionHelper.java
@@ -57,7 +57,7 @@ public class BinaryIntExpressionHelper extends BinaryExpressionWriter {
 
     private static final int[] stdCompareCodes = {
         IF_ICMPEQ,      // COMPARE_NOT_EQUAL            120
-        IF_ICMPNE,      // COMPARE_IDENTICAL            121 
+        IF_ICMPNE,      // COMPARE_IDENTICAL            121
         IF_ICMPEQ,      // COMPARE_NOT_IDENTICAL        122
         IF_ICMPNE,      // COMPARE_EQUAL                123
         IF_ICMPGE,      // COMPARE_LESS_THAN            124
@@ -78,10 +78,10 @@ public class BinaryIntExpressionHelper extends BinaryExpressionWriter {
     private static final int[] bitOp = {
         IOR,            //  BITWISE_OR / PIPE   340
         IAND,           //  BITWISE_AND         341
-        IXOR,           //  BIWISE_XOR          342
-    };    
+        IXOR,           //  BITWISE_XOR         342
+    };
 
-    /* unhandled types from from org.codehaus.groovy.syntax.Types
+    /* unhandled types from org.codehaus.groovy.syntax.Types
     public static final int LOGICAL_OR                  = 162;   // ||
     public static final int LOGICAL_AND                 = 164;   // &&
 
@@ -137,7 +137,7 @@ public class BinaryIntExpressionHelper extends BinaryExpressionWriter {
 
 
     /**
-     * writes a std compare. This involves the tokens IF_ICMPEQ, IF_ICMPNE, 
+     * writes a std compare. This involves the tokens IF_ICMPEQ, IF_ICMPNE,
      * IF_ICMPEQ, IF_ICMPNE, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE and IF_ICMPLT
      * @param type the token type
      * @return true if a successful std compare write
@@ -174,7 +174,7 @@ public class BinaryIntExpressionHelper extends BinaryExpressionWriter {
     @Override
     protected boolean writeSpaceship(int type, boolean simulate) {
         if (type != COMPARE_TO) return false;
-        /*  
+        /*
            we will actually do
 
           (x < y) ? -1 : ((x == y) ? 0 : 1)
@@ -200,7 +200,7 @@ public class BinaryIntExpressionHelper extends BinaryExpressionWriter {
           to load them again, we will instead duplicate them. This will
           require some pop actions in the branches!
 
-              DUP2          (operands: IIII) 
+              DUP2          (operands: IIII)
               IF_ICMPGE L1  (operands: II)
               ICONST_M1     (operands: III)
               GOTO L2
@@ -212,7 +212,7 @@ public class BinaryIntExpressionHelper extends BinaryExpressionWriter {
           L3
               - jump from L1 branch to here (operands: -)
               ICONST_1      (operands: I)
-          L2  
+          L2
           - if jump from GOTO L2 we have III, but need only I
           - if from L3 branch we get only I
 
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/BinaryLongExpressionHelper.java b/src/main/java/org/codehaus/groovy/classgen/asm/BinaryLongExpressionHelper.java
index aef72e8626..2a14c0e65e 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/BinaryLongExpressionHelper.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/BinaryLongExpressionHelper.java
@@ -61,7 +61,7 @@ public class BinaryLongExpressionHelper extends BinaryExpressionWriter {
             DUP2_X1
             DUP2_X1
             POP2
-            DUP2_X1          
+            DUP2_X1
          */
         mv.visitInsn(DUP2_X1);
         mv.visitInsn(POP2);
@@ -77,14 +77,14 @@ public class BinaryLongExpressionHelper extends BinaryExpressionWriter {
         mv.visitInsn(POP2);
     }
 
-    private static final MethodCaller 
+    private static final MethodCaller
         longArrayGet = MethodCaller.newStatic(BytecodeInterface8.class, "lArrayGet"),
         longArraySet = MethodCaller.newStatic(BytecodeInterface8.class, "lArraySet");
 
     private static final int[] bitOp = {
         LOR,            //  BITWISE_OR / PIPE   340
         LAND,           //  BITWISE_AND         341
-        LXOR,           //  BIWISE_XOR          342
+        LXOR,           //  BITWISE_XOR         342
     };
 
     @Override
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeDumper.java b/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeDumper.java
index 86359e6626..bae8feea33 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeDumper.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeDumper.java
@@ -26,7 +26,7 @@ import java.io.PrintWriter;
 import java.io.Writer;
 
 /**
- * An utility class which can be used in test cases to dump generated bytecode.
+ * A utility class which can be used in test cases to dump generated bytecode.
  *
  * @since 2.4.0
  */
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 10c2ccc703..baf54fa405 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
@@ -611,7 +611,7 @@ public class BytecodeHelper {
     public static boolean isClassLiteralPossible(ClassNode classNode) {
         // the current implementation only checks for public modifier, because Groovy used to allow
         // handles on classes even if they are package protected and not in the same package.
-        // There are situations where we could make more fine grained checks, but be careful of
+        // There are situations where we could make more fine-grained checks, but be careful of
         // potential breakage of existing code.
         return Modifier.isPublic(classNode.getModifiers());
     }
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
index 6a5b797e36..5d49885fed 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/CallSiteWriter.java
@@ -64,7 +64,7 @@ import static org.objectweb.asm.Opcodes.PUTSTATIC;
 import static org.objectweb.asm.Opcodes.RETURN;
 
 /**
- * This class represents non public API used by AsmClassGenerator. Don't
+ * This class represents non-public API used by AsmClassGenerator. Don't
  * use this class in your code
  */
 public class CallSiteWriter {
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java b/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
index 64a8ce05a3..4f5d16b1b9 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
@@ -436,7 +436,7 @@ public class CompileStack {
     /**
      * Causes the state-stack to add an element and sets
      * the given scope as new current variable scope. Creates
-     * a element for the state stack so pop has to be called later
+     * an element for the state stack so pop has to be called later
      */
     public void pushVariableScope(final VariableScope scope) {
         pushState();
@@ -464,7 +464,7 @@ public class CompileStack {
     /**
      * Should be called when descending into a loop that defines
      * also a scope. Calls pushVariableScope and prepares labels
-     * for a loop structure. Creates a element for the state stack
+     * for a loop structure. Creates an element for the state stack
      * so pop has to be called later
      */
     public void pushLoop(final VariableScope el, final List<String> labelNames) {
@@ -497,7 +497,7 @@ public class CompileStack {
 
     /**
      * Should be called when descending into a loop that does
-     * not define a scope. Creates a element for the state stack
+     * not define a scope. Creates an element for the state stack
      * so pop has to be called later
      */
     public void pushLoop(final List<String> labelNames) {
@@ -544,7 +544,7 @@ public class CompileStack {
     }
 
     /**
-     * Creates a new break label and a element for the state stack
+     * Creates a new break label and an element for the state stack
      * so pop has to be called later
      */
     public Label pushSwitch() {
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java
index 8f9d38a04b..7032a92da1 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java
@@ -831,7 +831,7 @@ public class InvocationWriter {
     }
 
     /**
-     * Converts sourceType to a non primitive by using Groovy casting.
+     * Converts sourceType to a non-primitive by using Groovy casting.
      * sourceType might be a primitive
      * This might be done using SBA#castToType
      */
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/OptimizingStatementWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/OptimizingStatementWriter.java
index aa3f9b9667..2b295d98a4 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/OptimizingStatementWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/OptimizingStatementWriter.java
@@ -128,7 +128,7 @@ public class OptimizingStatementWriter extends StatementWriter {
             }
         }
 
-        // meta class check with boolean holder
+        // metaclass check with boolean holder
         MethodNode mn = controller.getMethodNode();
         if (mn != null) {
             mv.visitFieldInsn(GETSTATIC, controller.getInternalClassName(), Verifier.STATIC_METACLASS_BOOL, "Z");
@@ -332,7 +332,7 @@ public class OptimizingStatementWriter extends StatementWriter {
             super.writeExpressionStatement(statement);
         } else {
             StatementMeta meta = statement.getNodeMetaData(StatementMeta.class);
-            // we have to have handle DelcarationExpressions special, since their
+            // we have to have handle DeclarationExpressions special, since their
             // entry should be outside the optimization path, we have to do that of
             // course only if we are actually going to do two different paths,
             // otherwise it is not needed
@@ -777,7 +777,7 @@ public class OptimizingStatementWriter extends StatementWriter {
         public void visitConstructorCallExpression(final ConstructorCallExpression expression) {
             if (expression.getNodeMetaData(StatementMeta.class) != null) return;
             super.visitConstructorCallExpression(expression);
-            // we cannot set a target for the constructor call, since we cannot easily check the meta class of the other class
+            // we cannot set a target for the constructor call, since we cannot easily check the metaclass of the other class
             //setMethodTarget(call, "<init>", call.getArguments(), false);
         }
 
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/WriterControllerFactory.java b/src/main/java/org/codehaus/groovy/classgen/asm/WriterControllerFactory.java
index a98bd44aeb..9d683edc07 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/WriterControllerFactory.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/WriterControllerFactory.java
@@ -19,7 +19,7 @@
 package org.codehaus.groovy.classgen.asm;
 
 /**
- * A non static factory to get alternative writer controller to be stored in the meta data
+ * A non-static factory to get alternative writer controller to be stored in the metadata
  */
 public interface WriterControllerFactory {
     WriterController makeController(WriterController normalController);
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
index 2092c16f31..f240f92752 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
@@ -737,7 +737,7 @@ public class StaticInvocationWriter extends InvocationWriter {
                     if (isObjectType(declaringClass)) {
                         // checkcast not necessary because Object never evolves
                         // and it prevents a potential ClassCastException if the
-                        // delegate of a closure is changed in a SC closure
+                        // delegate of a closure is changed in an SC closure
                         type = ClassHelper.OBJECT_TYPE;
                     } else if (isObjectType(type)) {
                         // can happen for compiler rewritten code, where type information is missing
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
index f6319b81ac..c3efd7a793 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
@@ -145,7 +145,7 @@ public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceE
             if (isConstructorReference) { // TODO: move this check to the parser
                 addFatalError("Constructor reference must be TypeName::new", methodReferenceExpression);
             } else if (methodRefMethod.isStatic() && !targetIsArgument) {
-                // "string"::valueOf refers to static method, so instance is superflous
+                // "string"::valueOf refers to static method, so instance is superfluous
                 typeOrTargetRef = makeClassTarget(typeOrTargetRefType, typeOrTargetRef);
                 isClassExpression = true;
             } else {