mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-183167 @NotNull on anonymous class breaks getEnclosingClass
This commit is contained in:
+2
-5
@@ -61,7 +61,7 @@ public class NotNullVerifyingInstrumenter extends ClassVisitor implements Opcode
|
||||
NotNullVerifyingInstrumenter instrumenter = new NotNullVerifyingInstrumenter(writer, reader, notNullAnnotations);
|
||||
reader.accept(instrumenter, 0);
|
||||
instrumenter.myAuxGenerator.generateReportingMethod(writer);
|
||||
return instrumenter.isModification();
|
||||
return instrumenter.myIsModification;
|
||||
}
|
||||
|
||||
private static Map<String, Map<Integer, String>> getAllParameterNames(ClassReader reader) {
|
||||
@@ -103,10 +103,6 @@ public class NotNullVerifyingInstrumenter extends ClassVisitor implements Opcode
|
||||
return methodParamNames;
|
||||
}
|
||||
|
||||
public boolean isModification() {
|
||||
return myIsModification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||
super.visit(version, access, name, signature, superName, interfaces);
|
||||
@@ -116,6 +112,7 @@ public class NotNullVerifyingInstrumenter extends ClassVisitor implements Opcode
|
||||
|
||||
@Override
|
||||
public void visitOuterClass(String owner, String name, String desc) {
|
||||
super.visitOuterClass(owner, name, desc);
|
||||
myInner = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EnclosingClass {
|
||||
public static Object main() {
|
||||
return new Object() {
|
||||
void foo(@NotNull String s) {}
|
||||
};
|
||||
}
|
||||
}
|
||||
+6
@@ -207,6 +207,12 @@ public class NotNullVerifyingInstrumenterTest extends UsefulTestCase {
|
||||
verifyCallThrowsException("Argument 0 for @NotNull parameter of MalformedBytecode$NullTest2.handle must not be null", null, testClass.getMethod("main"));
|
||||
}
|
||||
|
||||
public void testEnclosingClass() throws Exception {
|
||||
Class<?> testClass = prepareTest();
|
||||
Object obj = testClass.getMethod("main").invoke(null);
|
||||
assertEquals(testClass, obj.getClass().getEnclosingClass());
|
||||
}
|
||||
|
||||
public void testLocalClassImplicitParameters() throws Exception {
|
||||
Class<?> test = prepareTest(true, "NotNull");
|
||||
Object instance = test.newInstance();
|
||||
|
||||
Reference in New Issue
Block a user