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/01/17 05:13:49 UTC

[groovy] branch GROOVY_4_0_X updated (0ca772a -> 8e1e728)

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

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


    from 0ca772a  GROOVY-10449: Include public fields in the list of properties returned by MetaClassImpl#getProperties()
     new 88b768e  add some javadoc
     new 627f0fc  GROOVY-10451: Sealed classes incorrectly allow a self-reference in the permitted subclasses
     new 8264b2d  GROOVY-10452: Bump slf4j to 1.7.33 (test dependency)
     new 8e1e728  GROOVY-10453: Bump jqwik to 1.6.3 (test dependency)

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java |  2 ++
 src/main/java/org/codehaus/groovy/ast/ClassNode.java          |  3 +++
 .../codehaus/groovy/transform/SealedASTTransformation.java    | 10 ++++++++--
 src/test/groovy/bugs/Groovy6932Bug.groovy                     |  2 +-
 src/test/groovy/bugs/Groovy8060Bug.groovy                     |  2 +-
 .../groovy/classgen/asm/sc/StaticCompileFlowTypingTest.groovy |  2 +-
 .../org/codehaus/groovy/transform/SealedTransformTest.groovy  | 11 +++++++++++
 subprojects/groovy-test-junit5/build.gradle                   |  2 +-
 versions.properties                                           |  2 +-
 9 files changed, 29 insertions(+), 7 deletions(-)

[groovy] 01/04: add some javadoc

Posted by pa...@apache.org.
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 88b768e79c9ceaa2ac46e1cabc926f8f2c7fa820
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sun Jan 16 22:12:57 2022 +1000

    add some javadoc
---
 src/main/java/org/codehaus/groovy/ast/ClassNode.java | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/main/java/org/codehaus/groovy/ast/ClassNode.java b/src/main/java/org/codehaus/groovy/ast/ClassNode.java
index 2732d8c..81fa7dd 100644
--- a/src/main/java/org/codehaus/groovy/ast/ClassNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/ClassNode.java
@@ -1417,6 +1417,9 @@ public class ClassNode extends AnnotatedNode {
         return (getModifiers() & ACC_ABSTRACT) != 0;
     }
 
+    /**
+     * @return true for native and emulated (annotation based) sealed classes
+     */
     public boolean isSealed() {
         return !getAnnotations(SEALED_TYPE).isEmpty() || !getPermittedSubclasses().isEmpty();
     }

[groovy] 03/04: GROOVY-10452: Bump slf4j to 1.7.33 (test dependency)

Posted by pa...@apache.org.
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 8264b2d8a9d0d090e0c749a6550c030d92f6fc23
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Jan 17 14:58:11 2022 +1000

    GROOVY-10452: Bump slf4j to 1.7.33 (test dependency)
---
 src/test/groovy/bugs/Groovy6932Bug.groovy                               | 2 +-
 src/test/groovy/bugs/Groovy8060Bug.groovy                               | 2 +-
 .../codehaus/groovy/classgen/asm/sc/StaticCompileFlowTypingTest.groovy  | 2 +-
 versions.properties                                                     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/test/groovy/bugs/Groovy6932Bug.groovy b/src/test/groovy/bugs/Groovy6932Bug.groovy
