NPE when compiling Scala library #1

jmgrosen opened this Issue Jan 24, 2013 · 2 comments

3 participants


Compiling a simple "Hello World" scala file gives me two files in classes/, and HelloWorldScala$.java. Then, to compile it to a binary, I use robovm -verbose -cp scala-library.jar:classes/ HelloWorldScala. It goes through and compiles a lot of classes, but then eventually gets to scala.concurrent.forkjoin.ForkJoinTask and fails with this exception:

    at soot.jimple.toolkits.annotation.arraycheck.ArrayBoundsCheckerAnalysis.doAnalysis(
    at soot.jimple.toolkits.annotation.arraycheck.ArrayBoundsCheckerAnalysis.<init>(
    at soot.jimple.toolkits.annotation.arraycheck.ArrayBoundsChecker.internalTransform(
    at soot.BodyTransformer.transform(
    at soot.Transform.apply(
    at soot.BodyPack.internalApply(
    at soot.Pack.apply(
    at org.robovm.compiler.MethodCompiler.doCompile(
    at org.robovm.compiler.AbstractMethodCompiler.compile(
    at org.robovm.compiler.ClassCompiler.method(
    at org.robovm.compiler.ClassCompiler.compile(
    at org.robovm.compiler.ClassCompiler.compile(
    at org.robovm.compiler.AppCompiler.compile(
    at org.robovm.compiler.AppCompiler.compile(
    at org.robovm.compiler.AppCompiler.main(

This is using Scala 2.10 and RoboVM 0.0.1.


Same for me on Linux x86 with JRE 1.7.0_09.

@ntherning ntherning added a commit that closed this issue Jan 25, 2013
@ntherning ntherning Fixes #1. NPE is thrown by Soot's ArrayBoundsCheckerAnalysis when the…
… first unit in a static method is the target of other units in the method. We now insert a nop as the first unit in such methods to work around this problem. This thread on Soot's mailing list has more info:
@ntherning ntherning closed this in 99a324c Jan 25, 2013

Here's some Java code which triggers this Soot problem:

    static int[] x = {1};
    static void foo() {
        while (true) {
@ntherning ntherning added a commit that referenced this issue Nov 23, 2014
@ntherning ntherning Fixed LocalVariable tables in Soot for parameters and 'this' to alway…
…s start

on the first unit of the body of a method. This fixes an issue with the
LocalSplitter splitting parameters which are written without being read first.

Also removed the special compilation of Object.<init>() as it didn't create
allocas as expected by compiler plugins. Object.<init>() will now be compiled
as any other method and the call to register_finalizable() will be inserted

Also fixed so that the nop inserted by MethodCompiler to workaround a bug in
Soot's ArrayBoundsCheckerAnalysis (see #1) is removed right after the Soot
passes have been run. Otherwise the start unit for parameter LocalVariables
will not be the first unit of the method any longer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment