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

Scala reflection does not represent thrown exceptions #7008

Closed
scabug opened this issue Jan 23, 2013 · 3 comments
Closed

Scala reflection does not represent thrown exceptions #7008

scabug opened this issue Jan 23, 2013 · 3 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Jan 23, 2013

This REPL session explains it the best:

Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import scala.reflect.runtime.universe._
import scala.reflect.runtime.universe._

scala> typeOf[java.lang.reflect.Method].member(newTermName("invoke"))
res0: reflect.runtime.universe.Symbol = method invoke

scala> res0.annotations
res1: List[reflect.runtime.universe.Annotation] = List()

The relevant piece of code is in JavaMirrors:

private def jmethodAsScala1(jmeth: jMethod): MethodSymbol = {
      val clazz = sOwner(jmeth)
      val meth = clazz.newMethod(newTermName(jmeth.getName), NoPosition, toScalaMethodFlags(jmeth.getModifiers))
      methodCache enter (jmeth, meth)
      val tparams = jmeth.getTypeParameters.toList map createTypeParameter
      val paramtpes = jmeth.getGenericParameterTypes.toList map typeToScala
      val resulttpe = typeToScala(jmeth.getGenericReturnType)
      setMethType(meth, tparams, paramtpes, resulttpe)
      copyAnnotations(meth, jmeth)
      if ((jmeth.getModifiers & JAVA_ACC_VARARGS) != 0) meth.setInfo(arrayToRepeated(meth.info))
      meth
    }

It forgets to load information about thrown exceptions and synthesize the right annotations.

@scabug
Copy link
Author

@scabug scabug commented Jan 23, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7008?orig=1
Reporter: @gkossakowski
Affected Versions: 2.10.0

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 31, 2013

@xeno-by said:
Probably should a very easy fix. Will try to get it once we're discussing synchronization.

Loading

@scabug
Copy link
Author

@scabug scabug commented Jan 31, 2013

Loading

@scabug scabug closed this Feb 5, 2013
@scabug scabug added the has PR label Apr 7, 2017
@scabug scabug added this to the 2.10.1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants