Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
scabug opened this issue Jul 22, 2011 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented Jul 22, 2011

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

@scabug
Copy link
Author

scabug commented Jul 22, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4827?orig=1
Reporter: Oleg Zhurakousky (ozhurakousky)
Affected Versions: 2.9.0

@scabug
Copy link
Author

scabug commented Jul 28, 2011

@paulp said:
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.

@scabug
Copy link
Author

scabug commented Jul 28, 2011

Commit Message Bot (anonymous) said:
(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 #4827, no review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants