diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/generator/GroovyToJavaGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/generator/GroovyToJavaGenerator.java index c88d6e3375d7..b51abdc337ac 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/generator/GroovyToJavaGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/generator/GroovyToJavaGenerator.java @@ -594,6 +594,20 @@ public class GroovyToJavaGenerator { writeParameterList(text, parameters); + final PsiReferenceList throwsList = method.getThrowsList(); + final PsiClassType[] exceptions = throwsList.getReferencedTypes(); + if (exceptions.length > 0) { + text.append("throws "); + for (int i = 0; i < exceptions.length; i++) { + PsiClassType exception = exceptions[i]; + if (i != 0) { + text.append(","); + } + text.append(getTypeText(exception, method, false)); + text.append(" "); + } + } + if (!isAbstract) { /************* body **********/ text.append("{\n"); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GeneratorTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GeneratorTest.java index 24562a9dc308..57c978bd2567 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GeneratorTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GeneratorTest.java @@ -55,6 +55,7 @@ public void testArrayType1() throws Throwable { doTest(); } public void testInaccessibleConstructor() throws Throwable { doTest(); } public void testSynchronizedProperty() throws Throwable { doTest(); } public void testVarargs() throws Throwable { doTest(); } + public void testThrowsCheckedException() throws Throwable { doTest(); } public void testCheckedExceptionInConstructorDelegate() throws Throwable { myFixture.addClass("package foo;" + diff --git a/plugins/groovy/testdata/groovy/stubGenerator/throwsCheckedException.test b/plugins/groovy/testdata/groovy/stubGenerator/throwsCheckedException.test new file mode 100644 index 000000000000..620ed2a26229 --- /dev/null +++ b/plugins/groovy/testdata/groovy/stubGenerator/throwsCheckedException.test @@ -0,0 +1,30 @@ +class Foo { + def foo() throws IOException {} +} +----- +public class Foo implements groovy.lang.GroovyObject { + public java.lang.Object foo() throws java.io.IOException { + return null; + } + + public groovy.lang.MetaClass getMetaClass() { + return null; + } + + public void setMetaClass(groovy.lang.MetaClass mc) { + return ; + } + + public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args) { + return null; + } + + public java.lang.Object getProperty(java.lang.String propertyName) { + return null; + } + + public void setProperty(java.lang.String propertyName, java.lang.Object newValue) { + return ; + } +} +--- \ No newline at end of file