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 2021/12/26 18:41:57 UTC
[groovy] branch GROOVY_2_5_X updated: GROOVY-7482: add test case
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
new 5e98f70 GROOVY-7482: add test case
5e98f70 is described below
commit 5e98f70bc766af35b0f76a040c91782143aa9ffa
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sun Dec 26 12:41:48 2021 -0600
GROOVY-7482: add test case
---
.../groovy/tools/javac/JavaStubGenerator.java | 12 ++---
.../groovy/tools/stubgenerator/Groovy7482.groovy | 55 ++++++++++++++++++++++
2 files changed, 59 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java b/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java
index fc095b0..a62d385 100644
--- a/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java
+++ b/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java
@@ -108,13 +108,10 @@ public class JavaStubGenerator {
private static final int DEFAULT_BUFFER_SIZE = 8 * 1024; // 8K
public void generateClass(ClassNode classNode) throws FileNotFoundException {
// Only attempt to render our self if our super-class is resolved, else wait for it
- if (requireSuperResolved && !classNode.getSuperClass().isResolved()) {
- return;
- }
+ if (requireSuperResolved && !classNode.getSuperClass().isResolved()) return;
// owner should take care for us
- if (classNode instanceof InnerClassNode)
- return;
+ if (classNode instanceof InnerClassNode) return;
// don't generate stubs for private classes, as they are only visible in the same file
if ((classNode.getModifiers() & Opcodes.ACC_PRIVATE) != 0) return;
@@ -142,7 +139,6 @@ public class JavaStubGenerator {
printImports(out, classNode);
printClassContents(out, classNode);
-
}
}
@@ -278,7 +274,7 @@ public class JavaStubGenerator {
String className = classNode.getNameWithoutPackage();
if (classNode instanceof InnerClassNode)
- className = className.substring(className.lastIndexOf("$") + 1);
+ className = className.substring(className.lastIndexOf('$') + 1);
out.println(className);
printGenericsBounds(out, classNode, true);
@@ -589,7 +585,7 @@ public class JavaStubGenerator {
for (ClassNode stub:stubExceptions) {
if (stub.isDerivedFrom(superExc)) continue outer;
}
- // not found
+ // not found
return false;
}
diff --git a/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy7482.groovy b/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy7482.groovy
new file mode 100644
index 0000000..6bdf7a4
--- /dev/null
+++ b/src/test/org/codehaus/groovy/tools/stubgenerator/Groovy7482.groovy
@@ -0,0 +1,55 @@
+/*
+ * 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
+
+final class Groovy7482 extends StringSourcesStubTestCase {
+
+ @Override
+ Map<String, String> provideSources() {
+ [
+ 'A.java': '''
+ public abstract class A {
+ private Object getProperty(String name) {
+ return null;
+ }
+ }
+ ''',
+
+ 'C.groovy': '''
+ class C extends A {
+ }
+ ''',
+
+ 'Main.java': '''
+ public class Main {
+ public static void main(String[] args) {
+ new C();
+ }
+ }
+ '''
+ ]
+ }
+
+ @Override
+ void verifyStubs() {
+ String stub = stubJavaSourceFor('C')
+ assert !stub.contains('getProperty')
+ assert !stub.contains('GroovyObject')
+ }
+}