Community
Participate
Working Groups
In Eclipse, you can right-click on a class and choose "Source -> Override/implement methods" and then check the methods you want to override. It works fine for the normal case. But if you want to override methods in a class contained within a method's body, Eclipse throws an error dialog. See attachment for a screenshot. "Operation not supported for specified element type" To reproduce: 1. Create a class like the following. package com.avaya.ic.vesp; public class DummyClass { public void myTest() { class Blah extends Object { } } } 2. Right-click on "Blah" and choose Source --> Override/Implement methods. 3. Choose a method to override (i.e. "hashCode") 4. Get an error dialog.
Created attachment 16641 [details] Screenshot of error
Can you please specify the build number you are you using ?
Reproduced with 200412142000. Move to JDT/UI for investigation.
Move back to JDT/Core since the problem seems to come from the underlying operation. !ENTRY org.eclipse.jdt.ui 4 10001 2004-12-15 11:02:35.748 !MESSAGE Internal Error !STACK 1 Java Model Exception: Java Model Status [Operation not supported for specified element type(s):Blah [in myTest() [in DummyClass [in [Working copy] DummyClass.java [in <default> [in src [in P]]]]]]] at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:735) at org.eclipse.jdt.internal.core.SourceType.createMethod(SourceType.java:140) at org.eclipse.jdt.internal.corext.codemanipulation.AddUnimplementedMethodsOperation.run(AddUnimplementedMethodsOperation.java:82) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1674) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3672) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:65) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:322) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:269) at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:624) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:621) at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:1949) at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:1061) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.ui.internal.progress.ProgressManager.runInUI(ProgressManager.java:1057) at org.eclipse.jdt.ui.actions.OverrideMethodsAction.run(OverrideMethodsAction.java:239) at org.eclipse.jdt.ui.actions.OverrideMethodsAction.run(OverrideMethodsAction.java:153) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:989) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:555) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:505) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:419) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2803) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2448) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1569) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1540) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:285) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:220) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129) 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.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:684) at org.eclipse.core.launcher.Main.main(Main.java:668) !SUBENTRY 1 org.eclipse.jdt.core 4 967 2004-12-15 11:02:35.748 !MESSAGE Operation not supported for specified element type(s):Blah [in myTest() [in DummyClass [in [Working copy] DummyClass.java [in <default> [in src [in P]]]]]]
This kind of operation is not supported for local and anonymous class.
Java model operations are to be rewritten using AST rewrite.
*** This bug has been marked as a duplicate of 43483 ***