Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352665 - [1.6][compiler] Internal compiler Error: ArrayIndexOutOfBoundsException when compiling certain classes with outer access error
Summary: [1.6][compiler] Internal compiler Error: ArrayIndexOutOfBoundsException when ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.7.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-20 15:42 EDT by Jakub CLA
Modified: 2012-09-20 04:37 EDT (History)
4 users (show)

See Also:


Attachments
Problem classes (2.12 KB, application/zip)
2011-07-20 15:45 EDT, Jakub CLA
no flags Details
Proposed fix + regression test (5.48 KB, patch)
2011-07-20 20:10 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub CLA 2011-07-20 15:42:38 EDT
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.
Comment 1 Jakub CLA 2011-07-20 15:45:16 EDT
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.
Comment 2 Olivier Thomann CLA 2011-07-20 17:22:27 EDT
The problem comes from the fact that the class ProfileInfo is not static. Making this class static fixes the error.
Investigating.
Comment 3 Olivier Thomann CLA 2011-07-20 20:10:35 EDT
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.
Comment 4 Olivier Thomann CLA 2011-07-20 20:10:55 EDT
Created attachment 200043 [details]
Proposed fix + regression test
Comment 5 Olivier Thomann CLA 2011-07-20 20:11:39 EDT
Srikanth, please review.
Comment 6 Olivier Thomann CLA 2011-07-20 20:12:27 EDT
Released in BETA_JAVA7 branch only in order to get it as part of the tomorrow's build.
Srikanth, please verify.
Comment 7 Ayushman Jain CLA 2011-08-02 10:01:31 EDT
Verified for 3.8M1 using build I20110729-1200
Comment 8 Fred Sauer CLA 2011-09-08 15:12:23 EDT
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
Comment 9 Olivier Thomann CLA 2011-09-08 15:17:56 EDT
I verified that this test case is also fixed in HEAD.