|
|
|
[
Permlink
| « Hide
]
Eugene Vigdorchik - 03 Jan 07 16:26
This is a bug in compiler generating wrong parameter annotations. I currently don't see a way to fix this. We should know somehow, that it is an inner class and that it is not static. None of this information is written to class file.
It's probably debatable whether this is a compiler bug. I tested it with the Eclipse compiler and it reports the same indices for parameter annotations. Anyway, here's how I think this could be fixed. The key is the ASM-method "visitInnerClass". See the following rough fragment from my IntelliLang-implementation (which should be sufficiently similar to the @NotNull one):
class Instrumenter extends ClassAdapter { boolean myIsNonStaticInnerClass; public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { super.visit(version, access, name, signature, superName, interfaces); myClassName = name; } public void visitInnerClass(String name, String outerName, String innerName, int access) { super.visitInnerClass(name, outerName, innerName, access); if (myClassName.equals(name)) { myIsNonStaticInnerClass = (access & ACC_STATIC) == 0; } } ... } class InstrumentationAdapter extends MethodAdapter { Instrumenter myInstrumenter; public void visitCode() { for (PatternValue parameter : myParameterPatterns) { int j; if ((myAccess & Opcodes.ACC_STATIC) == 0) { // special case: ctor of non-static inner classes (see IDEA-10889) if ("<init>".equals(myMethodName)) { j = (myInstrumenter.myIsNonStaticInnerClass) ? 1 + myArgTypes[0].getSize() // skip first (synthetic) "Outer.this" parameter : 1; } else { j = 1; } } else { j = 0; } for (int l = 0; l < parameter.index; l++) { j += myArgTypes[l].getSize(); } ... } } } At least it seems to work for all kinds of weird inner-class constructs Oops, I missed that InnerClasses attribute is written to both outer and inner class files. That would certainly fix it, thank you, Sascha.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||