Bug 272204 - null should never be part of a type hierarchy
Summary: null should never be part of a type hierarchy
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-14 14:40 EDT by Olivier Thomann CLA
Modified: 2009-04-28 12:34 EDT (History)
0 users

See Also:
jerome_lanneluc: review+


Attachments
Proposed fix (1.06 KB, patch)
2009-04-14 14:41 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2009-04-14 14:40:46 EDT
I got a NPE when trying to rename an interface method.
Investigating the issue I noticed that null can be put in a type hierarchy in the case this.builder.getHandle(this.typeModels[t], interfaceBinding); return null.
See org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.findSuperInterfaces(IGenericType, ReferenceBinding)

I could not end up creating a small test case that exhibits the problem, but I have a workspace that is broken because of this.

Here is the stack trace I got:
...
Root exception:
java.lang.NullPointerException
at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.isInterface(TypeHierarchy.java:1042)
at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.getSuperclass(TypeHierarchy.java:656)
at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.getSupertypes(TypeHierarchy.java:675)
at org.eclipse.jdt.internal.corext.refactoring.rename.RippleMethodFinder2.uniteWithSupertypes(RippleMethodFinder2.java:397)
at org.eclipse.jdt.internal.corext.refactoring.rename.RippleMethodFinder2.uniteWithSupertypes(RippleMethodFinder2.java:403)
at org.eclipse.jdt.internal.corext.refactoring.rename.RippleMethodFinder2.createUnionFind(RippleMethodFinder2.java:384)
at org.eclipse.jdt.internal.corext.refactoring.rename.RippleMethodFinder2.findAllRippleMethods(RippleMethodFinder2.java:196)
at org.eclipse.jdt.internal.corext.refactoring.rename.RippleMethodFinder2.getAllRippleMethods(RippleMethodFinder2.java:168)
at org.eclipse.jdt.internal.corext.refactoring.rename.RippleMethodFinder2.getRelatedMethods(RippleMethodFinder2.java:161)
at org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor.initializeMethodsToRename(RenameMethodProcessor.java:236)
at org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor.doCheckFinalConditions(RenameMethodProcessor.java:360)
at org.eclipse.jdt.internal.corext.refactoring.rename.RenameVirtualMethodProcessor.doCheckFinalConditions(RenameVirtualMethodProcessor.java:143)
at org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor.checkFinalConditions(JavaRenameProcessor.java:46)
at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:224)
at org.eclipse.ltk.core.refactoring.Refactoring.checkAllConditions(Refactoring.java:160)
at org.eclipse.jdt.internal.ui.refactoring.RefactoringExecutionHelper$Operation.run(RefactoringExecutionHelper.java:80)
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4662)
at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:106)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Comment 1 Olivier Thomann CLA 2009-04-14 14:41:53 EDT
Created attachment 131823 [details]
Proposed fix

Possible fix?
Jérôme, please review.
Comment 2 Olivier Thomann CLA 2009-04-14 14:44:35 EDT
I believe the problem comes from the fact that the type org.eclipse.jdt.launching.sourcelookup.containers.JavaSourcePathComputer has also a method getId().

I tried to rename a method getId() to getTimestamp().

No idea why that unrelated type is checked, but this is causing the NPE.

Surprisingly enough, I can properly open the type hierarchy for org.eclipse.jdt.launching.sourcelookup.containers.JavaSourcePathComputer without getting an exception with or without the patch. 
Comment 3 Olivier Thomann CLA 2009-04-17 11:03:14 EDT
Would be nice to get this reviewed for 3.5M7.
Comment 4 Jerome Lanneluc CLA 2009-04-17 11:21:26 EDT
Fix looks good. A regression test would be awesome.
Comment 5 Olivier Thomann CLA 2009-04-27 07:59:12 EDT
I could not extract a regression test so far. I'll release the fix today as this is fixing a real bug.
Comment 6 Olivier Thomann CLA 2009-04-27 16:32:55 EDT
Released patch for 3.5M7.
No regression test so far.
Comment 7 Kent Johnson CLA 2009-04-28 12:34:22 EDT
Verified for 3.5M7 by reading the code