Bug 82542 - Internal error during AST creation
Summary: Internal error during AST creation
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 82762 82842 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-01-11 06:33 EST by Tobias Widmer CLA
Modified: 2005-02-15 07:54 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Widmer CLA 2005-01-11 06:33:32 EST
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)
Comment 1 Tobias Widmer CLA 2005-01-11 06:40:23 EST
The version of JDT Core is actually HEAD
Comment 2 Jerome Lanneluc CLA 2005-01-11 06:42:19 EST
From the stack trace, I'm not sure how this can happen. Do you have steps to
reproduce ?
Comment 3 Tobias Widmer CLA 2005-01-11 07:02:33 EST
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.
Comment 4 Jerome Lanneluc CLA 2005-01-11 07:23:01 EST
We could work around the problem, but it indicates a deeper problem as the path
should never be of length 0.
Comment 5 Dani Megert CLA 2005-01-11 11:07:50 EST
Increased severity since I can't use I2005011-0800 for self hosting.
Comment 6 Markus Keller CLA 2005-01-11 11:10:16 EST
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.
Comment 7 Jerome Lanneluc CLA 2005-01-11 11:31:23 EST
Workaround is to set preference Java>Compiler>Building>Type restriction>Access
restriction violation to Ignore
Comment 8 Jerome Lanneluc CLA 2005-01-11 13:21:09 EST
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().
Comment 9 Jerome Lanneluc CLA 2005-01-14 07:27:37 EST
*** Bug 82762 has been marked as a duplicate of this bug. ***
Comment 10 Jerome Lanneluc CLA 2005-01-14 10:00:15 EST
*** Bug 82842 has been marked as a duplicate of this bug. ***
Comment 11 David Audel CLA 2005-02-15 07:54:51 EST
Verified in I20050214-0927