Project: JDT
Bug 144941 [reorg] NPE in ReorgPolicyFactory [refactoring]
Reported: 2006-06-01 15:00:08 | Status: verified fixed

1. Create a Java Project JavaProj 2. Create a Java Class JC1 in Package P1 3. Create a basic Project NonJavaProj 4. Select JC1.java in the Package Explorer and Refactor ... Move it using the context menu 5. On the Move wizard, select NonJavaProj as the destination. 6. Check the "Update fully qualified names in non-Java text files (forces preview)" option and click Preview. RESULT: Exceptions thrown. The root exception is ... java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory$MoveFilesFoldersAndCusPolicy.handleType(ReorgPolicyFactory.java:1935) at org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory$MoveFilesFoldersAndCusPolicy.computeQualifiedNameMatches(ReorgPolicyFactory.java:1925) at org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory$MoveFilesFoldersAndCusPolicy.checkFinalConditions(ReorgPolicyFactory.java:1946) at org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor.checkFinalConditions(JavaMoveProcessor.java:158) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:175) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:83) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:118) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1737) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113) If we do not perform Step 6 and still go to the preview page, things are fine and the refactoring completes successfully. Q1. Do we want to allow moving Java classes to non-Java Projects?? Q1a. If yes then the behavior should be consistent irrespective of whether the user performs Step 6 or not. Ideally, I would prefer if this Refactoring was disallowed in the main Move Wizard page itself.

Files changed in fix:
org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgPolicyFactory.java