compiler error when extending org.eclipse.ui.editors.text.TextEditor from Scala class

230 views
Skip to first unread message

Simon Schäfer

unread,
Sep 11, 2012, 7:07:10 AM9/11/12
to scala-i...@googlegroups.com
I tried to write an eclipse plugin with editor. When I do this with Java
all works fine, but when I add Scala nature to the project and create a
Scala class which extends org.eclipse.ui.editors.text.TextEditor I get
following error:

error while loading AbstractDecoratedTextEditor, class file
'/home/antoras/Software/scala-eclipse/plugins/org.eclipse.ui.editors_3.7.0.v20110928-1504.jar(org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.class)'
is broken (class java.lang.NullPointerException/) com.test.slang
Unknown Scala Problem

I'm working with the last nightly build and 2.10.

Dependencies and so on are correctly set (it works with Java). Does
someone know what's that for a problem?

iulian dragos

unread,
Sep 11, 2012, 7:47:46 AM9/11/12
to scala-i...@googlegroups.com
Hi Simon,

On Tue, Sep 11, 2012 at 1:07 PM, Simon Schäfer <ma...@antoras.de> wrote:
I tried to write an eclipse plugin with editor. When I do this with Java
all works fine, but when I add Scala nature to the project and create a
Scala class which extends org.eclipse.ui.editors.text.TextEditor I get
following error:

error while loading AbstractDecoratedTextEditor, class file
'/home/antoras/Software/scala-eclipse/plugins/org.eclipse.ui.editors_3.7.0.v20110928-1504.jar(org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.class)'
is broken (class java.lang.NullPointerException/)       com.test.slang  
Unknown Scala Problem

This indicates an incomplete classpath: some classfile references another class which is not found. I wonder if there is any additional information in the Error Log window, or if the Scala log file (make sure to turn on DEBUG level logging in Eclipse Preferences/Scala/Logging).


I'm working with the last nightly build and 2.10.

Dependencies and so on are correctly set (it works with Java). Does
someone know what's that for a problem?

Unfortunately, the Scala compiler is more greedy than the Java compiler. It may happen that it needs a certain class on the classpath in situations where the java compiler is happy to know just the name of that class! So in this case I'm pretty sure the solution is to add another dependency in your MANIFEST.MF file. To know exactly what bundle you need is impossible without more information. For an example plugin written in Scala that defines an editor you can have a look at https://github.com/scala-ide/scala-worksheet.

At any rate, the Scala compiler should not crash with an NPE. It would be good to file a bug on the Scala issue tracker (issues.scala-lang.org) as well.

thanks,
iulian
 



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

sschaef

unread,
Sep 11, 2012, 3:37:35 PM9/11/12
to scala-i...@googlegroups.com
eclispe does not report more information, neither in Scala logging nor in the error log view.

But I found out that by adding a dependency to org.eclipse.debug.ui the error disappears, but another occur:

