Skip to content

Variable Navigation throwing NPE and support for lambda#715

Merged
SougandhS merged 1 commit intoeclipse-jdt:masterfrom
subyssurendran666:NPE_in_variable_navigation_712
Jul 7, 2025
Merged

Variable Navigation throwing NPE and support for lambda#715
SougandhS merged 1 commit intoeclipse-jdt:masterfrom
subyssurendran666:NPE_in_variable_navigation_712

Conversation

@subyssurendran666
Copy link
Copy Markdown
Contributor

@subyssurendran666 subyssurendran666 commented Jun 9, 2025

Variable Navigation throwing NPE and support for variable navigation in lambda for non-java projects

Fix: #712

What it does

How to test

  1. Open child Eclipse and import JDT.Debug project (Go to Project explorer -> Right click then import -> General -> Projects from Folder or Archive -> select the project from file explorer)
  2. Open third third eclipse from the second one.
  3. Create a java project from the third child and debug the code snippet provided in the parent ticket.
  4. Place breakpoint and then Navigate to Decoration from the variables view.

Author checklist

@subyssurendran666 subyssurendran666 force-pushed the NPE_in_variable_navigation_712 branch 2 times, most recently from 7ad4d31 to af0ddda Compare June 9, 2025 07:03
@subyssurendran666 subyssurendran666 changed the title Variable Navigation throwing NPE Variable Navigation throwing NPE and support for variable navigation in lambda Jun 9, 2025
@subyssurendran666 subyssurendran666 force-pushed the NPE_in_variable_navigation_712 branch from af0ddda to 530252e Compare June 9, 2025 08:01
@SougandhS SougandhS changed the title Variable Navigation throwing NPE and support for variable navigation in lambda Variable Navigation throwing NPE and support for lambda Jun 9, 2025
@SougandhS
Copy link
Copy Markdown
Member

SougandhS commented Jun 10, 2025

Lamda issue is fixed but doing navigation on BinaryTypes eg Thread.class it throws

java.lang.IllegalStateException: source not specified
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:916)
	at org.eclipse.jdt.internal.debug.ui.actions.NavigateToVarDeclAction.run(NavigateToVarDeclAction.java:92)
	at org.eclipse.jdt.internal.debug.ui.actions.ObjectActionDelegate.runWithEvent(ObjectActionDelegate.java:102)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:229)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:581)
	at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:415)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4660)

check with this example

 Thread waitingThread = new Thread(() -> {
      synchronized (monitor) {
          try {
          	int x=10;
              monitor.wait();   // put breakpoint here 
          } catch (InterruptedException ignored) {}
      }
 }, "Eclipse");

now once program is suspended, on debug view select thread.runWith() stackframe
and do navigation
image

@subyssurendran666 subyssurendran666 force-pushed the NPE_in_variable_navigation_712 branch from 530252e to 535604a Compare June 10, 2025 04:17
@subyssurendran666
Copy link
Copy Markdown
Contributor Author

Lamda issue is fixed but doing navigation on BinaryTypes eg Thread.class it throws

java.lang.IllegalStateException: source not specified
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:916)
	at org.eclipse.jdt.internal.debug.ui.actions.NavigateToVarDeclAction.run(NavigateToVarDeclAction.java:92)
	at org.eclipse.jdt.internal.debug.ui.actions.ObjectActionDelegate.runWithEvent(ObjectActionDelegate.java:102)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:229)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:581)
	at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:415)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4660)

check with this example

 Thread waitingThread = new Thread(() -> {
      synchronized (monitor) {
          try {
          	int x=10;
              monitor.wait();   // put breakpoint here 
          } catch (InterruptedException ignored) {}
      }
 }, "Eclipse");

now once program is suspended, on debug view select thread.runWith() stackframe and do navigation image

This problem is handled.

@SougandhS
Copy link
Copy Markdown
Member

org.eclipse.jdt.debug.tests.breakpoints.ThreadNameChangeTests.testListenToThreadNameChange failure is unrelated to this PR

