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 2020/04/22 02:33:14 UTC
[groovy] 01/02: GROOVY-9405: Junit 5 IncompatibleClassChangeError
(inner classes not being written in package-info classes)
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
commit f33fc06bbea013841ca736997354ecb0c46bae65
Author: Paul King <pa...@asert.com.au>
AuthorDate: Tue Apr 21 22:14:13 2020 +1000
GROOVY-9405: Junit 5 IncompatibleClassChangeError (inner classes not being written in package-info classes)
---
.../groovy/classgen/AsmClassGenerator.java | 49 ++++++++++----------
.../groovy/tools/stubgenerator/Groovy9405.groovy | 52 ++++++++++++++++++++++
2 files changed, 75 insertions(+), 26 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
index f8ca958..3524267 100644
--- a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
+++ b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
@@ -241,35 +241,32 @@ public class AsmClassGenerator extends ClassGenerator {
// pull them out of package node but treat them like they were on class node
visitAnnotations(classNode, packageNode, classVisitor);
}
- classVisitor.visitEnd();
- return;
} else {
visitAnnotations(classNode, classVisitor);
- }
-
- if (classNode.isInterface()) {
- ClassNode owner = classNode;
- if (owner instanceof InnerClassNode) {
- owner = owner.getOuterClass();
- }
- String outerClassName = classNode.getName();
- String name = outerClassName + "$" + context.getNextInnerClassIdx();
- controller.setInterfaceClassLoadingClass(
- new InterfaceHelperClassNode (
- owner, name, ACC_SUPER | ACC_SYNTHETIC | ACC_STATIC, ClassHelper.OBJECT_TYPE,
- controller.getCallSiteWriter().getCallSites()));
- super.visitClass(classNode);
- createInterfaceSyntheticStaticFields();
- } else {
- super.visitClass(classNode);
- MopWriter.Factory mopWriterFactory = classNode.getNodeMetaData(MopWriter.Factory.class);
- if (mopWriterFactory == null) {
- mopWriterFactory = MopWriter.FACTORY;
+ if (classNode.isInterface()) {
+ ClassNode owner = classNode;
+ if (owner instanceof InnerClassNode) {
+ owner = owner.getOuterClass();
+ }
+ String outerClassName = classNode.getName();
+ String name = outerClassName + "$" + context.getNextInnerClassIdx();
+ controller.setInterfaceClassLoadingClass(
+ new InterfaceHelperClassNode (
+ owner, name, ACC_SUPER | ACC_SYNTHETIC | ACC_STATIC, ClassHelper.OBJECT_TYPE,
+ controller.getCallSiteWriter().getCallSites()));
+ super.visitClass(classNode);
+ createInterfaceSyntheticStaticFields();
+ } else {
+ super.visitClass(classNode);
+ MopWriter.Factory mopWriterFactory = classNode.getNodeMetaData(MopWriter.Factory.class);
+ if (mopWriterFactory == null) {
+ mopWriterFactory = MopWriter.FACTORY;
+ }
+ MopWriter mopWriter = mopWriterFactory.create(controller);
+ mopWriter.createMopMethods();
+ controller.getCallSiteWriter().generateCallSiteArray();
+ createSyntheticStaticFields();
}
- MopWriter mopWriter = mopWriterFactory.create(controller);
- mopWriter.createMopMethods();
- controller.getCallSiteWriter().generateCallSiteArray();
- createSyntheticStaticFields();
}
// GROOVY-6750 and GROOVY-6808
diff --git a/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy9405.groovy b/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy9405.groovy
new file mode 100644
index 0000000..73db7f0
--- /dev/null
+++ b/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy9405.groovy
@@ -0,0 +1,52 @@
+/*
+ * 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 org.codehaus.groovy.tools.stubgenerator
+
+class Groovy9405 extends StringSourcesStubTestCase {
+
+ Map<String, String> provideSources() {
+ [
+ 'test/Requires.java': '''
+ package test;
+ import java.lang.annotation.*;
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ElementType.PACKAGE})
+ public @interface Requires {
+ Class<? extends groovy.lang.Closure> condition();
+ }
+ ''',
+ 'test/package-info.groovy': '''
+ @test.Requires(condition = { -> true })
+ package test
+ '''
+ ]
+ }
+
+// protected void init() {
+// debug = true
+// delete = false
+// }
+
+ void verifyStubs() {
+ def piClass = loader.loadClass('test.package-info')
+ def inners = piClass.classes
+ assert inners.length > 0
+ assert inners*.name.contains('test.package-info$_closure1')
+ }
+}