Scala Programming Language
  1. Scala Programming Language
  2. SI-4827

java.lang.VerifyError when one of the methods mixed in with trait that has the same(name, signature) method

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.0
    • Fix Version/s: None
    • Component/s: Misc Compiler
    • Labels:
      None
    • Environment:

      Description

      If at some point i need to get into details of my use case, please let me know, but i was able to isolate the problem which is now reproducible with this simple code

      object VerifyErrorTest {
        def main(args: Array[String]): Unit = {
          Foo.foo("")
        }
      }
      
      trait CommonTrait {
        def foo(any: Object): DecoratedFoo = {
          null
        }
      }
      
      class Foo {}
      
      object Foo {
        def apply() = new Foo() with CommonTrait
      
        def foo(o: Object): DecoratedFoo  = {
          null
        }
      }
      
      class DecoratedFoo {}
      
      

      If I comment apply() method or remove with CommonTrait it works fine, otherwise i get this:

      Exception in thread "main" java.lang.VerifyError: class Foo$$anon$1 overrides final method foo.(Ljava/lang/Object;)LDecoratedFoo;
      	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)
      . . .. 
      

      I've classified it as a Bug for now, but as I am in the process of learning Scala I may very well be doing something wrong, so please let me know

        Activity

        Hide
        Paul Phillips added a comment -

        A verify error is always a bug. This one is caused by a corner case with static forwarders, where "foo" looks safe but is not. Right now you can work around it by compiling with -Xno-forwarders.

        Show
        Paul Phillips added a comment - A verify error is always a bug. This one is caused by a corner case with static forwarders, where "foo" looks safe but is not. Right now you can work around it by compiling with -Xno-forwarders.
        Hide
        Commit Message Bot added a comment -

        (extempore in r25392) Changed forwarders not to generate final methods, which otherwise would
        induce VerifyErrors anytime the companion class was subclassed and had a
        method with the same signature. Closes SI-4827, no review.

        Show
        Commit Message Bot added a comment - (extempore in r25392 ) Changed forwarders not to generate final methods, which otherwise would induce VerifyErrors anytime the companion class was subclassed and had a method with the same signature. Closes SI-4827 , no review.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Oleg Zhurakousky
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development