diff --git a/java/java-tests/testData/compiler/notNullVerification/EnclosingClass.java b/java/java-tests/testData/compiler/notNullVerification/EnclosingClass.java index 385117b893b3..4df0d7f90b9f 100644 --- a/java/java-tests/testData/compiler/notNullVerification/EnclosingClass.java +++ b/java/java-tests/testData/compiler/notNullVerification/EnclosingClass.java @@ -1,9 +1,18 @@ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. import org.jetbrains.annotations.NotNull; public class EnclosingClass { - public static Object main() { + public static Object fromStatic() { return new Object() { - void foo(@NotNull String s) {} + void foo(@NotNull String s) { } + }; + } + + public Object fromInstance() { + return new Object() { + boolean foo(@NotNull String s) { + return s.contains(EnclosingClass.this.toString()); + } }; } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java b/java/java-tests/testSrc/com/intellij/java/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java index d805b37fb18a..34b532194825 100644 --- a/java/java-tests/testSrc/com/intellij/java/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java +++ b/java/java-tests/testSrc/com/intellij/java/compiler/notNullVerification/NotNullVerifyingInstrumenterTest.java @@ -199,7 +199,7 @@ public class NotNullVerifyingInstrumenterTest { Object instance = test.newInstance(); verifyCallThrowsException("@FooAnno method TypeUseOnlyAnnotations.foo1 must not return null", instance, test.getMethod("foo1")); verifyCallThrowsException("Argument 0 for @FooAnno parameter of TypeUseOnlyAnnotations.foo2 must not be null", instance, test.getMethod("foo2", String.class), (String)null); - test.getMethod("foo3", List.class).invoke(instance, (List)null); + test.getMethod("foo3", List.class).invoke(instance, new Object[]{null}); } @Test @@ -231,8 +231,10 @@ public class NotNullVerifyingInstrumenterTest { @Test public void testEnclosingClass() throws Exception { Class testClass = prepareTest(); - Object obj = testClass.getMethod("main").invoke(null); - assertEquals(testClass, obj.getClass().getEnclosingClass()); + Object obj1 = testClass.getMethod("fromStatic").invoke(null); + assertEquals(testClass, obj1.getClass().getEnclosingClass()); + Object obj2 = testClass.getMethod("fromInstance").invoke(testClass.newInstance()); + assertEquals(testClass, obj2.getClass().getEnclosingClass()); } @Test @@ -270,7 +272,7 @@ public class NotNullVerifyingInstrumenterTest { return prepareTest(false, AnnotationUtil.NOT_NULL); } - private Class prepareTest(boolean withDebugInfo, String... notNullAnnos) throws IOException { + private Class prepareTest(boolean withDebugInfo, String... notNullAnnotations) throws IOException { String base = JavaTestUtil.getJavaTestDataPath() + "/compiler/notNullVerification/"; String baseClassName = PlatformTestUtil.getTestName(testName.getMethodName(), false); String javaPath = (base + baseClassName) + ".java"; @@ -296,7 +298,7 @@ public class NotNullVerifyingInstrumenterTest { FailSafeClassReader reader = new FailSafeClassReader(content, 0, content.length); ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES); - modified |= NotNullVerifyingInstrumenter.processClassFile(reader, writer, notNullAnnos); + modified |= NotNullVerifyingInstrumenter.processClassFile(reader, writer, notNullAnnotations); byte[] instrumented = writer.toByteArray(); String className = FileUtil.getNameWithoutExtension(fileName); diff --git a/plugins/IntelliLang/intellilang-jps-plugin/test/org/jetbrains/jps/intellilang/instrumentation/PatternInstrumenterTest.kt b/plugins/IntelliLang/intellilang-jps-plugin/test/org/jetbrains/jps/intellilang/instrumentation/PatternInstrumenterTest.kt index b7be87daae4f..e642847dce78 100644 --- a/plugins/IntelliLang/intellilang-jps-plugin/test/org/jetbrains/jps/intellilang/instrumentation/PatternInstrumenterTest.kt +++ b/plugins/IntelliLang/intellilang-jps-plugin/test/org/jetbrains/jps/intellilang/instrumentation/PatternInstrumenterTest.kt @@ -95,8 +95,10 @@ class PatternInstrumenterTest { @Test fun enclosingClass() { val testClass = loadClass() - val obj = testClass.getMethod("enclosingClass").invoke(null) - assertEquals(testClass, obj::class.java.enclosingClass) + val obj1 = testClass.getMethod("enclosingStatic").invoke(null) + assertEquals(testClass, obj1::class.java.enclosingClass) + val obj2 = testClass.getMethod("enclosingInstance").invoke(testClass.newInstance()) + assertEquals(testClass, obj2::class.java.enclosingClass) } @Test fun capturedParam() { diff --git a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$1.class b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$1.class index 628caec78b8a..eb4329aa683f 100644 Binary files a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$1.class and b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$1.class differ diff --git a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$1Local.class b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$1Local.class index 06e9c95c360a..35afe5f2f24a 100644 Binary files a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$1Local.class and b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$1Local.class differ diff --git a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$2.class b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$2.class new file mode 100644 index 000000000000..f2b7df6abbdb Binary files /dev/null and b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$2.class differ diff --git a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$A.class b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$A.class index a8c842390297..0324320063e0 100644 Binary files a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$A.class and b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$A.class differ diff --git a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$B.class b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$B.class index a8290c41121b..2dcc840a159e 100644 Binary files a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$B.class and b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$B.class differ diff --git a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$Inner.class b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$Inner.class index 8df09983fbf0..4f12f231a298 100644 Binary files a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$Inner.class and b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$Inner.class differ diff --git a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$Nested.class b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$Nested.class index b1641edc57bb..c8fb345dc8b5 100644 Binary files a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$Nested.class and b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass$Nested.class differ diff --git a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass.class b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass.class index a473ed7f364e..fa68fd67797f 100644 Binary files a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass.class and b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass.class differ diff --git a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass.java b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass.java index 62cb646aaf7d..4c0e7c569413 100644 --- a/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass.java +++ b/plugins/IntelliLang/intellilang-jps-plugin/testData/patternInstrumenter/TestClass.java @@ -41,9 +41,17 @@ public class TestClass { a.get("-"); } - public static Object enclosingClass() { + public static Object enclosingStatic() { return new Object() { - void foo(@Pattern("\\d+") String s) { } + public void foo(@Pattern("\\d+") String s) { } + }; + } + + public Object enclosingInstance() { + return new Object() { + public boolean foo(@Pattern("\\d+") String s) { + return s.contains(TestClass.this.toString()); + } }; }