Bug 169358 - Compiler crashes when accessing final variable from anonymous inner class
Summary: Compiler crashes when accessing final variable from anonymous inner class
Status: VERIFIED DUPLICATE of bug 168665
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.2   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-02 13:51 EST by Tobias Riemenschneider CLA
Modified: 2007-01-16 06:53 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Riemenschneider CLA 2007-01-02 13:51:51 EST
Build ID: I20061214-1445

Steps To Reproduce:
1. Switch to compiler compliance level 6.0.

2. Create the following class in a Java project
> CompilerErrorTest.java >>>
public class CompilerErrorTest {
  static class Worker {
    Worker(long i) {}
  }
  void doit() {
    final Object o = new Object();
    Worker w = new Worker(0) {
      public void work() {
        o.toString();
      }
    };
  }
}
< CompilerErrorTest.java <<<

3. Try to compile it and enjoy the compiler error
####
Severity and Description	Path	Resource	Location	Creation Time	Id
Internal compiler error
java.lang.ArrayIndexOutOfBoundsException: 4
	at org.eclipse.jdt.internal.compiler.codegen.StackMapFrameCodeStream.getLocal(StackMapFrameCodeStream.java:771)
	at org.eclipse.jdt.internal.compiler.codegen.StackMapFrameCodeStream.aload(StackMapFrameCodeStream.java:93)
	at org.eclipse.jdt.internal.compiler.codegen.CodeStream.load(CodeStream.java:5247)
	at org.eclipse.jdt.internal.compiler.codegen.CodeStream.load(CodeStream.java:5147)
	at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.generateSyntheticFieldInitializationsIfNecessary(ConstructorDeclaration.java:226)
	at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.internalGenerateCode(ConstructorDeclaration.java:286)
	at org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration.generateCode(ConstructorDeclaration.java:179)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:530)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:564)
	at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.generateCode(QualifiedAllocationExpression.java:145)
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.generateCode(LocalDeclaration.java:109)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:229)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:176)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:530)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:581)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:215)
	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:605)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:415)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:301)
	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:213)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:238)
	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:59)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:254)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:175)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:621)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:163)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:194)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:243)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:299)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:331)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:156)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:222)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
	test/src	CompilerErrorTest.java	line 0	1167763331453	35
####

More information:
The compiler error vanishes when the constructor Worker has no parameter or when the parameter is a long or double value.

Switching the compiler compliance level remove also the compiler error.
Comment 1 Kent Johnson CLA 2007-01-02 15:44:38 EST

*** This bug has been marked as a duplicate of bug 168665 ***
Comment 2 Frederic Fusier CLA 2007-01-16 06:53:37 EST
Verified for 3.2.2 using build M20070112-1200.