Community
Participate
Working Groups
I20050104-1600 + ZRH plugin export 200501111141 (JDT Core v530b) java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0 at org.eclipse.jdt.core.compiler.CharOperation.pathMatch (CharOperation.java:1856) at org.eclipse.jdt.internal.compiler.util.Util.isExcluded(Util.java:488) at org.eclipse.jdt.internal.compiler.env.AccessRestriction.getViolatedRestriction (AccessRestriction.java:81) at org.eclipse.jdt.internal.core.SearchableEnvironment.find (SearchableEnvironment.java:113) at org.eclipse.jdt.internal.core.SearchableEnvironment.findType (SearchableEnvironment.java:198) at org.eclipse.jdt.internal.core.CancelableNameEnvironment.findType (CancelableNameEnvironment.java:45) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType (LookupEnvironment.java:119) at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage (PackageBinding.java:176) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findImport (CompilationUnitScope.java:371) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findSingleImport (CompilationUnitScope.java:424) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.resolveSingleImpo rt(CompilationUnitScope.java:586) at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage (Scope.java:2204) at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:1988) at org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding (SingleTypeReference.java:39) at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType (TypeReference.java:141) at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveSuperType (TypeReference.java:104) at org.eclipse.jdt.internal.compiler.lookup.ClassScope.findSupertype (ClassScope.java:1066) at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectSuperclass (ClassScope.java:725) at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy (ClassScope.java:861) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierar chy(CompilationUnitScope.java:243) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings (LookupEnvironment.java:195) at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:307) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve (CompilationUnitResolver.java:755) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve (CompilationUnitResolver.java:464) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:759) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:575) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST (ASTProvider.java:563) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST (ASTProvider.java:494) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartLis tenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:165) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run (SelectionListenerWithASTManager.java:142) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66)
The version of JDT Core is actually HEAD
From the stack trace, I'm not sure how this can happen. Do you have steps to reproduce ?
I am sorry, I can't give any specific details. It seems that only arbitrary source code from JDT UI which is opened in the java editor (from source) triggers the exception. The stack trace shows that AccessRestriction#getViolatedRestriction(..) receives an empty char array as target type name, but the following string operations are designed to handle either null or a non-empty array.
We could work around the problem, but it indicates a deeper problem as the path should never be of length 0.
Increased severity since I can't use I2005011-0800 for self hosting.
I got this with my development workspace when I started up I20050111-0800. I guess the problem is that external archives are not handled properly. In CancelableNameEnvironment(SearchableEnvironment).find(String, String) line: 113, I see this situation on startup: typeName= "IAdaptable" packageName= "org.eclipse.core.runtime" typePath= Path (/org.eclipse.core.runtime/runtime.jar) rootPath= Path (/org.eclipse.core.runtime/runtime.jar) type.getPath() of a binary type returns only the path of the archive, which happens to be the same as the path to the package fragment root. I have org.eclipse.core.runtime imported as binary project.
Workaround is to set preference Java>Compiler>Building>Type restriction>Access restriction violation to Ignore
Thanks Markus for the test case. Fixed SearchableEnvironment#find(String,String) and SearchableEnvironmentRequestor#acceptType(IType) to handle the case where the type comes from a jar. In this case, build a relative path (e.g. java/lang/Object.class). Added regression test ReconcilerTests#testAccessRestriction2().
*** Bug 82762 has been marked as a duplicate of this bug. ***
*** Bug 82842 has been marked as a duplicate of this bug. ***
Verified in I20050214-0927