diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationInspection.java index 31d8d55143ed..5bcc11b0e8d9 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationInspection.java @@ -8,6 +8,7 @@ import com.intellij.codeInsight.daemon.impl.quickfix.MethodThrowsFix; import com.intellij.codeInspection.*; import com.intellij.codeInspection.reference.*; import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel; +import com.intellij.lang.jvm.JvmModifier; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -71,6 +72,9 @@ public class RedundantThrowsDeclarationInspection extends GlobalJavaBatchInspect PsiElement psiMethod = refMethod.getPsiElement(); if (!(psiMethod instanceof PsiMethod)) return null; + + if (((PsiMethod)psiMethod).hasModifier(JvmModifier.NATIVE)) return null; + PsiReferenceList list = ((PsiMethod)psiMethod).getThrowsList(); PsiClassType[] throwsList = list.getReferencedTypes(); PsiJavaCodeReferenceElement[] throwsRefs = list.getReferenceElements(); diff --git a/java/java-tests/testData/inspection/redundantThrow/NativeMethod/expected.xml b/java/java-tests/testData/inspection/redundantThrow/NativeMethod/expected.xml new file mode 100644 index 000000000000..ec272abeaa3a --- /dev/null +++ b/java/java-tests/testData/inspection/redundantThrow/NativeMethod/expected.xml @@ -0,0 +1,3 @@ + + + diff --git a/java/java-tests/testData/inspection/redundantThrow/NativeMethod/src/Foo.java b/java/java-tests/testData/inspection/redundantThrow/NativeMethod/src/Foo.java new file mode 100644 index 000000000000..833c99709286 --- /dev/null +++ b/java/java-tests/testData/inspection/redundantThrow/NativeMethod/src/Foo.java @@ -0,0 +1,11 @@ +import java.io.*; + +class Bar { + + public native int goDrink(String arg) throws IOException; + + public static void main(String[] args) throws IOException { + Bar bar = new Bar(); + bar.goDrink("aaa"); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/RedundantThrowTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/RedundantThrowTest.java index 7662c8c701b8..b5da50c3551e 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/RedundantThrowTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/RedundantThrowTest.java @@ -58,4 +58,8 @@ public class RedundantThrowTest extends InspectionTestCase { public void testThrownClausesInMethodReference() { doTest(); } + + public void testNativeMethod() { + doTest(); + } }