summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/jvm/throws-annot.check21
-rw-r--r--test/files/jvm/throws-annot.scala74
2 files changed, 95 insertions, 0 deletions
diff --git a/test/files/jvm/throws-annot.check b/test/files/jvm/throws-annot.check
new file mode 100644
index 0000000000..a0ed82b106
--- /dev/null
+++ b/test/files/jvm/throws-annot.check
@@ -0,0 +1,21 @@
+read throws: class java.io.IOException
+read annotations:
+readWith2 throws: class java.lang.ClassCastException, class java.io.IOException
+readWith2 annotations:
+readMixed throws: class java.io.IOException, class java.lang.NullPointerException
+readMixed annotations: @java.lang.Deprecated()
+readMixed2 throws: class java.io.IOException, class java.lang.NullPointerException
+readMixed2 annotations: @java.lang.Deprecated()
+readNoEx throws:
+readNoEx annotations: @java.lang.Deprecated()
+Testing mirror class
+read throws: class java.io.IOException
+read annotations:
+readWith2 throws: class java.lang.ClassCastException, class java.io.IOException
+readWith2 annotations:
+readMixed throws: class java.io.IOException, class java.lang.NullPointerException
+readMixed annotations: @java.lang.Deprecated()
+readMixed2 throws: class java.io.IOException, class java.lang.NullPointerException
+readMixed2 annotations: @java.lang.Deprecated()
+readNoEx throws:
+readNoEx annotations: @java.lang.Deprecated()
diff --git a/test/files/jvm/throws-annot.scala b/test/files/jvm/throws-annot.scala
new file mode 100644
index 0000000000..5f4dac07e8
--- /dev/null
+++ b/test/files/jvm/throws-annot.scala
@@ -0,0 +1,74 @@
+/** Test the @throws annotation */
+import java.io.IOException
+
+object TestThrows {
+
+ abstract class Foo {
+
+ @throws(classOf[IOException])
+ def read(): Int
+
+ @throws(classOf[ClassCastException])
+ @throws(classOf[IOException])
+ def readWith2(): Int
+
+ @throws(classOf[IOException])
+ @Deprecated
+ @throws(classOf[NullPointerException])
+ def readMixed(): Int
+
+ @Deprecated
+ @throws(classOf[IOException])
+ @throws(classOf[NullPointerException])
+ def readMixed2(): Int
+
+ @Deprecated
+ def readNoEx(): Int
+ }
+
+ def checkMethod(cls: Class[_], name: String) {
+ val method = cls.getMethod(name, Array())
+ println(name + " throws: " + method.getExceptionTypes.mkString("", ", ", ""))
+ println(name + " annotations: " + method.getDeclaredAnnotations.mkString("", ", ", ""))
+ }
+
+ def run(cls: Class[_]) {
+ checkMethod(cls, "read")
+ checkMethod(cls, "readWith2")
+ checkMethod(cls, "readMixed")
+ checkMethod(cls, "readMixed2")
+ checkMethod(cls, "readNoEx")
+ }
+}
+
+/** Test the top-level mirror that is has the annotations. */
+object TL {
+
+ @throws(classOf[IOException])
+ def read(): Int = 0
+
+ @throws(classOf[ClassCastException])
+ @throws(classOf[IOException])
+ def readWith2(): Int = 0
+
+ @throws(classOf[IOException])
+ @Deprecated
+ @throws(classOf[NullPointerException])
+ def readMixed(): Int = 0
+
+ @Deprecated
+ @throws(classOf[IOException])
+ @throws(classOf[NullPointerException])
+ def readMixed2(): Int = 0
+
+ @Deprecated
+ def readNoEx(): Int = 0
+}
+
+object Test {
+ def main(args: Array[String]) {
+ TestThrows.run(classOf[TestThrows.Foo])
+ println("Testing mirror class")
+ TestThrows.run(Class.forName("TL"))
+ }
+}