scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Reflecting classes with Java annotations with Java Enum parameters explodes #6783

Closed scabug closed 11 years ago

scabug commented 11 years ago

Attempting to get a ClassSymbol from a Scala class with Java attribute with a defined Java Enum parameter causes an exception to be thrown at runtime. If you remove the parameter (let it default) the code runs without issue. A runnable example is attached.

@JavaAnnotation(JavaAnnotation.JavaEnum.BAR) case class AnnotatedScalaClass()

val symbol = currentMirror.classSymbol(classOf[AnnotatedScalaClass]) assert(symbol.isCaseClass == true)

java.lang.RuntimeException: error reading Scala signature of test.ReflectionTest: bad symbolic reference. A signature in test.ReflectionTest refers to term JavaEnum in object src.JavaAnnotation which is not available. It may be completely missing from the current classpath, or the version on the classpath might be incompatible with the version used when compiling test.ReflectionTest. at scala.reflect.internal.pickling.UnPickler.unpickle(UnPickler.scala:45) at scala.reflect.runtime.JavaMirrors$JavaMirror.unpickleClass(JavaMirrors.scala:561) at scala.reflect.runtime.SymbolLoaders$TopClassCompleter.complete(SymbolLoaders.scala:31) at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1217) at scala.reflect.runtime.JavaMirrors$JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$coreLookup$1(JavaMirrors.scala:928) at scala.reflect.runtime.JavaMirrors$JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$lookupClass$1(JavaMirrors.scala:934) at scala.reflect.runtime.JavaMirrors$JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$classToScala1(JavaMirrors.scala:939) at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToScala$1.apply(JavaMirrors.scala:916) at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToScala$1.apply(JavaMirrors.scala:916) at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$toScala$1.apply(JavaMirrors.scala:104) at scala.reflect.runtime.TwoWayCache.toScala(TwoWayCache.scala:38) at scala.reflect.runtime.JavaMirrors$JavaMirror.toScala(JavaMirrors.scala:102) at scala.reflect.runtime.JavaMirrors$JavaMirror.classToScala(JavaMirrors.scala:916) at scala.reflect.runtime.JavaMirrors$JavaMirror.classSymbol(JavaMirrors.scala:206) at scala.reflect.runtime.JavaMirrors$JavaMirror.classSymbol(JavaMirrors.scala:65) at test.ReflectionTest$delayedInit$body.apply(ReflectionTest.scala:10) at scala.Function0$class.apply$mcV$sp(Function0.scala:40) at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) at scala.App$$anonfun$main$1.apply(App.scala:71) at scala.App$$anonfun$main$1.apply(App.scala:71) at scala.collection.immutable.List.foreach(List.scala:309) at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32) at scala.App$class.main(App.scala:71) at test.ReflectionTest$.main(ReflectionTest.scala:6) at test.ReflectionTest.main(ReflectionTest.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:601)

scabug commented 11 years ago

Imported From: https://issues.scala-lang.org/browse/SI-6783?orig=1 Reporter: Ryan Bair (ryandbair) Affected Versions: 2.10.0-M5 Attachments:

scabug commented 11 years ago

@xeno-by said: Duplicate of #6548, which I fixed just a few hours ago.