-
Notifications
You must be signed in to change notification settings - Fork 21
ClassFormatError using specialized annotation #7288
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7288?orig=1 |
@soc said: |
@gzm0 said:
|
kenji yoshida said: |
kenji yoshida said (edited on Mar 30, 2016 1:23:07 AM UTC): scalaVersion := "2.11.8" package com.example
case class Foo[F[_], A](step: F[Foo.Step[A]])
object Foo {
class Step[A]
object Done {
def unapply[A](a: Step[A]): Boolean = true
}
}
object ClassFormatErrorBug {
implicit class AnyOps[A](actual: A) {
def mustMatch[B](f: PartialFunction[A, B]): Unit = {
}
}
type Id[+A] = A
def main(args: Array[String]): Unit = {
val s = new Foo[Id, String](new Foo.Step[String])
s.step mustMatch {
case Foo.Done() => true
}
}
} |
@SethTisue said: also, I'm skeptical that you've really minimized this. occasionally a bug requires this much code to trigger, but it's very rare. so for example, when I pull {{Step}} out to the outer level and remove its type parameters, I still get the same error. nor does the error go away if eliminate {{Foo}}'s companion object and promote {{Done}} to the top level. I suspect there are further such reductions that could result in even more minimized code. |
@VladUreche said (edited on Mar 30, 2016 12:57:58 PM UTC): $ javap -s -private -classpath . 'com/example/ClassFormatErrorBug$$anonfun$main$1'
Compiled from "SI-7288.scala"
public final class com.example.ClassFormatErrorBug$$anonfun$main$1 extends scala.runtime.AbstractPartialFunction<com.example.Foo$Step<java.lang.String, com.example.Foo<java.lang.Object, java.lang.String>>, java.lang.Object> implements scala.Serializable {
public final <A1 extends com/example/Foo$Step<java/lang/String, com/example/Foo<java/lang/Object, java/lang/String>>, B1 extends java/lang/Object> B1 applyOrElse(A1, scala.Function1<A1, B1>);
Signature: (Ljava/lang/Object;Lscala/Function1;)Ljava/lang/Object;
public final java.lang.Object applyOrElse(java.lang.Object, scala.Function1);
Signature: (Ljava/lang/Object;Lscala/Function1;)Ljava/lang/Object;
...
} This has been fixed in miniboxing: miniboxing/miniboxing-plugin#192. |
@retronym said: package com.example
object ClassFormatErrorBug {
type Id[A] = A
def main(args: Array[String]): Unit = {
new PF1
}
}
abstract class PF[A, B]{
def x[A1 <: A](x1: A1): Any
}
class PF1 extends PF[ClassFormatErrorBug.Id[java.lang.String], Any] {
def x[A1 <: ClassFormatErrorBug.Id[java.lang.String]](x1: A1): Any = null
}
|
@SethTisue said (edited on Mar 30, 2016 4:20:34 PM UTC): object SI_7288 {
type Id[A] = A
def f[A](pf: PartialFunction[A, Unit]): Unit = ()
f[Id[Int]] { case _ => }
def main(args: Array[String]): Unit = ()
} |
@VladUreche said: Seems miniboxing only removes the redundant bridges generated by itself, not those generated by erasure, so it doesn't fix the problem completely. |
on 2.12.4 my minimization gives
|
Closes scala/bug#7216 Closes scala/bug#7288 Closes scala/bug#8693
scala/scala#8569 shows that the original report was fixed at least as of 2.12.0, so I'll close the ticket with that milestone my alternate minimization remains unfixed even in 2.13.1; I've opened a separate ticket on it: #11817 |
Thanks! I've been taking a look at it because it's not right to leave it here to rot. |
|
It seems that the scala compiler is generating multiple equals methods with the same signature. First of all here is a toy code sample that reproduces the issue:
This program compiles correctly using the scala compiler, however upon instantiation of MyClass at run time, the class loader throws the following exception:
Running javap shows the following duplicate method has been generated:
Additionally using JAD to decompile the class shows the source of the two methods:
FYI: I don't think this is a blocker, it's my first time filing an issue, and I was unable to change the default priority.
The text was updated successfully, but these errors were encountered: