Intellij“评估表达式”导致NoSuchMethodException

时间:2018-08-01 13:06:07

标签: scala debugging intellij-idea evaluate

我试图在调试应用程序时检查IntelliJ中对象的中大型Scala映射的内容。我在“评估”对话框中输入以下内容:prices.get.keys.toList.filter(k => k.startsWith("GC")),其中pricesFuture[Map[String, SomeObject]]。我直接在Iterable上尝试过,没有toList集合,但结果相同。

我得到以下异常: 生成的代码调用期间发生错误:  com.intellij.debugger.engine.evaluation.EvaluateException: Method threw 'java.lang.NoSuchMethodError' exception.堆栈跟踪的顶部只是我有断点的那一行。

还有其他人遇到吗?如果是这样,是否有解决方法?

堆栈跟踪如下:

c.p.p.e.u.ClassUnderTest$$anonfun$4$GeneratedEvaluatorClass$10$1.invoke(FileToCompile1993.scala:85)
c.p.p.e.u.ClassUnderTest$$anonfun$4.apply(ClassUnderTest.scala:81)
c.p.p.e.u.ClassUnderTest$$anonfun$4.apply(ClassUnderTest.scala:76)
scala.collection.immutable.HashSet$HashSet1.filter0(HashSet.scala:313)
scala.collection.immutable.HashSet$HashTrieSet.filter0(HashSet.scala:929)
scala.collection.immutable.HashSet$HashTrieSet.filter0(HashSet.scala:929)
scala.collection.immutable.HashSet.filter(HashSet.scala:167)
scala.collection.immutable.HashSet.filter(HashSet.scala:35)
c.p.p.e.u.ClassTest.get(ClassTest.scala:76)
c.p.p.e.u.ClassTest.$$anonfun$1.apply$mcV$sp(ClassTest.scala:35)
c.p.p.e.u.ClassTest$$anonfun$1.apply(ClassTest.scala:22)
c.p.p.e.u.ClassTest$$anonfun$1.apply(ClassTest.scala:22)
org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
org.scalatest.Transformer.apply(Transformer.scala:22)
org.scalatest.Transformer.apply(Transformer.scala:20)
org.scalatest.FlatSpecLike$$anon$1.apply(FlatSpecLike.scala:1647)
org.scalatest.Suite$class.withFixture(Suite.scala:1122)
org.scalatest.FlatSpec.withFixture(FlatSpec.scala:1683)
org.scalatest.FlatSpecLike$class.invokeWithFixture$1(FlatSpecLike.scala:1644)
org.scalatest.FlatSpecLike$$anonfun$runTest$1.apply(FlatSpecLike.scala:1656)
org.scalatest.FlatSpecLike$$anonfun$runTest$1.apply(FlatSpecLike.scala:1656)
org.scalatest.SuperEngine.runTestImpl(Engine.scala:306)
org.scalatest.FlatSpecLike$class.runTest(FlatSpecLike.scala:1656)
org.scalatest.FlatSpec.runTest(FlatSpec.scala:1683)
org.scalatest.FlatSpecLike$$anonfun$runTests$1.apply(FlatSpecLike.scala:1714)
org.scalatest.FlatSpecLike$$anonfun$runTests$1.apply(FlatSpecLike.scala:1714)
org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:413)
org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:401)
scala.collection.immutable.List.foreach(List.scala:381)
org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:390)
org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:427)
org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:401)
scala.collection.immutable.List.foreach(List.scala:381)
org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:396)
org.scalatest.SuperEngine.runTestsImpl(Engine.scala:483)
org.scalatest.FlatSpecLike$class.runTests(FlatSpecLike.scala:1714)
org.scalatest.FlatSpec.runTests(FlatSpec.scala:1683)
org.scalatest.Suite$class.run(Suite.scala:1424)
org.scalatest.FlatSpec.org$scalatest$FlatSpecLike$$super$run(FlatSpec.scala:1683)
org.scalatest.FlatSpecLike$$anonfun$run$1.apply(FlatSpecLike.scala:1760)
org.scalatest.FlatSpecLike$$anonfun$run$1.apply(FlatSpecLike.scala:1760)
org.scalatest.SuperEngine.runImpl(Engine.scala:545)
org.scalatest.FlatSpecLike$class.run(FlatSpecLike.scala:1760)
org.scalatest.FlatSpec.run(FlatSpec.scala:1683)
org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:55)
org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2563)
org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2557)
scala.collection.immutable.List.foreach(List.scala:381)
org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:2557)
org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1044)
org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1043)
org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:2722)
org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1043)
org.scalatest.tools.Runner$.run(Runner.scala:883)
org.scalatest.tools.Runner.run(Runner.scala)
org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:131)
org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:28)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:67)

我已将Scala插件更新到最新版本2018.2.9,并且正在使用IntelliJ IDEA的最新版本(来自“关于”对话框):

IntelliJ IDEA 2018.2(最终版) Build#IU-182.3684.101,建于2018年7月24日

1 个答案:

答案 0 :(得分:1)

Scala调试器在评估复杂表达式(使用lambda,匿名类,类声明等)时存在一些问题。其中一个https://youtrack.jetbrains.com/issue/SCL-14194可能是导致问题的原因,因为调试器在lambda c.p.p.e.u.ClassUnderTest$$anonfun$4.apply(ClassUnderTest.scala:81)中停止,并且该表达式包含lambda函数。

原因是IDEA在评估之前会编译表达式,并且它并不总是正确捕获上下文。解决方法是,您可以尝试从其他调试器停止符(例如,常用方法的主体)中评估表达式。