From f1701f704a2485fcc2eb6d5d8b5d0228beddd9b3 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 31 Jan 2013 20:40:16 +0100 Subject: SI-7008 @throws annotations are now populated in reflect Runtime reflection in JavaMirrors previously forgot to fill in @throws when importing Java reflection artifacts. Now this is fixed. Note that generic exception types used in `throws` specifications will be garbled (i.e. erased), because we don't use `getGenericExceptionTypes` in favor of just `getExceptionTypes` to stay compatible with the behavior of ClassfileParser. That's a bug, but a separate one and should be fixed separately. Also note that this commit updated javac-artifacts.jar, because we need to test how reflection works with javac-produced classfiles. The sources that were used to produce those classfiles can be found in the jar next to the classfiles. --- test/files/lib/javac-artifacts.jar.desired.sha1 | 2 +- test/files/run/t7008.check | 9 +++++++++ test/files/run/t7008/Impls_Macros_1.scala | 12 ++++++++++++ test/files/run/t7008/Test_2.scala | 9 +++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t7008.check create mode 100644 test/files/run/t7008/Impls_Macros_1.scala create mode 100644 test/files/run/t7008/Test_2.scala (limited to 'test') diff --git a/test/files/lib/javac-artifacts.jar.desired.sha1 b/test/files/lib/javac-artifacts.jar.desired.sha1 index a49c986386..508141b771 100644 --- a/test/files/lib/javac-artifacts.jar.desired.sha1 +++ b/test/files/lib/javac-artifacts.jar.desired.sha1 @@ -1 +1 @@ -61931a51bb1a2d308d214b96d06e9a8808515dcf ?javac-artifacts.jar +a05ca69ac68fa7006b1b8ed98597046e105b4047 ?javac-artifacts.jar diff --git a/test/files/run/t7008.check b/test/files/run/t7008.check new file mode 100644 index 0000000000..ee077f90ff --- /dev/null +++ b/test/files/run/t7008.check @@ -0,0 +1,9 @@ +: List(throws[NullPointerException](classOf[java.lang.NullPointerException])) +bar: List(throws[Exception](classOf[java.lang.Exception])) +baz: List(throws[IllegalStateException](classOf[java.lang.IllegalStateException])) +foo: List(throws[Exception](classOf[java.lang.Exception])) +============= +: List(throws[java.lang.NullPointerException](classOf[java.lang.NullPointerException])) +bar: List(throws[java.lang.Exception](classOf[java.lang.Exception])) +baz: List(throws[java.lang.IllegalStateException](classOf[java.lang.IllegalStateException])) +foo: List(throws[java.lang.Exception](classOf[java.lang.Exception])) diff --git a/test/files/run/t7008/Impls_Macros_1.scala b/test/files/run/t7008/Impls_Macros_1.scala new file mode 100644 index 0000000000..f2eb7425f5 --- /dev/null +++ b/test/files/run/t7008/Impls_Macros_1.scala @@ -0,0 +1,12 @@ +import language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + def impl(c: Context) = { + val decls = c.typeOf[JavaClassWithCheckedExceptions[_]].declarations.toList + val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL) + c.universe.reify(println(c.literal(s).splice)) + } + + def foo = macro impl +} \ No newline at end of file diff --git a/test/files/run/t7008/Test_2.scala b/test/files/run/t7008/Test_2.scala new file mode 100644 index 0000000000..b67faa327f --- /dev/null +++ b/test/files/run/t7008/Test_2.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + Macros.foo + println("=============") + + val decls = typeOf[JavaClassWithCheckedExceptions[_]].declarations.toList + decls sortBy (_.name.toString) foreach (decl => println(s"${decl.name}: ${decl.annotations}")) +} \ No newline at end of file -- cgit v1.2.3