Community
Participate
Working Groups
I20071009-2225 In my code, I accidentally used JavaCore.create(handleIdentifier, null), although JavaCore#create(String, WorkingCopyOwner) does not allow the second parameter to be null. An ICompilationUnit was created with owner == null, which later lead to NPEs when it was used, e.g. here: Exception in thread "Info view input computer" java.lang.NullPointerException at org.eclipse.jdt.internal.core.CompilationUnit.equals(CompilationUnit.java:453) at org.eclipse.jdt.internal.core.JavaElement.equals(JavaElement.java:121) at org.eclipse.jdt.internal.core.SourceRefElement.equals(SourceRefElement.java:83) at org.eclipse.jdt.internal.core.SourceType.equals(SourceType.java:158) at org.eclipse.jdt.internal.ui.infoviews.AbstractInfoView.isIgnoringNewInput(AbstractInfoView.java:376) at org.eclipse.jdt.internal.ui.infoviews.JavadocView.isIgnoringNewInput(JavadocView.java:633) at org.eclipse.jdt.internal.ui.infoviews.AbstractInfoView$2.run(AbstractInfoView.java:537) The create(..,..) method should either allow null as owner (and replace it with DefaultWorkingCopyOwner.PRIMARY), or it should throw an NPE or an IllegalArgumentException in this case). Furthermore, the Javadoc is not fully correct: * @param owner the owner of the returned compilation unit, ignored if the * returned element is not a compilation unit => owner is only ignored if the element is not a CU *or an element inside a CU* (my call actually created an IType).
Created attachment 100433 [details] Proposed fix and regression test
Fix and test released for 3.5M1
Verified for 3.5M1 using I20080805-1307