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

VerifyError with default parameters #4777

Closed
scabug opened this issue Jul 7, 2011 · 5 comments
Closed

VerifyError with default parameters #4777

scabug opened this issue Jul 7, 2011 · 5 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Jul 7, 2011

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.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 7, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4777?orig=1
Reporter: @jrudolph
Affected Versions: 2.9.0

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 7, 2011

@gkossakowski said:
Which Scala version do you use?

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 7, 2011

@jrudolph said:
Sorry, forgot to fill out. I'm using Scala 2.9.0-1

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 7, 2011

@soc said (edited on Jul 7, 2011 9:33:16 AM UTC):
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)
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Mar 3, 2012

@paulp said:
This was fixed in 892ecd2db7 . I added a test.

@scabug scabug closed this Mar 3, 2012
@scabug scabug added this to the 2.10.0-M2 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.