Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.0
    • Fix Version/s: Scala 2.10.0-M2
    • Component/s: None
    • Labels:
      None

      Description

      This code:

      class A(val a: Int = 13)
      class DefaultsTest(x: Int = 25) extends A(28)
      object DefaultsTest extends DefaultsTest(12)
      
      object Main extends App {
        new DefaultsTest()
      }
      

      fails with:

      java.lang.VerifyError: class DefaultsTest$ overrides final method init$default$1.()I
      	at java.lang.ClassLoader.defineClass1(Native Method)
      	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
      	at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
      	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
      	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
      	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
      	at Main$.<init>(DefaultsTest.scala:7)
      	at Main$.<clinit>(DefaultsTest.scala)
      	at Main.main(DefaultsTest.scala)
      

      For some reason, the `init$default$1` methods in `DefaultsTest` are static forwarders to the companion object while the companion object tries to implement the methods from the class in turn leading to the error.

        Activity

        Hide
        Grzegorz Kossakowski added a comment -

        Which Scala version do you use?

        Show
        Grzegorz Kossakowski added a comment - Which Scala version do you use?
        Hide
        Johannes Rudolph added a comment -

        Sorry, forgot to fill out. I'm using Scala 2.9.0-1

        Show
        Johannes Rudolph added a comment - Sorry, forgot to fill out. I'm using Scala 2.9.0-1
        Hide
        Simon Ochsenreither added a comment - - edited

        Seems to works in the REPL, but can verify when compiled with 2.10.0.r25228-b20110704020234.

        Backtrace is a bit larger here:

        java.lang.VerifyError: class DefaultsTest$ overrides final method init$default$1.()I
        	at java.lang.ClassLoader.defineClass1(Native Method)
        	at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
        	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        	at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
        	at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
        	at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
        	at java.security.AccessController.doPrivileged(Native Method)
        	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        	at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.scala$tools$nsc$util$ScalaClassLoader$$super$findClass(ScalaClassLoader.scala:88)
        	at scala.tools.nsc.util.ScalaClassLoader$class.findClass(ScalaClassLoader.scala:44)
        	at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.findClass(ScalaClassLoader.scala:88)
        	at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        	at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.scala$tools$nsc$util$ScalaClassLoader$$super$loadClass(ScalaClassLoader.scala:88)
        	at scala.tools.nsc.util.ScalaClassLoader$class.loadClass(ScalaClassLoader.scala:50)
        	at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.loadClass(ScalaClassLoader.scala:88)
        	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
        	at Main$.<init>(Main.scala:6)
        	at Main$.<clinit>(Main.scala)
        	at Main.main(Main.scala)
        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.lang.reflect.Method.invoke(Method.java:616)
        	at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:78)
        	at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:24)
        	at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:88)
        	at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:78)
        	at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101)
        	at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:33)
        	at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:40)
        	at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:56)
        	at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80)
        	at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89)
        	at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
        
        Show
        Simon Ochsenreither added a comment - - edited Seems to works in the REPL, but can verify when compiled with 2.10.0.r25228-b20110704020234. Backtrace is a bit larger here: java.lang.VerifyError: class DefaultsTest$ overrides final method init$default$1.()I at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:634) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:277) at java.net.URLClassLoader.access$000(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:212) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.scala$tools$nsc$util$ScalaClassLoader$$super$findClass(ScalaClassLoader.scala:88) at scala.tools.nsc.util.ScalaClassLoader$class.findClass(ScalaClassLoader.scala:44) at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.findClass(ScalaClassLoader.scala:88) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.scala$tools$nsc$util$ScalaClassLoader$$super$loadClass(ScalaClassLoader.scala:88) at scala.tools.nsc.util.ScalaClassLoader$class.loadClass(ScalaClassLoader.scala:50) at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.loadClass(ScalaClassLoader.scala:88) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) at Main$.<init>(Main.scala:6) at Main$.<clinit>(Main.scala) at Main.main(Main.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:78) at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:24) at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:88) at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:78) at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:101) at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:33) at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:40) at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:56) at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80) at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:89) at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
        Hide
        Paul Phillips added a comment -

        This was fixed in 892ecd2db7 . I added a test.

        Show
        Paul Phillips added a comment - This was fixed in 892ecd2db7 . I added a test.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Johannes Rudolph
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development