Aladdin - Scala Bugtracking
[#949] project: compiler priority: low category: bug
submitter assigned to status date submitted
Nikolay Martin fixed 2007-02-13 16:21:34.0
subject [contrib #334] NoClassDefFoundError accessing private object
code
object P extends Application {

    def f = new T { val state = State.A }

    private object State extends Enumeration {
        val A, B = Value
    }

    f
}

trait T {
}

/*
Using
    private object State extends Enumeration {
we experience a runtime error:-

scalac -version
Scala compiler 2.3.3 -- (c) 2002-2007 LAMP/EPFL

scalac P.scala

scala P
java.lang.NoClassDefFoundError: P$P$$State$
        at P$$anon$0.<init>(P.scala:4)
        at P$.f(P.scala:4)
        at P$.<init>(P.scala:10)
        at P$.<clinit>(P.scala)
        at P.main(P.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:76)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:107)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)


Using
    object State extends Enumeration {
or
    private[P] object State extends Enumeration {
we have successful execution.
*/

what happened
java.lang.NoClassDefFoundError at runtime
what expected successful execution
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-02-13 16:24:31.0
The name of the nested private object is mangled as for methods. This should not be done, I think. The JVM backend emits it under the regular name for a nested class
Martin  edited on  2007-03-05 22:29:50.0