summaryrefslogtreecommitdiff
path: root/test/files/jvm5
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-03-02 13:35:59 +0000
committermichelou <michelou@epfl.ch>2007-03-02 13:35:59 +0000
commit12a3b4c5ffe61ad646c33c59a666386e11429316 (patch)
treef89fa6879d0d22a37ada6ade6886fce5dcf1708b /test/files/jvm5
parent327f88d16802daaddb85b33498a1cfc5b976bd28 (diff)
downloadscala-12a3b4c5ffe61ad646c33c59a666386e11429316.tar.gz
scala-12a3b4c5ffe61ad646c33c59a666386e11429316.tar.bz2
scala-12a3b4c5ffe61ad646c33c59a666386e11429316.zip
added test for @BeanProperty annotation
Diffstat (limited to 'test/files/jvm5')
-rw-r--r--test/files/jvm5/annotations.check2
-rw-r--r--test/files/jvm5/annotations.scala32
2 files changed, 30 insertions, 4 deletions
diff --git a/test/files/jvm5/annotations.check b/test/files/jvm5/annotations.check
index 06d35ddb48..efdd54a237 100644
--- a/test/files/jvm5/annotations.check
+++ b/test/files/jvm5/annotations.check
@@ -4,3 +4,5 @@ class java.io.IOException
@test.SourceAnnotation(mail=scala@lists.epfl.ch, value=http://scala.epfl.ch)
@test.SourceAnnotation(mail=you@bloodsuckers.com, value=http://bloodsuckers.com)
@test.SourceAnnotation(mail=bill.gates@bloodsuckers.com, value=http://bloodsuckers.com)
+0
+99
diff --git a/test/files/jvm5/annotations.scala b/test/files/jvm5/annotations.scala
index fa5ab1476b..e81aa863a8 100644
--- a/test/files/jvm5/annotations.scala
+++ b/test/files/jvm5/annotations.scala
@@ -5,7 +5,7 @@ object Test1 {
@remote
def foo: Unit = ()
}
- def run: Unit = {
+ def run {
val method = classOf[Foo].getMethod("foo", Array())
method.getExceptionTypes foreach Console.println
}
@@ -19,7 +19,7 @@ object Test2 {
@throws(classOf[IOException])
def read() = in.read()
}
- def run: Unit = {
+ def run {
val method = classOf[Reader].getMethod("read", Array())
method.getExceptionTypes foreach Console.println
}
@@ -41,7 +41,7 @@ object Test3 {
@Deprecated
def foo: Unit = ()
}
- def run: Unit = {
+ def run {
val method = classOf[Foo].getMethod("foo", Array())
val annotation = method.getAnnotation(classOf[Deprecated])
Console.println(annotation)
@@ -74,18 +74,42 @@ object Test4 {
class Foo2
@SourceAnnotation("http://bloodsuckers.com")
class Foo3
- def run: Unit = {
+ def run {
classOf[Foo1].getAnnotations foreach Console.println
classOf[Foo2].getAnnotations foreach Console.println
classOf[Foo3].getAnnotations foreach Console.println
}
}
+object Test5 {
+ import scala.reflect.BeanProperty
+ class Count {
+ // we use "Integer" instead of "Int" because of Java reflection
+ @BeanProperty
+ private var count: Integer = 0
+
+ private val getter =
+ getClass().getMethod("getCount", Array[java.lang.Class]())
+ private val setter =
+ getClass().getMethod("setCount", Array[java.lang.Class](classOf[Integer]))
+
+ def get = getter.invoke(this, Array()).asInstanceOf[Integer].intValue
+ def set(n: Int) = setter.invoke(this, Array(new Integer(n)))
+ }
+ def run {
+ val count = new Count
+ Console.println(count.get)
+ count.set(99)
+ Console.println(count.get)
+ }
+}
+
object Test {
def main(args: Array[String]): Unit = {
Test1.run
Test2.run
Test3.run // requires the use of -target:jvm-1.5
Test4.run
+ Test5.run
}
}