Bug 186749 - CCE in Scope.findMemberType
Summary: CCE in Scope.findMemberType
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-14 04:11 EDT by Martin Aeschlimann CLA
Modified: 2007-05-16 09:38 EDT (History)
0 users

See Also:


Attachments
Proposed patch (2.29 KB, patch)
2007-05-14 10:14 EDT, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2007-05-14 04:11:22 EDT
20070512-0010

- change to a 6.0 JDK as workspace JRE
- create a project with 6.0 compliance and the following content:

package a;
public class Try {
    void m(Object var) {
        if (1==1 && var.equals(1)) {

        }
    }
}

- select 'var.equals(1)' and invoke 'refactor > introduce indirection'

java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMemberType(Scope.java:954)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2408)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getPackage(Scope.java:2088)
	at org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference.getTypeBinding(QualifiedTypeReference.java:69)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:163)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveSuperType(TypeReference.java:114)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.findSupertype(ClassScope.java:1116)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectSuperInterfaces(ClassScope.java:909)
	at org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:955)
	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:290)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:220)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1012)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1078)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1199)
	at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:217)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:502)
	at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:550)
	at org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine2.searchPattern(RefactoringSearchEngine2.java:473)
	at org.eclipse.jdt.internal.corext.refactoring.rename.RippleMethodFinder2.findAllDeclarations(RippleMethodFinder2.java:295)
	at org.eclipse.jdt.internal.corext.refactoring.rename.RippleMethodFinder2.getAllRippleMethods(RippleMethodFinder2.java:144)
	at org.eclipse.jdt.internal.corext.refactoring.rename.RippleMethodFinder2.getRelatedMethods(RippleMethodFinder2.java:132)
	at org.eclipse.jdt.internal.corext.refactoring.code.IntroduceIndirectionRefactoring.updateReferences(IntroduceIndirectionRefactoring.java:605)
	at org.eclipse.jdt.internal.corext.refactoring.code.IntroduceIndirectionRefactoring.checkFinalConditions(IntroduceIndirectionRefactoring.java:499)
Comment 1 Philipe Mulet CLA 2007-05-14 06:31:59 EDT
Looking at the trace, it seems the problem comes from a distinct unit (which has a qualified super type reference). 

Comment 2 Philipe Mulet CLA 2007-05-14 06:34:12 EDT
In runtime workbench, the refactoring action took minutes to perform, and didn't crash in the end.
Comment 3 Philipe Mulet CLA 2007-05-14 06:38:45 EDT
Reproduced only if using a JRE 6.0 lib on the buildpath.
i.e.
java version "1.6.0_02-ea"
Java(TM) SE Runtime Environment (build 1.6.0_02-ea-b02)
Java HotSpot(TM) Client VM (build 1.6.0_02-ea-b02, mixed mode)
Comment 4 Philipe Mulet CLA 2007-05-14 06:39:59 EDT
Offending unit is Font.class (from searching with source attached).
Comment 5 Philipe Mulet CLA 2007-05-14 06:55:41 EDT
java.awt.Font is trying to connect super-interface "java.io.Serializable"

It tries to look for a member type "java" through static import:
import : sun.font.EAttribute.*

Comment 6 Philipe Mulet CLA 2007-05-14 10:14:00 EDT
Created attachment 67056 [details]
Proposed patch
Comment 7 Philipe Mulet CLA 2007-05-14 10:15:18 EDT
Could reproduce original issue (using refactoring), but unable to write a regression test. 

Comment 8 Philipe Mulet CLA 2007-05-14 12:33:43 EDT
Kent - once patch is reviewed, please release it.

Still need to produce some regression test.
Comment 9 Kent Johnson CLA 2007-05-14 12:48:31 EDT
Released change to Scope in HEAD
Comment 10 Kent Johnson CLA 2007-05-15 11:07:38 EDT
Had no luck trying to narrow down a testcase, but the fix is obviously necessary.
Comment 11 Eric Jodet CLA 2007-05-16 06:22:03 EDT
Verified for 3.3 RC1 using build I20070516-0010