Scala Programming Language
  1. Scala Programming Language
  2. SI-7008

Scala reflection does not represent thrown exceptions

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.10.1
    • Component/s: None

      Description

      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.

        Activity

        Hide
        Eugene Burmako added a comment -

        Probably should a very easy fix. Will try to get it once we're discussing synchronization.

        Show
        Eugene Burmako added a comment - Probably should a very easy fix. Will try to get it once we're discussing synchronization.
        Show
        Eugene Burmako added a comment - https://github.com/scala/scala/pull/2040

          People

          • Assignee:
            Eugene Burmako
            Reporter:
            Grzegorz Kossakowski
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development