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: class scala.runtime.RichInt$$$$anon$$1 overrides final method foreach.(Lscala/Function1;)V #4575
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4575?orig=1 |
@paulp said: import annotation.bridge
class A {
final def f() = ()
}
class B extends A {
@bridge override def f() = ()
}
object Test {
// java.lang.VerifyError: class B overrides final method f.()V
def main(args: Array[String]) = new B f()
} |
@ijuma said: |
@odersky said: package scala
import annotation.bridge
class A {
final def f(): A = new A
}
class B extends A {
@bridge override def f(): B = new B
}
object Test {
// java.lang.VerifyError: class B overrides final method f.()V
def main(args: Array[String]) = {
println(new B().f()) }
} If I run this under java version "1.6.0_24" on MacOS, everything runs as it should: /Users/odersky/workspace/scala/test/files/new> java -verify scala.Test
scala.A@28bb0d0d Note that the bridge method was not called, but the original method in A was called instead. If I would compile with an old binary that did refer to the bridge method signature directly, I would indeed get a VerifyError. So, we know for certain that bridge methods in Range are ineffective (without them you got a MissingMethodError, now you get a VerifyError, makes no practical difference). But now I ask myself: Why did the bridge method not get verified, whereas in the original example it did? What's different between by setting and tomcats? Does tomcat somehow do different verification than java, or does Ismaels WAR contain some 2.8 code that calls the bridge method? In the first case, the error would be very serious, so that we'd have to put out a patch quickly. |
@ijuma said: |
@odersky said: |
@ijuma said: java.lang.VerifyError: class scala.runtime.RichInt$$$$anon$$1 overrides final method foreach.(Lscala/Function1;)V
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:1969)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1932)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1826)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1785)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1771)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1254)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:316)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:932)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:723)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:379)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:324)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1041)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431) |
@odersky said: |
@ijuma said: |
@paulp said: |
@ijuma said: |
@odersky said: |
@odersky said: |
@ijuma said: |
@dragos said: |
@ijuma said:
Agreed. |
Bill Atkins (batkins) said: Is there a workaround at the moment - will this go away if I just recompile code that suffers from this bug with the 2.9.0 compiler? |
@dragos said: Martin already fixed it but forgot to close the ticket. |
Robbie Coleman (erraggy) said: I am still seeing this issue from within Glassfish: There is discussion on the scala-user group here: |
=== What steps will reproduce the problem (please be specific and use wikiformatting)? ===
I reproduced the problem by deploying a WAR compiled with Scala 2.9.0 to Tomcat 7.0.12.
=== What is the expected behavior? ===
Successful initialisation.
=== What do you see instead? ===
=== Additional information ===
To compensate for the lack of an isolated test case, here's some information (Alex Cruise provided some of it on IRC after I mentioned the initial error).
The source of the issue seems to be the following @bridge method in RichInt:
The problem is that Range defines a final foreach and Range.ByOne tries to override it.
Using javap, in Range.class, there is:
and in RichInt$$$$anon$$1 which inherits from Range.Inclusive which inherits from Range, there is:
=== What versions of the following are you using? ===
The text was updated successfully, but these errors were encountered: