Aladdin - Scala Bugtracking
[#580] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Stephane Iulian fixed 2006-04-27 18:35:47.0
subject error: class file "..." is broken
code
// Bar.java
public class Bar {
    int bar_x;
    public class Foo {
      int foo_x;
    }
    Foo foo = new Foo();
}

// test.scala
object test {
  class MyBar extends Bar {
    val x = bar_x
    //val y = new Foo
    val z = foo
  }
}
what happened
error: error while loading Bar, class file '/tmp/classes/Bar.class' is broken
(class Bar$Foo not found.)
test.scala:5 error: not found: value foo
    val z = foo
            ^
test.scala:2 error: value this is not a member of Bar
  class MyBar extends Bar {
                      ^
three errors found
what expected scalac accepts both value declarations y and z in test.scala
[back to overview]
Changes of this bug report
Stephane  edited on  2006-04-27 18:36:06.0
Martin  edited on  2006-08-20 19:02:19.0
Since Iulian has now taken the lead to make Scala compatible with Java's inner classes, I reassign this to him.
Iulian  edited on  2006-08-22 17:26:58.0
This is not only related to inner classes. Apparently the compiler can't find classes in the empty package. This simpler example shows it:
// Bar.java
public class Bar {
}

class X {
    public Bar b;
};

// Foo.scala
object test {
  val t = new X();
}
output: error: error while loading X, class file 'classes/X.class' is broken (class Bar not found.) Foo.scala:4 error: value this is not a member of X val t = new X(); Note that adding a 'package' declaration in each file will work around this problem. I don't remember exactly the context, but this problem has been discussed before (or maybe it was the scala 1 compiler...). I'll keep looking into the other problem which is commented out in the original code sample (calling constructors of Java-inner classes).
Iulian  edited on  2006-11-02 17:42:30.0
Fixed the classfile parser to find classes in the empty package.