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 2021/08/06 15:34:15 UTC
[groovy] branch master updated: GROOVY-10121: @AnnotationCollector
does not work with JUnit 5
This is an automated email from the ASF dual-hosted git repository.
paulk 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 5f90966 GROOVY-10121: @AnnotationCollector does not work with JUnit 5
5f90966 is described below
commit 5f90966fd547d138469a8c59a679c4a429e2a4ca
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sat Aug 7 01:34:07 2021 +1000
GROOVY-10121: @AnnotationCollector does not work with JUnit 5
---
.../transform/AnnotationCollectorTransform.java | 2 +-
.../AnnotationCollectorReflectionTest.groovy | 29 ++++++++++++++++++++++
.../groovy10121/SomeCollectedAnnotations.groovy | 24 ++++++++++++++++++
3 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java b/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java
index 3323e2b..f6beaba 100644
--- a/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java
+++ b/src/main/java/org/codehaus/groovy/transform/AnnotationCollectorTransform.java
@@ -121,7 +121,7 @@ public class AnnotationCollectorTransform {
// force no interfaces implemented
helper.setInterfaces(ClassNode.EMPTY_ARRAY);
} else {
- helper = new InnerClassNode(cn.getPlainNodeReference(), cn.getName() + "$CollectorHelper",
+ helper = new InnerClassNode(cn, cn.getName() + "$CollectorHelper",
ACC_PUBLIC | ACC_STATIC | ACC_FINAL, ClassHelper.OBJECT_TYPE.getPlainNodeReference());
cn.getModule().addClass(helper);
helper.addAnnotation(new AnnotationNode(COMPILESTATIC_CLASSNODE));
diff --git a/src/test/groovy/bugs/groovy10121/AnnotationCollectorReflectionTest.groovy b/src/test/groovy/bugs/groovy10121/AnnotationCollectorReflectionTest.groovy
new file mode 100644
index 0000000..505279a
--- /dev/null
+++ b/src/test/groovy/bugs/groovy10121/AnnotationCollectorReflectionTest.groovy
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package groovy.bugs.groovy10121
+
+import org.junit.Test
+
+final class AnnotationCollectorReflectionTest {
+ @Test
+ void testHelperIsVisibleAsInnerClass() {
+ def innerNames = SomeCollectedAnnotations.classes*.name
+ assert innerNames.contains('groovy.bugs.groovy10121.SomeCollectedAnnotations$CollectorHelper')
+ }
+}
diff --git a/src/test/groovy/bugs/groovy10121/SomeCollectedAnnotations.groovy b/src/test/groovy/bugs/groovy10121/SomeCollectedAnnotations.groovy
new file mode 100644
index 0000000..d7dd5cc
--- /dev/null
+++ b/src/test/groovy/bugs/groovy10121/SomeCollectedAnnotations.groovy
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package groovy.bugs.groovy10121
+
+import groovy.transform.AnnotationCollector
+
+@AnnotationCollector
+@interface SomeCollectedAnnotations { }