Scala 2.10.x on JamVM: NullPointerException in ScalaRunTime.tupleNames

543 views
Skip to first unread message

Tom

unread,
Apr 25, 2013, 2:46:55 PM4/25/13
to scala...@googlegroups.com
Hi,

I'm trying to get scala 2.10.1 working on a JamVM cross-compile (1.5.4, with classpath 0.98, bytecode inlining disabled, PPC/uClibc toolchain).

Running the following app:
object foo {
  def main(args: Array[String]) = { println("Hello"); }
}
(jamvm -cp scala-library.jar:foo.jar foo)

yields the following exception using the HashMap class (specifically caused by bringing in Predef, but presumably by any use of a HashMap, or ScalaRunTime.hash):
Caused by: java.lang.ExceptionInInitializerError
   at scala.collection.mutable.HashTable$HashUtils$class.elemHashCode(HashTable.scala:398)
   at scala.collection.mutable.HashMap.elemHashCode(HashMap.scala:39)
   at scala.collection.mutable.HashTable$class.findOrAddEntry(HashTable.scala:161)
   at scala.collection.mutable.HashMap.findOrAddEntry(HashMap.scala:39)
   at scala.collection.mutable.HashMap.put(HashMap.scala:75)
   at scala.collection.mutable.HashMap.update(HashMap.scala:80)
   at scala.sys.SystemProperties$.addHelp(SystemProperties.scala:64)
   at scala.sys.SystemProperties$.bool(SystemProperties.scala:68)
   at scala.sys.SystemProperties$.noTraceSupression$lzycompute(SystemProperties.scala:80)
   at scala.sys.SystemProperties$.noTraceSupression(SystemProperties.scala:80)
   at scala.util.control.NoStackTrace$.<init>(NoStackTrace.scala:31)
   at scala.util.control.NoStackTrace$.<clinit>(NoStackTrace.scala)
   at scala.util.control.NoStackTrace$class.fillInStackTrace(NoStackTrace.scala:22)
   at scala.util.control.BreakControl.fillInStackTrace(Breaks.scala:93)
   at java.lang.Throwable.<init>(Throwable.java:161)
   at java.lang.Throwable.<init>(Throwable.java:149)
   at scala.util.control.BreakControl.<init>(Breaks.scala:93)
   at scala.util.control.Breaks.<init>(Breaks.scala:28)
   at scala.collection.Traversable$.<init>(Traversable.scala:96)
   at scala.collection.Traversable$.<clinit>(Traversable.scala)
   at scala.package$.<init>(package.scala:46)
   at scala.package$.<clinit>(package.scala)
   at scala.Predef$.<init>(Predef.scala:90)
   at scala.Predef$.<clinit>(Predef.scala)
   at foo$.main(foo.scala:2)
Caused by: java.lang.NullPointerException
   at scala.runtime.ScalaRunTime$.<init>(ScalaRunTime.scala:50)
   at scala.runtime.ScalaRunTime$.<clinit>(ScalaRunTime.scala)
   at scala.collection.mutable.HashTable$HashUtils$class.elemHashCode(HashTable.scala:398)
   ....

The place where the NPE is generated is the block creating ScalaRunTime.tupleNames:

Seeing as that code looks totally harmless, and of course the app runs fine on my laptop, I'm not sure where to start debugging this.  The only issue I could find relating to Scala and JamVM was the SoftReference issue (https://github.com/scala/scala/pull/1902 // SI-6969), but that doesn't seem to be remotely related.  This app and more complicated ones run fine if compiled as Scala 2.9.2 apps, but I get this exception with both 2.10.0 and 2.10.1.

Does anybody have any thoughts about where to start debugging this?

Thanks!
Tom

Simon Ochsenreither

unread,
Apr 25, 2013, 4:39:25 PM4/25/13
to scala...@googlegroups.com
Hi Tom,

thanks for reporting this!

There a few things I can suggest:

You could try to further minimize the code example (e. g. compile without Predef/other imports: Use the flags -Yno-imports (Compile without importing scala.*, java.lang.*, or Predef) or -Yno-predef (Compile without importing Predef)), so that it is easier to reproduce and decreases the amount of “suspicious” code involved.

Additionally, could you try it with a trunk build of Scala? There were a few Avian-fixes related fixes were I'm not sure whether they all arrived in 2.10.x.

Apart from that, I recommend filing a bug, so that this issue is not forgotten.

Let me know if I can help.

Bye,

Simon

