Bug 560778 - Wrong error message when evaluating expression with anonymous class defined within a method call
Summary: Wrong error message when evaluating expression with anonymous class defined w...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.12   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-04 09:10 EST by Simeon Andreev CLA
Modified: 2024-03-04 08:18 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simeon Andreev CLA 2020-03-04 09:10:30 EST
I have a breakpoint at the start of "org.eclipse.debug.internal.ui.viewers.model.TreeModelContentProvider.modelChanged(IModelDelta, IModelProxy)", while debugging some CDT launch (a Java application would be the same).

I tried to evaluate the following expression in the Debug Shell view:

		delta.accept(new org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDeltaVisitor() {
			@Override
			public boolean visit(org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta d, int depth) {
				if (d.getElement() != null) {
					System.out.println(d.getElement().getClass());
				} else {
					System.out.println("null"); //$NON-NLS-1$
				}                
				return true;
			}
		});

I got a message about an error at the return statement. I copied my code to TreeModelContentProvider.modelChanged() (in another IDE, where I had sources), there were no such errors.

Then I tried to define an anonymous class outside of the accept() method, then the evaluation told me this is not allowed:

	Evaluation failed. Reason(s):
		Anonymous type declaration cannot be used in an evaluation expression
		Constructor of a local type cannot be used in an evaluation expression

Would have been nice to know this right away.
Comment 1 Simeon Andreev CLA 2020-03-04 09:20:49 EST
Of course, it would be better still if this type of code would work inside an evaluation. Visitor patterns are not that uncommon.
Comment 2 Eclipse Genie CLA 2022-02-23 08:55:37 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Eclipse Genie CLA 2024-03-04 08:18:44 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.