summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2008-02-01 13:35:13 +0000
committerIulian Dragos <jaguarul@gmail.com>2008-02-01 13:35:13 +0000
commit1e00b1bd3b624efd8eac511d642d289715404bb6 (patch)
treeb425e45acbabb3a6c80f8af1f586fc1d8697b1af /test/files
parent222998874fb15354823e255384bf6ee6d1898d27 (diff)
downloadscala-1e00b1bd3b624efd8eac511d642d289715404bb6.tar.gz
scala-1e00b1bd3b624efd8eac511d642d289715404bb6.tar.bz2
scala-1e00b1bd3b624efd8eac511d642d289715404bb6.zip
Fixed #377.
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"))
+ }
+}