Simon Ochsenreither

unread,
Apr 25, 2013, 4:56:48 PM4/25/13
to scala...@googlegroups.com
Hi Tom,

it seems to work on my machine:

./bin/jamvm -cp ../lib/scala-current/lib/scala-library.jar:. foo
Hello

(Latest JamVM, latest Scala nightly)

There seems to be an issue though when starting the REPL, because JamVM/Gnu Classpath are missing a necessary class file, javax.script.Compilable:

./bin/jamvm -cp ../classpath/share/classpath/glibj.zip:../lib/scala-current/lib/scala-library.jar:../lib/scala-current/lib/scala-compiler.jar:../lib/scala-current/lib/scala-reflect.jar scala.tools.nsc.MainGenericRunner
Exception in thread "main" java.lang.NoClassDefFoundError: scala/tools/nsc/interpreter/ILoop$ILoopInterpreter
   at scala.tools.nsc.interpreter.ILoop.createInterpreter(ILoop.scala:121)
   at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:667)
   at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:665)
   at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:665)
   at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:95)
   at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:665)
   at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:80)
   at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:93)
   at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:102)
   at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Caused by: java.lang.NoClassDefFoundError: scala/tools/nsc/interpreter/IMain
   at java.lang.VMClassLoader.defineClass(Native Method)
   at java.lang.VMClassLoader.defineClassWithTransformers(VMClassLoader.java:343)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:471)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:83)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:617)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:341)
   at java.lang.ClassLoader$1.loadClass(ClassLoader.java:1112)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:293)
   at scala.tools.nsc.interpreter.ILoop.createInterpreter(ILoop.scala:121)
   ...9 more
Caused by: java.lang.NoClassDefFoundError: javax/script/Compilable
   at java.lang.VMClassLoader.defineClass(Native Method)
   at java.lang.VMClassLoader.defineClassWithTransformers(VMClassLoader.java:343)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:471)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:83)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:617)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:341)
   at java.lang.ClassLoader$1.loadClass(ClassLoader.java:1112)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:293)
   at java.lang.VMClassLoader.defineClass(Native Method)
   ...17 more
Caused by: java.lang.ClassNotFoundException: javax.script.Compilable not found in java.lang.ClassLoader$1{urls=[file:/home/soc/Entwicklung/jamvm/../classpath/share/classpath/glibj.zip,file:/home/soc/Entwicklung/jamvm/../lib/scala-current/lib/scala-library.jar,file:/home/soc/Entwicklung/jamvm/../lib/scala-current/lib/scala-compiler.jar,file:/home/soc/Entwicklung/jamvm/../lib/scala-current/lib/scala-reflect.jar], parent=null}
   at java.net.URLClassLoader.findClass(URLClassLoader.java:531)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:341)
   at java.lang.ClassLoader$1.loadClass(ClassLoader.java:1112)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:293)
   at java.lang.VMClassLoader.defineClass(Native Method)
   ...25 more


I'm a bit interested, what's your reason for using JamVM?
It doesn't seem to be maintained/developed anymore.

Thanks and bye,

Simon

Tom Cauchois

unread,
Apr 25, 2013, 6:59:08 PM4/25/13
to Simon Ochsenreither, scala...@googlegroups.com
Hi Simon,

Thanks for the reply.  I'm using JamVM so I can run Scala on an embedded linux ppc target.  My main requirement is that I compile the VM from source, but it looks like Avian/Cacao/Kaffe/maybe others might work for my purposes as well.  I'm still in the evaluation stage, so it might be worth switching to Avian, but the exception I got with JamVM was suspicious and seemed worth investigating.  For a hello world application, I can avoid bringing in scala.Predef, but any sufficiently complicated application will eventually cause this exception (e.g. using actors).

I've tried compiling my hello world test case with the scala nightly build (2.11.0-20130424-145255-b291e28c75), and I'm still getting the error.  I've managed to reproduce the error on JamVM compiled for my laptop.  Here are my various configurations (on Ubuntu with gcc 4.4.3, $X is install dir):
[classpath-0.98] ./configure --disable-gtk-peer --disable-gconf-peer --disable-plugin --prefix=$X CFLAGS=-Wno-error
[jamvm-1.5.4] ./configure --with-classpath-install-dir=$X --prefix=$X --disable-int-inlining

I'm curious if you're passing different flags in?  Anyway, I'll create a bug tomorrow with exact repro steps.

Thanks!
Tom




Simon

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages