diff options
author | michelou <michelou@epfl.ch> | 2008-02-04 09:47:40 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2008-02-04 09:47:40 +0000 |
commit | d8e9f6cd938ef9f4b8eb24c5e89d62accd1a310c (patch) | |
tree | 9f22d216cee361cad782dff893d93c302f51f03b /test/files/jvm5/throws-annot.scala | |
parent | 17688db317d8e2e3a31297f56b830f8a783b8d13 (diff) | |
download | scala-d8e9f6cd938ef9f4b8eb24c5e89d62accd1a310c.tar.gz scala-d8e9f6cd938ef9f4b8eb24c5e89d62accd1a310c.tar.bz2 scala-d8e9f6cd938ef9f4b8eb24c5e89d62accd1a310c.zip |
moved test to jvm5
Diffstat (limited to 'test/files/jvm5/throws-annot.scala')
-rw-r--r-- | test/files/jvm5/throws-annot.scala | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/test/files/jvm5/throws-annot.scala b/test/files/jvm5/throws-annot.scala new file mode 100644 index 0000000000..5f4dac07e8 --- /dev/null +++ b/test/files/jvm5/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")) + } +} |