Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368600 - AIOOBE in OTJavaElement.getChildren()
Summary: AIOOBE in OTJavaElement.getChildren()
Status: VERIFIED FIXED
Alias: None
Product: Objectteams
Classification: Tools
Component: OTDT (show other bugs)
Version: 2.1   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-14 03:37 EST by Stephan Herrmann CLA
Modified: 2012-09-22 15:52 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2012-01-14 03:37:02 EST
I consistently get this exception when opening OT's CodeCompletionTest
in an editor:

java.lang.ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(Native Method)
	at java.util.ArrayList.toArray(ArrayList.java:328)
	at org.eclipse.objectteams.otdt.internal.core.OTJavaElement.getChildren(OTJavaElement.java:96)
	at org.eclipse.objectteams.otdt.internal.core.RoleType.getMethodMappings(RoleType.java:106)
	at org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.convert(SourceTypeConverter.java:575)
	at org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.convert(SourceTypeConverter.java:609)
	at org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.convert(SourceTypeConverter.java:186)
	at org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.buildCompilationUnit(SourceTypeConverter.java:109)
	at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.accept(CompilationUnitProblemFinder.java:121)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:235)
	at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:203)
	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findImport(CompilationUnitScope.java:710)
	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findSingleImport(CompilationUnitScope.java:764)
	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInImports(CompilationUnitScope.java:627)

Looking at the top frames this could mean two things: the list this.children
is corrupt, i.e., its elementData and size don't match or concurrent access
changes the length of the list while copying.
Comment 1 Stephan Herrmann CLA 2012-01-14 03:53:14 EST
Against a corrupt ArrayList I can do nothing (would that be a bug in
the JRE??). I'm not fully convinced that concurrency was the root cause
because the issue was reproduceable while the workbench was running, but
disappeared when I restarted the workbench.

Anyway, I'm adding synchronization on this.children to prevent the
concurrency issue in this location. 

Released via commit 488052484e419c2f0486117ba4a6ccbbc31832bd
Comment 2 Stephan Herrmann CLA 2012-01-14 04:14:39 EST
A google search confirms that other projects had concurrency issues
with ArrayList.toArray, too, e.g., bug 81675.
Comment 3 Stephan Herrmann CLA 2012-09-22 15:52:01 EDT
Never seen again. Consider fixed.