Bug 96583 - Sort Members throws an NPE with multiple static blocks
Summary: Sort Members throws an NPE with multiple static blocks
Status: VERIFIED DUPLICATE of bug 95388
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-25 06:03 EDT by peter.bright CLA
Modified: 2005-05-27 06:47 EDT (History)
0 users

See Also:


Attachments
Problematic file (123 bytes, application/octet-stream)
2005-05-25 06:05 EDT, peter.bright CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description peter.bright CLA 2005-05-25 06:03:27 EDT
My preferred member sort order places static blocks above methods.  If I have 
one static block in a class, sorting it works fine.  If I have more than one, 
I get a stack trace thus:
!ENTRY org.eclipse.ui 4 0 2005-05-25 10:52:18.180
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
	at 
org.eclipse.jdt.internal.corext.codemanipulation.SortMembersOperation$DefaultJa
vaElementComparator.compare(SortMembersOperation.java:182)
	at java.util.Arrays.mergeSort(Arrays.java:1284)
	at java.util.Arrays.sort(Arrays.java:1223)
	at java.util.Collections.sort(Collections.java:159)
	at org.eclipse.jdt.internal.core.SortElementsOperation$1.visit
(SortElementsOperation.java:174)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0
(TypeDeclaration.java:466)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
	at org.eclipse.jdt.core.dom.CompilationUnit.accept0
(CompilationUnit.java:299)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
	at org.eclipse.jdt.internal.core.SortElementsOperation.processElement
(SortElementsOperation.java:122)
	at org.eclipse.jdt.internal.core.SortElementsOperation.executeOperation
(SortElementsOperation.java:86)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run
(JavaModelOperation.java:718)
	at org.eclipse.core.internal.resources.Workspace.run
(Workspace.java:1716)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation
(JavaModelOperation.java:782)
	at org.eclipse.jdt.core.util.CompilationUnitSorter.sort
(CompilationUnitSorter.java:174)
	at 
org.eclipse.jdt.internal.corext.codemanipulation.SortMembersOperation.run
(SortMembersOperation.java:260)
	at org.eclipse.jdt.internal.core.BatchOperation.executeOperation
(BatchOperation.java:39)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run
(JavaModelOperation.java:718)
	at org.eclipse.core.internal.resources.Workspace.run
(Workspace.java:1716)
	at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3680)
	at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run
(WorkbenchRunnableAdapter.java:87)
	at 
org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.inte
rnalRun(BusyIndicatorRunnableContext.java:113)
	at 
org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run
(BusyIndicatorRunnableContext.java:80)
	at org.eclipse.swt.custom.BusyIndicator.showWhile
(BusyIndicator.java:69)
	at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run
(BusyIndicatorRunnableContext.java:126)
	at org.eclipse.ui.internal.progress.ProgressManager$5.run
(ProgressManager.java:1089)
	at org.eclipse.swt.custom.BusyIndicator.showWhile
(BusyIndicator.java:69)
	at org.eclipse.ui.internal.progress.ProgressManager.runInUI
(ProgressManager.java:1085)
	at org.eclipse.jdt.ui.actions.SortMembersAction.run
(SortMembersAction.java:222)
	at org.eclipse.jdt.ui.actions.SortMembersAction.run
(SortMembersAction.java:141)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun
(SelectionDispatchAction.java:222)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run
(SelectionDispatchAction.java:198)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:996)
	at 
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:538)
	at org.eclipse.jface.action.ActionContributionItem.access$2
(ActionContributionItem.java:488)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent
(ActionContributionItem.java:400)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2921)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2554)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1601)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1565)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench
(Workbench.java:315)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run
(IDEApplication.java:103)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run
(PlatformActivator.java:230)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:371)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:160)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:330)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:274)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)

I'm using 3.1M7 on Windows XPSP2 with JDK 1.5.0_02.
Comment 1 peter.bright CLA 2005-05-25 06:05:13 EDT
Created attachment 21708 [details]
Problematic file

Sorting members on the attached file NPEs.
Comment 2 Olivier Thomann CLA 2005-05-25 10:03:34 EDT
I will investigate.
Comment 3 Olivier Thomann CLA 2005-05-25 10:24:57 EDT

*** This bug has been marked as a duplicate of 95388 ***
Comment 4 Olivier Thomann CLA 2005-05-25 10:25:55 EDT
Added regression test in
org.eclipse.jdt.core.tests.model.SortCompilationUnitElementsTests.test027.
Comment 5 Frederic Fusier CLA 2005-05-27 06:47:25 EDT
Verified for 3.1 RC1 with build I20050527-0010.