diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java
index 981fb7fe67eb..0e651d1a6199 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/JavaAPIUsagesInspectionTest.java
@@ -23,7 +23,6 @@ package com.intellij.codeInspection;
import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.java15api.Java15APIUsageInspection;
-import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.InspectionTestCase;
@@ -63,11 +62,6 @@ public class JavaAPIUsagesInspectionTest extends InspectionTestCase {
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_1_6, JavaAPIUsagesInspectionTest.this::doTest);
}
- @Override
- protected Sdk getTestProjectSdk() {
- return IdeaTestUtil.getMockJdk18();
- }
-
//generate apiXXX.txt
/*
//todo exclude inheritors of ConcurrentMap#putIfAbsent
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java
index 8588e37d1fbf..3c28371a74c2 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/MagicConstantInspectionTest.java
@@ -38,6 +38,7 @@ import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.source.PsiClassImpl;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.FileTreeAccessFilter;
+import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.InspectionTestCase;
import com.intellij.testFramework.PsiTestUtil;
import org.jetbrains.annotations.NotNull;
@@ -62,7 +63,8 @@ public class MagicConstantInspectionTest extends InspectionTestCase {
@Override
protected Sdk getTestProjectSdk() {
- return PsiTestUtil.addJdkAnnotations(super.getTestProjectSdk());
+ // has to have JFrame and sources
+ return PsiTestUtil.addJdkAnnotations(IdeaTestUtil.getMockJdk17());
}
private void doTest() throws Exception {
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
index a8b27ab21089..d6c194fd1f92 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast15Test.java
@@ -3,6 +3,7 @@ package com.intellij.codeInspection;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
+import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.openapi.roots.ModuleRootModificationUtil;
import com.intellij.pom.java.LanguageLevel;
@@ -17,6 +18,12 @@ public class RedundantCast15Test extends InspectionTestCase {
ModuleRootModificationUtil.setModuleSdk(getModule(), getTestProjectSdk());
}
+ @Override
+ protected Sdk getTestProjectSdk() {
+ // in jdk 8 some casts are unnecessary
+ return IdeaTestUtil.getMockJdk17();
+ }
+
private void doTest() throws Exception {
final LocalInspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(new RedundantCastInspection());
doTest("redundantCast/generics/" + getTestName(false), toolWrapper, "java 1.5");
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java
index fe187a68940d..7e9bcf8e18e4 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantCast18Test.java
@@ -17,10 +17,6 @@ package com.intellij.codeInspection;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.InspectionTestCase;
public class RedundantCast18Test extends InspectionTestCase {
@@ -35,11 +31,4 @@ public class RedundantCast18Test extends InspectionTestCase {
public void testForeachValue() throws Exception { doTest(); }
public void testConditional() throws Exception { doTest(); }
public void testInferApplicabilityError() throws Exception { doTest(); }
-
- @Override
- protected Sdk getTestProjectSdk() {
- Sdk sdk = IdeaTestUtil.getMockJdk17();
- LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
- return sdk;
- }
}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantThrowTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantThrowTest.java
index 61dc1d9a5600..4a7d7d1f35ab 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/RedundantThrowTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/RedundantThrowTest.java
@@ -17,10 +17,6 @@ package com.intellij.codeInspection;
import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.unneededThrows.RedundantThrows;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.InspectionTestCase;
public class RedundantThrowTest extends InspectionTestCase {
@@ -68,11 +64,4 @@ public class RedundantThrowTest extends InspectionTestCase {
public void testThrownClausesInFunctionalExpressions() throws Exception {
doTest();
}
-
- @Override
- protected Sdk getTestProjectSdk() {
- Sdk sdk = IdeaTestUtil.getMockJdk17();
- LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
- return sdk;
- }
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedReturnValueTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedReturnValueTest.java
index 74f27e0b0c11..c72432532ad6 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedReturnValueTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedReturnValueTest.java
@@ -12,10 +12,6 @@ package com.intellij.codeInspection;
import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.unusedReturnValue.UnusedReturnValue;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.InspectionTestCase;
public class UnusedReturnValueTest extends InspectionTestCase {
@@ -47,13 +43,6 @@ public class UnusedReturnValueTest extends InspectionTestCase {
doTest();
}
- @Override
- protected Sdk getTestProjectSdk() {
- Sdk sdk = IdeaTestUtil.getMockJdk18();
- LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
- return sdk;
- }
-
public void testSimpleSetter() throws Exception {
try {
myTool.IGNORE_BUILDER_PATTERN = true;
diff --git a/java/mockJDK-1.8/jre/lib/rt.jar b/java/mockJDK-1.8/jre/lib/rt.jar
index f3a4f893f3d4..6885606d2964 100644
Binary files a/java/mockJDK-1.8/jre/lib/rt.jar and b/java/mockJDK-1.8/jre/lib/rt.jar differ
diff --git a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java
index 60a2cf9d4570..08eb0e5fdc73 100644
--- a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java
+++ b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java
@@ -234,8 +234,8 @@ public abstract class InspectionTestCase extends PsiTestCase {
}
protected Sdk getTestProjectSdk() {
- Sdk sdk = IdeaTestUtil.getMockJdk17();
- LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
+ Sdk sdk = IdeaTestUtil.getMockJdk18();
+ LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
return sdk;
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/StandardVariableNames.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/StandardVariableNames.java
index 5bfc39c12c7f..60e62a243aa9 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/StandardVariableNames.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/StandardVariableNames.java
@@ -1,5 +1,5 @@
package com.siyeh.igtest.naming.standard_variable_names;
-
+import java.io.*;
public class StandardVariableNames {
void bad() {
@@ -21,9 +21,13 @@ public class StandardVariableNames {
long l;
String s, str;
- new java.io.OutputStream() {
+ new MyOutputStream() {
+ // same as super
public void write(int b) throws IOException {}
- }
+ };
}
+}
+interface MyOutputStream {
+ void write(int b) throws IOException;
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/expected.xml
index aa28723a840c..52999e682cc8 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/naming/standard_variable_names/expected.xml
@@ -84,4 +84,11 @@
Standard variable names
Variable named <code>str</code> doesn't have type 'java.lang.String' #loc
+
+
+ StandardVariableNames.java
+ 32
+ Standard variable names
+ Variable named <code>b</code> doesn't have type 'byte' or 'java.lang.Byte' #loc
+
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/AssertWithSideEffectsInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/AssertWithSideEffectsInspectionTest.java
index b1106554548f..d0b21a7960a7 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/AssertWithSideEffectsInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/AssertWithSideEffectsInspectionTest.java
@@ -1,8 +1,15 @@
package com.siyeh.ig.bugs;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.testFramework.IdeaTestUtil;
import com.siyeh.ig.IGInspectionTestCase;
public class AssertWithSideEffectsInspectionTest extends IGInspectionTestCase {
+ @Override
+ protected Sdk getTestProjectSdk() {
+ // uses SQL
+ return IdeaTestUtil.getMockJdk17();
+ }
public void test() throws Exception {
doTest("com/siyeh/igtest/bugs/assert_with_side_effects",
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/FinalPrivateMethodInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/FinalPrivateMethodInspectionTest.java
index cc10fbc46415..7d51d61c834b 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/FinalPrivateMethodInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/FinalPrivateMethodInspectionTest.java
@@ -15,24 +15,12 @@
*/
package com.siyeh.ig.classlayout;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.testFramework.IdeaTestUtil;
import com.siyeh.ig.IGInspectionTestCase;
/**
* @author Bas Leijdekkers
*/
public class FinalPrivateMethodInspectionTest extends IGInspectionTestCase {
-
- @Override
- protected Sdk getTestProjectSdk() {
- LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
- return IdeaTestUtil.getMockJdk17();
- }
-
public void test() throws Exception {
doTest("com/siyeh/igtest/classlayout/final_private_method", new FinalPrivateMethodInspection());
}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java
index 753c2f76f53a..5e6ed0b25c88 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspectionTest.java
@@ -1,9 +1,5 @@
package com.siyeh.ig.inheritance;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.testFramework.IdeaTestUtil;
import com.siyeh.ig.IGInspectionTestCase;
public class AbstractMethodOverridesAbstractMethodInspectionTest extends IGInspectionTestCase {
@@ -14,11 +10,4 @@ public class AbstractMethodOverridesAbstractMethodInspectionTest extends IGInspe
tool.ignoreJavaDoc = true;
doTest("com/siyeh/igtest/inheritance/abstract_method_overrides_abstract_method", tool);
}
-
- @Override
- protected Sdk getTestProjectSdk() {
- Sdk sdk = IdeaTestUtil.getMockJdk17();
- LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
- return sdk;
- }
}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/InterfaceNeverImplementedInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/InterfaceNeverImplementedInspectionTest.java
index d0bbbac1b820..1ebeb5519194 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/InterfaceNeverImplementedInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/inheritance/InterfaceNeverImplementedInspectionTest.java
@@ -1,14 +1,11 @@
package com.siyeh.ig.inheritance;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
-import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
-import com.intellij.testFramework.IdeaTestUtil;
import com.siyeh.ig.IGInspectionTestCase;
public class InterfaceNeverImplementedInspectionTest extends IGInspectionTestCase {
-
public void test() throws Exception {
final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
final LanguageLevel level = levelProjectExtension.getLanguageLevel();
@@ -21,9 +18,4 @@ public class InterfaceNeverImplementedInspectionTest extends IGInspectionTestCas
levelProjectExtension.setLanguageLevel(level);
}
}
-
- @Override
- protected Sdk getTestProjectSdk() {
- return IdeaTestUtil.getMockJdk18();
- }
}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFinalOnLocalVariableOrParameterInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFinalOnLocalVariableOrParameterInspectionTest.java
index a78fff6c492a..2dcbf3dfe287 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFinalOnLocalVariableOrParameterInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFinalOnLocalVariableOrParameterInspectionTest.java
@@ -15,9 +15,16 @@
*/
package com.siyeh.ig.style;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.testFramework.IdeaTestUtil;
import com.siyeh.ig.IGInspectionTestCase;
public class UnnecessaryFinalOnLocalVariableOrParameterInspectionTest extends IGInspectionTestCase {
+ @Override
+ protected Sdk getTestProjectSdk() {
+ // effectively final rules are different in jdk 8
+ return IdeaTestUtil.getMockJdk17();
+ }
public void test() throws Exception {
doTest("com/siyeh/igtest/style/unnecessary_final_on_local_variable_or_parameter",
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java
index 1856fc662a46..144eac9359b9 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java
@@ -1,14 +1,21 @@
package com.siyeh.ig.style;
+import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
+import com.intellij.testFramework.IdeaTestUtil;
import com.siyeh.ig.IGInspectionTestCase;
public class UnnecessaryFullyQualifiedNameInspectionTest extends IGInspectionTestCase {
-
private static final String BASE_DIR = "com/siyeh/igtest/style/";
+ @Override
+ protected Sdk getTestProjectSdk() {
+ // uses awt
+ return IdeaTestUtil.getMockJdk17();
+ }
+
public void testFqnInJavadoc_Unnecessary_WhenFullyQualifyIfNotImported() throws Exception {
doTestWithFqnInJavadocSetting(BASE_DIR + "unnecessary_fqn_javadoc_fully_qualify_if_not_imported", JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_IF_NOT_IMPORTED);
}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/visibility/MethodOverloadsParentMethodInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/visibility/MethodOverloadsParentMethodInspectionTest.java
index 0fe9f5d4c1c1..d187b16cb6ba 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/visibility/MethodOverloadsParentMethodInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/visibility/MethodOverloadsParentMethodInspectionTest.java
@@ -1,22 +1,9 @@
package com.siyeh.ig.visibility;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.testFramework.IdeaTestUtil;
import com.siyeh.ig.IGInspectionTestCase;
public class MethodOverloadsParentMethodInspectionTest extends IGInspectionTestCase {
-
public void test() throws Exception {
doTest("com/siyeh/igtest/visibility/method_overloads_parent_method", new MethodOverloadsParentMethodInspection());
}
-
- @Override
- protected Sdk getTestProjectSdk() {
- final Sdk sdk = IdeaTestUtil.getMockJdk17();
- LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
- return sdk;
- }
-
}
\ No newline at end of file