NPE on Variables view
How to reproduce:
1. New scala project
2. Create some code, eg:
object App extends Application {
println("foo")
}
3. Set breakpoint (here at line 2)
4. Debug as - Scalla Application - Use configuration specific settings - Scaa Application (new debugger) Launcher - Ok
5. Window: This kind of launch is configured to open the Debug perspective... - Yes
6. Select row in view Variables [IMPORTANT: don't do anything else]
Result:
In lower part of Variables view you can see stacktrace:
exception while invoking toString(): null
scala.tools.eclipse.debug.model.ScalaObjectReference.jdiInvokeMethod(ScalaValue.scala:172)
scala.tools.eclipse.debug.model.HasMethodInvocation$$anonfun$invokeMethod$2.apply(ScalaDebugElement.scala:141)
scala.tools.eclipse.debug.model.HasMethodInvocation$$anonfun$invokeMethod$2.apply(ScalaDebugElement.scala:135)
scala.util.control.Exception$Catch.apply(Exception.scala:102)
scala.tools.eclipse.debug.model.HasMethodInvocation$class.invokeMethod(ScalaDebugElement.scala:135)
scala.tools.eclipse.debug.model.ScalaObjectReference.invokeMethod(ScalaValue.scala:137)
scala.tools.eclipse.debug.model.ScalaDebugModelPresentation$.computeDetail(ScalaDebugModelPresentation.scala:55)
scala.tools.eclipse.debug.model.ScalaDebugModelPresentation$.computeDetail(ScalaDebugModelPresentation.scala:31)
scala.tools.eclipse.debug.model.ScalaDebugModelPresentation$$anon$1.run(ScalaDebugModelPresentation.scala:88)
org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Expected result:
result of method toString currently selected object
Workaround:
1. Click on any (even current) row in stacktrace in Debug view
2. Click again on row in Variables view
3. Now lower part of Variables view show expected value
Result of investigation:
Probably variable thread is null in following method invocation:
protected[model] def jdiInvokeMethod(method: Method, thread: ScalaThread, args: Value*): Value = thread.invokeMethod(underlying, method, args:_*) //ScalaValue.scala:172
There is need to initialize
@volatile var currentThread: ScalaThread = null //ScalaDebugger.scala:49
with correct value when switching to Debug perspective or when displaing Debug view.
1. New scala project
2. Create some code, eg:
object App extends Application {
println("foo")
}
3. Set breakpoint (here at line 2)
4. Debug as - Scalla Application - Use configuration specific settings - Scaa Application (new debugger) Launcher - Ok
5. Window: This kind of launch is configured to open the Debug perspective... - Yes
6. Select row in view Variables [IMPORTANT: don't do anything else]
Result:
In lower part of Variables view you can see stacktrace:
exception while invoking toString(): null
scala.tools.eclipse.debug.model.ScalaObjectReference.jdiInvokeMethod(ScalaValue.scala:172)
scala.tools.eclipse.debug.model.HasMethodInvocation$$anonfun$invokeMethod$2.apply(ScalaDebugElement.scala:141)
scala.tools.eclipse.debug.model.HasMethodInvocation$$anonfun$invokeMethod$2.apply(ScalaDebugElement.scala:135)
scala.util.control.Exception$Catch.apply(Exception.scala:102)
scala.tools.eclipse.debug.model.HasMethodInvocation$class.invokeMethod(ScalaDebugElement.scala:135)
scala.tools.eclipse.debug.model.ScalaObjectReference.invokeMethod(ScalaValue.scala:137)
scala.tools.eclipse.debug.model.ScalaDebugModelPresentation$.computeDetail(ScalaDebugModelPresentation.scala:55)
scala.tools.eclipse.debug.model.ScalaDebugModelPresentation$.computeDetail(ScalaDebugModelPresentation.scala:31)
scala.tools.eclipse.debug.model.ScalaDebugModelPresentation$$anon$1.run(ScalaDebugModelPresentation.scala:88)
org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Expected result:
result of method toString currently selected object
Workaround:
1. Click on any (even current) row in stacktrace in Debug view
2. Click again on row in Variables view
3. Now lower part of Variables view show expected value
Result of investigation:
Probably variable thread is null in following method invocation:
protected[model] def jdiInvokeMethod(method: Method, thread: ScalaThread, args: Value*): Value = thread.invokeMethod(underlying, method, args:_*) //ScalaValue.scala:172
There is need to initialize
@volatile var currentThread: ScalaThread = null //ScalaDebugger.scala:49
with correct value when switching to Debug perspective or when displaing Debug view.
Leave a comment
on 2013-03-12 03:52 *
By Mirco Dotta
Hi, unfortunately there has been a very silly regression in RC2. I am confident the bug you are seeing is #1001586. The ticket I linked has already been fixed in the nightly. I would really appreciate if you could find the time to install the 3.0.x nightly and check if the issue you reported is still there. The update site for the Scala IDE 3.0.0 nightly for Eclipse Juno is: scala-ide.dreamhosters.com/nightly/scala-ide-scala-ide-3.0.x-juno-2.10.1-SNAPSHOT.
on 2013-03-12 06:04 *
By Mirco Dotta
on 2013-03-12 09:13 *
By Mirco Dotta
Internal note: Looks like in Eclipse Juno they have changed the way the Debug Perspective is activated, and that results in lack of selectionChanged notification in ScalaDebugger, which in turns prevents the ScalaDebugger.thread variable to be correctly initialized. The underneath issue is that we rely on selectionChanged event to be triggered at the right time to correctly update the debug view, we should find a more robust approach.
on 2013-03-13 11:07 *
By Mirco Dotta
This has been fixed and the fix will be available with the upcoming 3.0.0-RC3 release. Check the related ticket #1001585 for more details.