java.lang.UnsupportedOperationException: tail of empty list
    at scala.collection.immutable.Nil$.tail(List.scala:330)
    at scala.collection.immutable.Nil$.tail(List.scala:325)
    at xsbt.API.xsbt$API$$mkStructure(API.scala:234)
    at xsbt.API$$anonfun$structure$1.apply(API.scala:227)
    at xsbt.API$$anonfun$structure$1.apply(API.scala:227)
    at scala.collection.mutable.MapLike$class.getOrElseUpdate(MapLike.scala:189)
    at scala.collection.mutable.AbstractMap.getOrElseUpdate(Map.scala:91)
    at xsbt.API.structure(API.scala:227)
    at xsbt.API.xsbt$API$$structure(API.scala:224)
    at xsbt.API$$anonfun$xsbt$API$$mkClassLike$2.apply(API.scala:361)
    at xsbt.API$$anonfun$xsbt$API$$mkClassLike$2.apply(API.scala:361)
    at xsbt.Message$$anon$1.apply(Message.scala:8)
    at xsbti.SafeLazy$$anonfun$apply$1.apply(SafeLazy.scala:8)
    at xsbti.SafeLazy$Impl._t$lzycompute(SafeLazy.scala:20)
    at xsbti.SafeLazy$Impl._t(SafeLazy.scala:18)
    at xsbti.SafeLazy$Impl.get(SafeLazy.scala:24)
    at xsbt.API$$anonfun$xsbt$API$$forceStructures$1.apply(API.scala:95)
    at xsbt.API$$anonfun$xsbt$API$$forceStructures$1.apply(API.scala:95)
    at scala.collection.immutable.List.foreach(List.scala:309)
    at xsbt.API.xsbt$API$$forceStructures(API.scala:95)
    at xsbt.API$ApiPhase.processScalaUnit(API.scala:47)
    at xsbt.API$ApiPhase.processUnit(API.scala:38)
    at xsbt.API$ApiPhase$$anonfun$run$1.apply(API.scala:34)
    at xsbt.API$ApiPhase$$anonfun$run$1.apply(API.scala:34)
    at scala.collection.Iterator$class.foreach(Iterator.scala:726)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1155)
    at xsbt.API$ApiPhase.run(API.scala:34)
    at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1561)
    at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1535)
    at scala.tools.nsc.Global$Run.compileSources(Global.scala:1531)
    at scala.tools.nsc.Global$Run.compile(Global.scala:1641)
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:115)
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:89)
    at xsbt.CompilerInterface.run(CompilerInterface.scala:26)
    at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:74)
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:36)
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:30)
    at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:72)
    at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:72)
    at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:72)
    at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:129)
    at sbt.compiler.AggressiveCompile$$anonfun$3.compileScala$1(AggressiveCompile.scala:71)
    at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:112)
    at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:60)
    at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:24)
    at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:22)
    at sbt.inc.Incremental$.cycle(Incremental.scala:40)
    at sbt.inc.Incremental$.compile(Incremental.scala:25)
    at sbt.inc.IncrementalCompile$.apply(Compile.scala:20)
    at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:120)
    at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:44)
    at sbt.compiler.AggressiveCompile.apply(AggressiveCompile.scala:31)
    at sbt.compiler.IC$.compile(IncrementalCompiler.scala:20)
    at scala.tools.eclipse.buildmanager.sbtintegration.EclipseSbtBuildManager.runCompiler(EclipseSbtBuildManager.scala:128)
    at scala.tools.eclipse.buildmanager.sbtintegration.EclipseSbtBuildManager.update(EclipseSbtBuildManager.scala:118)
    at scala.tools.eclipse.buildmanager.sbtintegration.EclipseSbtBuildManager.build(EclipseSbtBuildManager.scala:173)
    at scala.tools.eclipse.ScalaProject.build(ScalaProject.scala:597)
    at scala.tools.eclipse.ScalaBuilder.build(ScalaBuilder.scala:114)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

After adding another dependency to org.eclipse.ui.ide, this error disappears, too, and all of the code is successfully compiled+run.

Do both bugs belong to scalac? The last second one looks more like an issue of sbt.

iulian dragos

unread,
Sep 13, 2012, 3:52:31 AM9/13/12
to scala-i...@googlegroups.com
On Tue, Sep 11, 2012 at 9:37 PM, sschaef <ma...@antoras.de> wrote:
eclispe does not report more information, neither in Scala logging nor in the error log view.

But I found out that by adding a dependency to org.eclipse.debug.ui the error disappears, but another occur:

java.lang.UnsupportedOperationException: tail of empty list
    at scala.collection.immutable.Nil$.tail(List.scala:330)
    at scala.collection.immutable.Nil$.tail(List.scala:325)
    at xsbt.API.xsbt$API$$mkStructure(API.scala:234) 
...
 
After adding another dependency to org.eclipse.ui.ide, this error disappears, too, and all of the code is successfully compiled+run.

Do both bugs belong to scalac? The last second one looks more like an issue of sbt.

You are right. I believe they have the same cause, and I filed a ticket on Sbt 5 month ago: https://github.com/harrah/xsbt/issues/417 Maybe you can add a comment and see if more interest bumps its priority a bit.

thanks,
iulian
Reply all
Reply to author
Forward
0 new messages