Community
Participate
Working Groups
I20080513-2000 CompilationUnit#equals(Object) throws NPE if owner is null. Other places in the CU check owner for null. java.lang.NullPointerException at org.eclipse.jdt.internal.core.CompilationUnit.equals(CompilationUnit.java:488) at org.eclipse.jface.viewers.StructuredSelection.equals(StructuredSelection.java:142) at org.eclipse.ui.internal.util.Util.equals(Util.java:366) at org.eclipse.ui.internal.services.ActivePartSourceProvider.checkActivePart(ActivePartSourceProvider.java:191) at org.eclipse.ui.internal.services.ActivePartSourceProvider$2.windowDeactivated(ActivePartSourceProvider.java:125) at org.eclipse.ui.internal.Workbench$13.run(Workbench.java:824) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.ui.internal.Workbench.fireWindowDeactivated(Workbench.java:822) at org.eclipse.ui.internal.WorkbenchWindow$26.shellDeactivated(WorkbenchWindow.java:3008) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:104) ...
Steps (only do this in a runtime workbench, since it will put you in the vicious circle from bug 232036!): - paste to Package Explorer: package p; public class C { void m() { new java.util.List<URL>(); } } - open ASTView (with bindings recovery, using ASTParser.createAST) - select new java.util.List<URL>() - open type binding for ClassInstanceCreation - double-click the last element (the red "> CompilationUnit...") - click OK => you're trapped in bug 232036
Replacing this.owner.equals(other.owner) with Util.equalOrNull(this.owner, other.owner) solved the problem for me, but I'm not sure whether the owner should have been null in the first place.
Created attachment 100237 [details] Proposed fix and regression tests
Frederic can you please review?
Patch looks good: +1
*** Bug 232045 has been marked as a duplicate of this bug. ***
Fix and tests released for 3.4RC1
Verified for 3.4RC1 using I20080515-2000.