Aladdin - Scala Bugtracking
[#704] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Martin fixed 2006-08-16 12:44:26.0
subject private objects still broken
code
trait D {
  private object x;
}
object Go extends D {
  def main(args : Array[String]) : Unit = {};
}
what happened
Exception in thread "main" java.lang.ClassFormatError: Method x in class test/D$class has illegal modifiers: 0x4\
1A
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
	at test.Go$.(Go.scala:7)
	at test.Go$.(Go.scala)
	at test.Go.main(Go.scala)
what expected
[back to overview]
Changes of this bug report
Iulian  edited on  2006-08-16 14:14:33.0
The implementation class for trait D gets an abstract (static final) method (the accessor for x), which of course is forbidden. I am not sure what should be done with the private object, but it seems like it could go in concrete implementations of D. At least, that's what happens for a private value. It's a bit strange since being private, x cannot be accessed by subclasses of D, but it's the place where all trait state (should) go(es).
Martin  edited on  2006-08-18 19:41:59.0