Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-4575

java.lang.VerifyError: class scala.runtime.RichInt$$$$anon$$1 overrides final method foreach.(Lscala/Function1;)V

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Library (Misc)
    • Labels:
      None

      Description

      === 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? ===

      791837-java.lang.VerifyError: class scala.runtime.RichInt$$$$anon$$1 overrides final method foreach.(Lscala/Function1;)V
      791838-	at java.lang.ClassLoader.defineClass1(Native Method)
      791839-	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
      791840-	at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
      791841-	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
      791842-	at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
      791843-	at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148)
      791844-	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
      791845-	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
      791846-	at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:1956)

      === 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:

      @bridge
      def until(end: Int): Range with Range.ByOne = new Range(self, end, 1) with Range.ByOne

      The problem is that Range defines a final foreach and Range.ByOne tries to override it.

      Using javap, in Range.class, there is:

      public final void foreach(scala.Function1);
        Code:
         Stack=2, Locals=4, Args_size=2
         0:   aload_0
      ...

      and in RichInt$$$$anon$$1 which inherits from Range.Inclusive which inherits from Range, there is:

      public void foreach(scala.Function1);
        Code:
         Stack=2, Locals=2, Args_size=2
         0:	aload_0
         1:	aload_1
         2:	invokestatic	SI-22; //Method scala/collection/immutable/Range$$ByOne$$class.foreach:(Lscala/collection/immutable/Range$$ByOne;Lscala/Function1;)V
      ...

      === What versions of the following are you using? ===

      • Scala: 2.9.0
      • Java: JDK 6 Update 25
      • Operating system: Linux

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ijuma Ismael Juma
              TracCC:
              Bill Atkins, Daniel Sobral, Johannes Rudolph, Paul Phillips, Seth Tisue, Simon Ochsenreither
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: