Community
Participate
Working Groups
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.
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
A google search confirms that other projects had concurrency issues with ArrayList.toArray, too, e.g., bug 81675.
Never seen again. Consider fixed.