summaryrefslogtreecommitdiff
path: root/test/files/jvm/throws-annot.scala
diff options
context:
space:
mode:
authorAntonio Cunei <antonio.cunei@epfl.ch>2009-05-15 15:44:54 +0000
committerAntonio Cunei <antonio.cunei@epfl.ch>2009-05-15 15:44:54 +0000
commit10830eaae2955766378369b8d1bcc0e6963b9b7f (patch)
tree595d0d162d94eda17062d4d13710378930b7ac7f /test/files/jvm/throws-annot.scala
parentfbf991833d5ec0d9890ac1e7df9f53209e313552 (diff)
downloadscala-10830eaae2955766378369b8d1bcc0e6963b9b7f.tar.gz
scala-10830eaae2955766378369b8d1bcc0e6963b9b7f.tar.bz2
scala-10830eaae2955766378369b8d1bcc0e6963b9b7f.zip
1.4-related cleanup and reorganization.
Removed a bunch of now useless 1.4 code, merged back jvm5-specific partest tests into the general jvm tests, documentation updates.
Diffstat (limited to 'test/files/jvm/throws-annot.scala')
-rw-r--r--test/files/jvm/throws-annot.scala74
1 files changed, 74 insertions, 0 deletions
diff --git a/test/files/jvm/throws-annot.scala b/test/files/jvm/throws-annot.scala
new file mode 100644
index 0000000000..90b58b9976
--- /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)
+ 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"))
+ }
+}