Community
Participate
Working Groups
Build Identifier: I20110613-1736 When compiling certain classes, I get "Internal compiler error: java.lang.ArrayIndexOutOfBoundsException: -1 at org.eclipse.jdt.internal.compiler.codegen.StackMapFrame.addStackItem(StackMapFrame.java: 92)" The stack trace: java.lang.ArrayIndexOutOfBoundsException: -1 at org.eclipse.jdt.internal.compiler.codegen.StackMapFrame.addStackItem(StackMapFrame.java:92) at org.eclipse.jdt.internal.compiler.ClassFile.traverse(ClassFile.java:5001) at org.eclipse.jdt.internal.compiler.ClassFile.generateStackMapTableAttribute(ClassFile.java:3363) at org.eclipse.jdt.internal.compiler.ClassFile.completeCodeAttributeForClinit(ClassFile.java:1332) at org.eclipse.jdt.internal.compiler.ast.Clinit.generateCode(Clinit.java:327) at org.eclipse.jdt.internal.compiler.ast.Clinit.generateCode(Clinit.java:109) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:543) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:612) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:359) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1187) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:681) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1175) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:801) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:544) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:537) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:480) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:470) at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:170) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:155) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Reproducible: Always Steps to Reproduce: I would enclose the files if I could. The problem seems to be caused by trying to call a nested class's constructor from within a static initializer, but not every case triggers the error.
Created attachment 200035 [details] Problem classes The three classes that causes the problem. Create a new project, add these classes to the source folder and compile.
The problem comes from the fact that the class ProfileInfo is not static. Making this class static fixes the error. Investigating.
Similar issue to bug 298250. Fix for bug 298250 was not sufficient. We actually needed to better detect wrong code generation during outer access emulation.
Created attachment 200043 [details] Proposed fix + regression test
Srikanth, please review.
Released in BETA_JAVA7 branch only in order to get it as part of the tomorrow's build. Srikanth, please verify.
Verified for 3.8M1 using build I20110729-1200
Here's a small repo case, which may be the same issue: ------------------------------------------------------------------ public class Outer { /* ought to be static */ class Inner { } static { if (System.getProperty("foo") == null) new Inner(); } } ------------------------------------------------------------------ Triggers: java.lang.ArrayIndexOutOfBoundsException: -1 at org.eclipse.jdt.internal.compiler.ClassFile.traverse(ClassFile.java:5133) at org.eclipse.jdt.internal.compiler.ClassFile.generateStackMapTableAttribute(ClassFile.java:3363) at org.eclipse.jdt.internal.compiler.ClassFile.completeCodeAttributeForClinit(ClassFile.java:1332) at org.eclipse.jdt.internal.compiler.ast.Clinit.generateCode(Clinit.java:327) at org.eclipse.jdt.internal.compiler.ast.Clinit.generateCode(Clinit.java:109) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:543) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:612) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:359) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1187) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:681) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1175) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:801) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:544) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:537) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:480) at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:170) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:155) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) eclipse.buildId=I20110613-1736 java.version=1.6.0_26 java.vendor=Apple Inc. BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US Framework arguments: -product org.eclipse.epp.package.jee.product -keyring /Users/fredsa/.eclipse_keyring -showlocation Command-line arguments: -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.jee.product -keyring /Users/fredsa/.eclipse_keyring -showlocation
I verified that this test case is also fixed in HEAD.