Community
Participate
Working Groups
Created attachment 251227 [details] Repro code. Just run and you'll get the exception. Repro case attached. Stack trace: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.fields(SourceTypeBinding.java:720) at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTypesForFieldsAndMethods(SourceTypeBinding.java:698) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(CompilationUnitScope.java:420) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1193) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:685) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1181) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:807) at com.company.HelloWorld.parseAndResolveSource(HelloWorld.java:29) at com.company.HelloWorld.main(HelloWorld.java:18) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) (yes, I created the repro in IntelliJ :) )
Thanks for the convenient repro! The problem is caused by very unhappy re-entrance during resolution of buggy code.
New Gerrit change created: https://git.eclipse.org/r/43050
Gerrit change https://git.eclipse.org/r/43050 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=841e5207182e4cce5a1b83b4f81bf082fd69694f
During a re-entrant call this.fields was shrunk to remove fields in error. The outer call, however, still used the old length as its loop boundary -> AIOOBE. Fixed by working on a pair of local variables, instead of a field + a local. As an optimization we could detect the situation and abort the outer fields() computation (because inner has already done all work), but since this would only help for error cases and probably helps only marginally, I don't think it's worth it. Released for 4.5 M6.
Wow, I'm seriously surprised it got fixed so fast... :D Awesome, thanks so much!!!
Verified for 4.5 M6 with build I20150317-2000
*** Bug 424900 has been marked as a duplicate of this bug. ***