index 3dabebe..22369a1 100644
--- a/src/test/groovy/bugs/Groovy6932Bug.groovy
+++ b/src/test/groovy/bugs/Groovy6932Bug.groovy
@@ -23,7 +23,7 @@ import groovy.test.GroovyTestCase
 class Groovy6932Bug extends GroovyTestCase {
     void testLoggingWithinClosuresShouldHaveGuards() {
         assertScript '''
-            @Grab('org.slf4j:slf4j-simple:1.7.31')
+            @Grab('org.slf4j:slf4j-simple:1.7.33')
             import groovy.util.logging.Slf4j
 
             new TestCode().doSomethingThatLogs()
diff --git a/src/test/groovy/bugs/Groovy8060Bug.groovy b/src/test/groovy/bugs/Groovy8060Bug.groovy
index 937a587..8546ae5 100644
--- a/src/test/groovy/bugs/Groovy8060Bug.groovy
+++ b/src/test/groovy/bugs/Groovy8060Bug.groovy
@@ -23,7 +23,7 @@ import groovy.test.GroovyTestCase
 class Groovy8060Bug extends GroovyTestCase {
     void testLoggingWithinClosuresThatAreMethodArgsShouldHaveGuards() {
         assertScript '''
-            @Grab('org.slf4j:slf4j-simple:1.7.31')
+            @Grab('org.slf4j:slf4j-simple:1.7.33')
             import groovy.util.logging.Slf4j
 
             @Slf4j
diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/StaticCompileFlowTypingTest.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/StaticCompileFlowTypingTest.groovy
index 671ef8c..f9013c2 100644
--- a/src/test/org/codehaus/groovy/classgen/asm/sc/StaticCompileFlowTypingTest.groovy
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/StaticCompileFlowTypingTest.groovy
@@ -88,7 +88,7 @@ final class StaticCompileFlowTypingTest {
                 @Grab('javax.servlet:javax.servlet-api:3.0.1'),
                 @Grab('org.grails.plugins:converters:3.3.+'),
                 @Grab('org.grails:grails-web:3.3.+'),
-                @Grab('org.slf4j:slf4j-nop:1.7.31')
+                @Grab('org.slf4j:slf4j-nop:1.7.33')
             ])
             @GrabExclude('org.codehaus.groovy:*')
             import static grails.converters.JSON.parse
diff --git a/versions.properties b/versions.properties
index 87bb218..a6b6fb8 100644
--- a/versions.properties
+++ b/versions.properties
@@ -42,7 +42,7 @@ log4j2=2.17.1
 openbeans=1.0.2
 picocli=4.6.2
 qdox=1.12.1
-slf4j=1.7.32
+slf4j=1.7.33
 xmlunit=1.6
 xstream=1.4.18
 # running with Groovy 4 can be allowed with -Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=true

[groovy] 02/04: GROOVY-10451: Sealed classes incorrectly allow a self-reference in the permitted subclasses

Posted by pa...@apache.org.
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 627f0fce2fc184337e24bc489f5742dc487f0e85
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sun Jan 16 23:33:36 2022 +1000

    GROOVY-10451: Sealed classes incorrectly allow a self-reference in the permitted subclasses
---
 src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java |  2 ++
 .../codehaus/groovy/transform/SealedASTTransformation.java    | 10 ++++++++--
 .../org/codehaus/groovy/transform/SealedTransformTest.groovy  | 11 +++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index 690547c..ae248a8 100644
--- a/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -1555,6 +1555,8 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> {
                                 .map(ClassExpression::new)
                                 .collect(Collectors.toList()));
                 sealedAnnotationNode.setMember("permittedSubclasses", permittedSubclassesListExpression);
+                configureAST(sealedAnnotationNode, ctx.PERMITS());
+                sealedAnnotationNode.setNodeMetaData("permits", true);
             }
             classNode.addAnnotation(sealedAnnotationNode);
         } else if (isNonSealed) {
diff --git a/src/main/java/org/codehaus/groovy/transform/SealedASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/SealedASTTransformation.java
index 04fda04..31dee5e 100644
--- a/src/main/java/org/codehaus/groovy/transform/SealedASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/SealedASTTransformation.java
@@ -43,6 +43,7 @@ import static org.codehaus.groovy.ast.ClassHelper.make;
 public class SealedASTTransformation extends AbstractASTTransformation {
 
     private static final Class<?> SEALED_CLASS = Sealed.class;
+    private static final String SEALED_NAME = "@" + SEALED_CLASS.getSimpleName();
     private static final ClassNode SEALED_TYPE = make(SEALED_CLASS);
     private static final ClassNode SEALED_OPTIONS_TYPE = make(SealedOptions.class);
     public static final String SEALED_ALWAYS_ANNOTATE = "groovy.transform.SealedOptions.alwaysAnnotate";
@@ -57,11 +58,11 @@ public class SealedASTTransformation extends AbstractASTTransformation {
         if (parent instanceof ClassNode) {
             ClassNode cNode = (ClassNode) parent;
             if (cNode.isEnum()) {
-                addError("@" + SEALED_CLASS.getSimpleName() + " not allowed for enum", cNode);
+                addError(SEALED_NAME + " not allowed for enum", cNode);
                 return;
             }
             if (cNode.isAnnotationDefinition()) {
-                addError("@" + SEALED_CLASS.getSimpleName() + " not allowed for annotation definition", cNode);
+                addError(SEALED_NAME + " not allowed for annotation definition", cNode);
                 return;
             }
             cNode.putNodeMetaData(SEALED_CLASS, Boolean.TRUE);
@@ -89,6 +90,11 @@ public class SealedASTTransformation extends AbstractASTTransformation {
             }
             List<ClassNode> newSubclasses = getMemberClassList(anno, "permittedSubclasses");
             if (newSubclasses != null) {
+                newSubclasses.forEach(subnode -> {
+                    if (subnode.equals(cNode)) {
+                        addError("Illegal self-reference: a sealed class cannot have itself as a permitted subclass", anno);
+                    }
+                });
                 cNode.getPermittedSubclasses().addAll(newSubclasses);
             }
         }
diff --git a/src/test/org/codehaus/groovy/transform/SealedTransformTest.groovy b/src/test/org/codehaus/groovy/transform/SealedTransformTest.groovy
index b375a8b..7e23073 100644
--- a/src/test/org/codehaus/groovy/transform/SealedTransformTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/SealedTransformTest.groovy
@@ -222,4 +222,15 @@ class SealedTransformTest {
         ''')
         assert shapeClass.getAnnotation(Sealed) == null
     }
+
+    @Test
+    void testSealedSelfReference() {
+        def expected = "Illegal self-reference: a sealed class cannot have itself as a permitted subclass"
+        assert shouldFail(MultipleCompilationErrorsException, '''
+            @groovy.transform.Sealed(permittedSubclasses=Shape) class Shape { }
+        ''').message.contains(expected)
+        assert shouldFail(MultipleCompilationErrorsException, '''
+            sealed class Other permits Other { }
+        ''').message.contains(expected)
+    }
 }

[groovy] 04/04: GROOVY-10453: Bump jqwik to 1.6.3 (test dependency)

Posted by pa...@apache.org.
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 8e1e7288b567f39fb02b04aeec6e9b6c5851c388
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Jan 17 14:58:47 2022 +1000

    GROOVY-10453: Bump jqwik to 1.6.3 (test dependency)
---
 subprojects/groovy-test-junit5/build.gradle | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/subprojects/groovy-test-junit5/build.gradle b/subprojects/groovy-test-junit5/build.gradle
index 8a5a3ae..740ea4f 100644
--- a/subprojects/groovy-test-junit5/build.gradle
+++ b/subprojects/groovy-test-junit5/build.gradle
@@ -33,7 +33,7 @@ dependencies {
         exclude(group: 'org.apiguardian', module: 'apiguardian-api')
     }
     testImplementation "org.junit.jupiter:junit-jupiter-params:${versions.junit5}"
-    testImplementation 'net.jqwik:jqwik:1.6.2'
+    testImplementation 'net.jqwik:jqwik:1.6.3'
     testRuntimeOnly "org.junit.platform:junit-platform-engine:${versions.junit5Platform}"
     testRuntimeOnly "org.junit.platform:junit-platform-runner:${versions.junit5Platform}"
     testImplementation project(':groovy-test')