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

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

commit 40149b6ccde186f5a04173e4b5fe361cb9cbcd8c
Author: Daniel Sun <[email protected]>
AuthorDate: Sat Mar 7 21:54:11 2020 +0800

    GROOVY-9448: Missing throws clause of constructor declaration in java stubs
---
 .../groovy/tools/javac/JavaStubGenerator.java      | 25 ++++++++++++++--------
 1 file changed, 16 insertions(+), 9 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 7e73515..46d3cff 100644
--- a/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java
+++ b/src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java
@@ -544,6 +544,9 @@ public class JavaStubGenerator {
 
         printParams(out, constructorNode);
 
+        ClassNode[] exceptions = constructorNode.getExceptions();
+        printExceptions(out, exceptions);
+
         ConstructorCallExpression constrCall = 
getFirstIfSpecialConstructorCall(constructorNode.getCode());
         if (constrCall == null) {
             out.println(" {}");
@@ -695,15 +698,7 @@ public class JavaStubGenerator {
         printParams(out, methodNode);
 
         ClassNode[] exceptions = methodNode.getExceptions();
-        for (int i = 0; i < exceptions.length; i++) {
-            ClassNode exception = exceptions[i];
-            if (i == 0) {
-                out.print("throws ");
-            } else {
-                out.print(", ");
-            }
-            printType(out, exception);
-        }
+        printExceptions(out, exceptions);
 
         if (Traits.isTrait(clazz)) {
             out.println(";");
@@ -740,6 +735,18 @@ public class JavaStubGenerator {
         }
     }
 
+    private void printExceptions(PrintWriter out, ClassNode[] exceptions) {
+        for (int i = 0; i < exceptions.length; i++) {
+            ClassNode exception = exceptions[i];
+            if (i == 0) {
+                out.print("throws ");
+            } else {
+                out.print(", ");
+            }
+            printType(out, exception);
+        }
+    }
+
     private static boolean isAbstract(final MethodNode methodNode) {
         if (isDefaultTraitImpl(methodNode)) {
             return false;

Reply via email to