diff options
author | mihaylov <mihaylov@epfl.ch> | 2006-07-05 12:36:25 +0000 |
---|---|---|
committer | mihaylov <mihaylov@epfl.ch> | 2006-07-05 12:36:25 +0000 |
commit | 4308d3971bc031afcd31a9b4c78b3b06ec80242f (patch) | |
tree | 357e5e3574e4e96514a3e89f0fe355d49b045cf6 /test/files/jvm5 | |
parent | fb129da2516f17f1e28434561c1d921b11a04598 (diff) | |
download | scala-4308d3971bc031afcd31a9b4c78b3b06ec80242f.tar.gz scala-4308d3971bc031afcd31a9b4c78b3b06ec80242f.tar.bz2 scala-4308d3971bc031afcd31a9b4c78b3b06ec80242f.zip |
Created a directory test/files/jvm5/ for test c...
Created a directory test/files/jvm5/ for test cases that run only on JVM
1.5
Diffstat (limited to 'test/files/jvm5')
-rw-r--r-- | test/files/jvm5/attributes.check | 2 | ||||
-rw-r--r-- | test/files/jvm5/attributes.scala | 85 |
2 files changed, 87 insertions, 0 deletions
diff --git a/test/files/jvm5/attributes.check b/test/files/jvm5/attributes.check new file mode 100644 index 0000000000..2793231eac --- /dev/null +++ b/test/files/jvm5/attributes.check @@ -0,0 +1,2 @@ +class java.rmi.RemoteException +class java.io.IOException diff --git a/test/files/jvm5/attributes.scala b/test/files/jvm5/attributes.scala new file mode 100644 index 0000000000..051355a947 --- /dev/null +++ b/test/files/jvm5/attributes.scala @@ -0,0 +1,85 @@ +object Test1 { + class Foo { + [remote] + def foo: Unit = () + } + def run: Unit = { + val method = classOf[Foo].getMethod("foo", Array()) + method.getExceptionTypes foreach Console.println + } +} + +object Test2 { + import java.io._ + class Reader(fname: String) { + private val in = new BufferedReader(new FileReader(fname)) + [throws(classOf[IOException])] + def read() = in.read() + } + def run: Unit = { + val method = classOf[Reader].getMethod("read", Array()) + method.getExceptionTypes foreach Console.println + } +} + +/* Java: +public class Main { + @Deprecated + public void foo() {} + public static void main(String[] args) throws Exception { + Method method = Class.forName("test.Main").getMethod("foo", new Class[]{}); + Annotation annotation = method.getAnnotation(Deprecated.class); + System.out.println(annotation); // @java.lang.Deprecated() + } +} +*/ +object Test3 { + class Foo { + [Deprecated] + def foo: Unit = () + } + def run: Unit = { + val method = classOf[Foo].getMethod("foo", Array()) + val annotation = method.getAnnotation(classOf[Deprecated]) + Console.println(annotation) + } +} + +/* Java: +@Retention(value=RetentionPolicy.RUNTIME) +@interface Source { + public String url(); + public String mail(); +} +@Source(url="http://scala.epfl.ch", mail="scala@lists.epfl.ch") +class Foo {} +public class Main { + public static void main(String[] args) throws Exception { + Class clazz = Class.forName("test.Foo"); + Annotation[] annotations = clazz.getAnnotations(); + for (int i = 0; i < annotations.length; i++) + System.out.println(annotations[i]); + // @test.Main$Source(url=http://scala.epfl.ch, mail=scala@lists.epfl.ch) + } +} +*/ +object Test4 { + import java.lang.annotation._ + [Retention(RetentionPolicy.RUNTIME)] + class Source(url: String, mail: String) extends Attribute + [Source("http://scala.epfl.ch", "scala@lists.epfl.ch")] + class Foo + def run: Unit = { + val clazz = classOf[Foo] + clazz.getAnnotations foreach Console.println + } +} + +object Test { + def main(args: Array[String]): Unit = { + Test1.run + Test2.run + //Test3.run // requires the use of -target:jvm-1.5 + //Test4.run + } +} |