diff --git a/java/java-tests/testData/compiler/notNullVerification/GroovyEnum.groovy b/java/java-tests/testData/compiler/notNullVerification/GroovyEnum.groovy new file mode 100644 index 000000000000..c6e26b0df8fd --- /dev/null +++ b/java/java-tests/testData/compiler/notNullVerification/GroovyEnum.groovy @@ -0,0 +1,9 @@ +// 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 + +@SuppressWarnings("unused") +enum GroovyEnum { + Value(null, "1"); + + GroovyEnum(String s1, @NotNull String s2) { } +} \ No newline at end of file diff --git a/java/java-tests/testData/compiler/notNullVerification/GroovyInnerClass.groovy b/java/java-tests/testData/compiler/notNullVerification/GroovyInnerClass.groovy new file mode 100644 index 000000000000..196b4f711f29 --- /dev/null +++ b/java/java-tests/testData/compiler/notNullVerification/GroovyInnerClass.groovy @@ -0,0 +1,12 @@ +import org.jetbrains.annotations.NotNull + +@SuppressWarnings("unused") +class GroovyInnerClass { + GroovyInnerClass() { + new Inner(null, "") + } + + private class Inner { + Inner(String s1, @NotNull String s2) { } + } +} \ 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 ca675438fb23..ee2c71351ccd 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 @@ -19,6 +19,7 @@ import org.junit.Test; import org.junit.rules.TestName; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; @@ -144,6 +145,12 @@ public class NotNullVerifyingInstrumenterTest { assertNotNull(testClass.getField("Value").get(null)); } + @Test + public void testGroovyEnum() throws Exception { + Class testClass = prepareTest(); + assertNotNull(testClass.getField("Value").get(null)); + } + @Test public void testStaticInnerClass() throws Exception { Class aClass = prepareTest(); @@ -156,6 +163,12 @@ public class NotNullVerifyingInstrumenterTest { assertNotNull(aClass.newInstance()); } + @Test + public void testGroovyInnerClass() throws Exception { + Class aClass = prepareTest(); + assertNotNull(aClass.newInstance()); + } + @Test public void testSkipBridgeMethods() throws Exception { Class testClass = prepareTest(); @@ -277,15 +290,29 @@ public class NotNullVerifyingInstrumenterTest { List cmdLine = ContainerUtil.newArrayList("-d", classesDir.getAbsolutePath(), "-classpath", testDir + "/annotations.jar"); if (withDebugInfo) cmdLine.add("-g"); - cmdLine.add(testDir + '/' + testName + ".java"); - com.sun.tools.javac.Main.compile(ArrayUtil.toStringArray(cmdLine)); - Class mainClass = null; + File testFile = new File(testDir, testName + ".java"); + if (testFile.exists()) { + cmdLine.add(testFile.getPath()); + com.sun.tools.javac.Main.compile(ArrayUtil.toStringArray(cmdLine)); + } + else { + testFile = new File(testDir, testName + ".groovy"); + if (testFile.exists()) { + cmdLine.add(testFile.getPath()); + org.codehaus.groovy.tools.FileSystemCompiler.main(ArrayUtil.toStringArray(cmdLine)); + } + else { + throw new FileNotFoundException("No test source for " + testName); + } + } + File[] files = classesDir.listFiles(); assertNotNull(files); Arrays.sort(files, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName())); boolean modified = false; MyClassLoader classLoader = new MyClassLoader(getClass().getClassLoader()); + Class mainClass = null; for (File file: files) { FailSafeClassReader reader = new FailSafeClassReader(FileUtil.loadFileBytes(file)); ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);