Bug 567705 - [1.8] Unable to inspect code: Compile error during code evaluation
Summary: [1.8] Unable to inspect code: Compile error during code evaluation
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.18   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-08 05:55 EDT by Noopur Gupta CLA
Modified: 2022-12-04 15:53 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Noopur Gupta CLA 2020-10-08 05:55:09 EDT
I20201006-1800

- Add a breakpoint on line 89 in org.eclipse.jdt.internal.ui.javaeditor.codemining.JavaReferenceCodeMining.doResolve(ITextViewer viewer, IProgressMonitor monitor).

- Ctrl-click on a code mining "1 reference" annotation in debug so that the above breakpoint is hit.

- Select the entire expression in "if" and press Cmd+Shift+I to inspect.

=> Inspect popup is not shown and we have a warning in error log about compile error:

Compile error during code evaluation: Only the first formal parameter may be declared explicitly as 'this'
Comment 1 Noopur Gupta CLA 2020-10-08 05:57:14 EDT
At the same line when breakpoint is hit, if you don't select anything and just press Cmd+Shift+I to inspect, we get an error dialog and this exception in error log:

Evaluation failed. Reason(s):
Index -1 out of bounds for length 0

java.lang.reflect.InvocationTargetException
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:397)
	at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:468)

...

Caused by: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 0
	at org.eclipse.jdt.internal.debug.eval.ast.engine.EvaluationSourceGenerator.getCompleteSnippet(EvaluationSourceGenerator.java:145)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.EvaluationSourceGenerator.<init>(EvaluationSourceGenerator.java:70)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.getCompiledExpression(ASTEvaluationEngine.java:367)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.evaluate(ASTEvaluationEngine.java:149)
	at org.eclipse.jdt.internal.debug.ui.actions.EvaluateAction$1.run(EvaluateAction.java:261)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Comment 2 Noopur Gupta CLA 2020-10-08 08:02:27 EDT
Looks like a problem in lambda debugging.

I was able to debug this code after converting both lambdas to anonymous classes.
Comment 3 Gayan Perera CLA 2020-10-11 16:18:41 EDT
Hi Nooopur,

Can you provide a simple sample code to reproduce this error ? It will be easy to debug the jdt with running a simple code example.
Comment 4 Noopur Gupta CLA 2020-10-13 05:20:12 EDT
(In reply to Noopur Gupta from comment #0)
> I20201006-1800
> 
> - Add a breakpoint on line 89 in
> org.eclipse.jdt.internal.ui.javaeditor.codemining.JavaReferenceCodeMining.doResolve(ITextViewer
> viewer, IProgressMonitor monitor).

I don't think I can provide a simplified code for this as I am seeing the problem here.

> - Ctrl-click on a code mining "1 reference" annotation in debug so that the
> above breakpoint is hit.

package p;

public class C {
	public static void main(String[] args) {
		new X();
	}
}

class X {
	
}

Here, class X has "1 reference" annotation when code minings are enabled. Ctrl+click on that to reproduce the bug.
Comment 5 Noopur Gupta CLA 2020-10-13 05:21:36 EDT
Is this a regression in 4.18 M1 or also present in 4.17?
Comment 6 Gayan Perera CLA 2020-10-13 09:43:21 EDT
Isn’t this reproduced able with a sample code other than using the code mining code as the test bench ?
Comment 7 Noopur Gupta CLA 2020-10-19 03:14:37 EDT
(In reply to Gayan Perera from comment #6)
> Isn’t this reproduced able with a sample code other than using the code
> mining code as the test bench ?
I haven't tried/seen it with any sample code.
Comment 8 Sarika Sinha CLA 2020-11-18 00:13:40 EST
This is not a regression, even 4.16 has the same behaviour.

But I get a different error:
	Evaluation failed. Reason(s):
		Evaluations must contain either an expression or a block of well-formed statements
Comment 9 Christian Dietrich CLA 2020-12-09 12:42:56 EST
i see the same/a similar problem

java.lang.reflect.InvocationTargetException
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:397)
	at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:468)
	at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:228)
	at org.eclipse.ui.internal.progress.ProgressManager.lambda$26(ProgressManager.java:821)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:74)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:854)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:830)
	at org.eclipse.jdt.internal.debug.ui.actions.EvaluateAction.run(EvaluateAction.java:279)
	at org.eclipse.jdt.internal.debug.ui.actions.DisplayAction.run(DisplayAction.java:113)
	at org.eclipse.jdt.internal.debug.ui.actions.EvaluateAction.run(EvaluateAction.java:597)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:239)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:580)
	at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:414)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4439)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1512)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1535)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1520)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1324)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4226)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3843)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1157)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1461)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 0
	at org.eclipse.jdt.internal.debug.eval.ast.engine.EvaluationSourceGenerator.getCompleteSnippet(EvaluationSourceGenerator.java:145)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.EvaluationSourceGenerator.<init>(EvaluationSourceGenerator.java:70)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.getCompiledExpression(ASTEvaluationEngine.java:368)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.evaluate(ASTEvaluationEngine.java:150)
	at org.eclipse.jdt.internal.debug.ui.actions.EvaluateAction$1.run(EvaluateAction.java:261)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Root exception:
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 0
	at org.eclipse.jdt.internal.debug.eval.ast.engine.EvaluationSourceGenerator.getCompleteSnippet(EvaluationSourceGenerator.java:145)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.EvaluationSourceGenerator.<init>(EvaluationSourceGenerator.java:70)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.getCompiledExpression(ASTEvaluationEngine.java:368)
	at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.evaluate(ASTEvaluationEngine.java:150)
	at org.eclipse.jdt.internal.debug.ui.actions.EvaluateAction$1.run(EvaluateAction.java:261)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Comment 10 Christian Dietrich CLA 2020-12-09 12:49:49 EST
can reliably be reproduced
with

	public static void main(String[] args) throws IOException {
		EcoreFactory factory = EcoreFactory.eINSTANCE;
		EcorePackage ecore = EcorePackage.eINSTANCE;
		
		EPackage ePackage = factory.createEPackage();
		ePackage.setName("mypack");
		ePackage.setNsPrefix("mypack");
		ePackage.setNsURI("https://www.itemis.de/mypack");
		
		EClass node = factory.createEClass();
		node.setName("Node");
		EAttribute name = factory.createEAttribute();

and rightklick+inspect after the =

i also get this when selecting display on some of the variables
but can not relate this reliably yet
Comment 11 Eclipse Genie CLA 2022-12-04 15:53:07 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.