From 10830eaae2955766378369b8d1bcc0e6963b9b7f Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Fri, 15 May 2009 15:44:54 +0000 Subject: 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. --- test/files/jvm/throws-annot.scala | 74 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 test/files/jvm/throws-annot.scala (limited to 'test/files/jvm/throws-annot.scala') 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")) + } +} -- cgit v1.2.3