@subyssurendran666 subyssurendran666 force-pushed the NPE_in_variable_navigation_712 branch from 535604a to d5d06b3 Compare June 10, 2025 06:46
@subyssurendran666 subyssurendran666 force-pushed the NPE_in_variable_navigation_712 branch from d5d06b3 to ddc29c4 Compare June 10, 2025 07:41
@SougandhS SougandhS force-pushed the NPE_in_variable_navigation_712 branch from ddc29c4 to 7dca8c4 Compare June 13, 2025 01:38
@subyssurendran666 subyssurendran666 force-pushed the NPE_in_variable_navigation_712 branch from 7dca8c4 to 51cbfa4 Compare June 19, 2025 10:22
@subyssurendran666 subyssurendran666 force-pushed the NPE_in_variable_navigation_712 branch 2 times, most recently from 99259bd to 753f596 Compare June 27, 2025 13:26
@SougandhS SougandhS force-pushed the NPE_in_variable_navigation_712 branch from 753f596 to 3b8032a Compare June 28, 2025 03:59
Copy link
Copy Markdown
Member

@SougandhS SougandhS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting BadLocation exception in few scenarios..

org.eclipse.jface.text.BadLocationException
	at org.eclipse.jface.text.ListLineTracker.getLineInformation(ListLineTracker.java:178)
	at org.eclipse.jface.text.AbstractLineTracker.getLineInformation(AbstractLineTracker.java:228)
	at org.eclipse.jface.text.AbstractDocument.getLineInformation(AbstractDocument.java:873)
	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.getLineInformation(SynchronizableDocument.java:385)
	at org.eclipse.jdt.internal.debug.ui.actions.NavigateToVarDeclAction.highlightLine(NavigateToVarDeclAction.java:275)
	at org.eclipse.jdt.internal.debug.ui.actions.NavigateToVarDeclAction$1.visit(NavigateToVarDeclAction.java:189)
	at org.eclipse.jdt.core.dom.VariableDeclarationFragment.accept0(VariableDeclarationFragment.java:231)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:3312)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:3383)
	at org.eclipse.jdt.core.dom.VariableDeclarationStatement.accept0(VariableDeclarationStatement.java:253)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:3312)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:3383)
	at org.eclipse.jdt.core.dom.Block.accept0(Block.java:128)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:3312)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:3360)
	at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:676)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:3312)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:3383)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:497)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:3312)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:3383)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:497)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:3312)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:3383)
	at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:257)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:3312)
	at org.eclipse.jdt.internal.debug.ui.actions.NavigateToVarDeclAction.run(NavigateToVarDeclAction.java:141)
	at org.eclipse.jdt.internal.debug.ui.actions.ObjectActionDelegate.runWithEvent(ObjectActionDelegate.java:102)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:229)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:581)
	at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:415)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4660)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1657)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1680)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1665)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1394)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4427)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4003)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:678)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:583)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:185)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:219)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:149)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:115)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:467)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:298)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:627)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1431)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1403)

@SougandhS
Copy link
Copy Markdown
Member

getting BadLocation exception in few scenarios..

Put an entry lambda breakpoint in any stream operation and check the operation with below stackframes

test.mp4

@subyssurendran666 subyssurendran666 force-pushed the NPE_in_variable_navigation_712 branch 2 times, most recently from 52195f4 to e74176c Compare July 4, 2025 09:05
Copy link
Copy Markdown
Member

@SougandhS SougandhS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it works in every scenarios. Thanks!
Please do the minor review changes I suggested then we can merge

@subyssurendran666 subyssurendran666 force-pushed the NPE_in_variable_navigation_712 branch from e74176c to 69078ea Compare July 7, 2025 02:58
Variable Navigation throwing NPE and support for variable navigation in
lambda for non-java projects

Fix: eclipse-jdt#712
@subyssurendran666 subyssurendran666 force-pushed the NPE_in_variable_navigation_712 branch from 69078ea to 509ffc0 Compare July 7, 2025 05:00
Copy link
Copy Markdown
Member

@SougandhS SougandhS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SougandhS SougandhS modified the milestone: 4.37 M2 Jul 7, 2025
@SougandhS SougandhS merged commit 3cc1183 into eclipse-jdt:master Jul 7, 2025
13 checks passed
noopur2507 pushed a commit that referenced this pull request Jul 21, 2025
Variable Navigation throwing NPE and support for variable navigation in
lambda for non-java projects

Fix: #712
noopur2507 added a commit that referenced this pull request Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variable Navigation throwing NPE for non-java projects

2 participants