diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-05-04 14:01:58 +0000 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-05-04 14:01:58 +0000 |
commit | 02ad6bb9666161e04e0b9ed3a8ffb6b0e2304596 (patch) | |
tree | dca5f24eb228049d81cec52d217d79050614cdbe /test/files/jvm | |
parent | 7abeacab53286233d4b150e713ca253c08f38bfd (diff) | |
download | scala-02ad6bb9666161e04e0b9ed3a8ffb6b0e2304596.tar.gz scala-02ad6bb9666161e04e0b9ed3a8ffb6b0e2304596.tar.bz2 scala-02ad6bb9666161e04e0b9ed3a8ffb6b0e2304596.zip |
fix and test where constructor parameter annota...
fix and test where constructor parameter annotations end up. no review
Diffstat (limited to 'test/files/jvm')
-rw-r--r-- | test/files/jvm/annotations.check | 11 | ||||
-rw-r--r-- | test/files/jvm/annotations.scala | 31 |
2 files changed, 36 insertions, 6 deletions
diff --git a/test/files/jvm/annotations.check b/test/files/jvm/annotations.check index 128f8e8f6e..fe14289381 100644 --- a/test/files/jvm/annotations.check +++ b/test/files/jvm/annotations.check @@ -23,7 +23,7 @@ public Test4$Foo6(java.lang.String) public Test4$Foo7() @test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=constructor val) -private final int Test4$Foo8.n +public Test4$Foo8(int) @test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=http://eppli.com) private int Test4$Foo9.z @@ -37,5 +37,14 @@ public int Test4$Foo9.x() @test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=http://uppla.com) public void Test4$Foo9.setY(int) +@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=on param 1) +public Test4$Foo10(java.lang.String) + +@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=on param 2) +private final java.lang.String Test4$Foo11.name + +@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=on param 3) +public void Test4$Foo12.name_$eq(java.lang.String) + 0 99 diff --git a/test/files/jvm/annotations.scala b/test/files/jvm/annotations.scala index 12760beb4e..136aae6675 100644 --- a/test/files/jvm/annotations.scala +++ b/test/files/jvm/annotations.scala @@ -102,17 +102,20 @@ object Test4 { type myAnn = SourceAnnotation @beanGetter @field @BeanProperty @myAnn("http://eppli.com") var z = 0 } + class Foo10(@SourceAnnotation("on param 1") val name: String) + class Foo11(@(SourceAnnotation @scala.annotation.target.field)("on param 2") val name: String) + class Foo12(@(SourceAnnotation @scala.annotation.target.setter)("on param 3") var name: String) def run { import java.lang.annotation.Annotation import java.lang.reflect.AnnotatedElement + def printSourceAnnotation(a: Annotation) { + val ann = a.asInstanceOf[SourceAnnotation] + println("@test.SourceAnnotation(mails=" + ann.mails.deepMkString("{", ",", "}") + + ", value=" + ann.value + ")") + } def printSourceAnnotations(target: AnnotatedElement) { //print SourceAnnotation in a predefined way to insure // against difference in the JVMs (e.g. Sun's vs IBM's) - def printSourceAnnotation(a: Annotation) { - val ann = a.asInstanceOf[SourceAnnotation] - println("@test.SourceAnnotation(mails=" + ann.mails.deepMkString("{", ",", "}") + - ", value=" + ann.value + ")") - } val anns = target.getAnnotations() anns foreach printSourceAnnotation if (anns.length > 0) { @@ -120,6 +123,14 @@ object Test4 { println } } + def printParamSourceAnnotations(target: { def getParameterAnnotations(): Array[Array[Annotation]] }) { + val anns = target.getParameterAnnotations().flatten + anns foreach printSourceAnnotation + if (anns.length > 0) { + println(target) + println + } + } printSourceAnnotations(classOf[Foo1]) printSourceAnnotations(classOf[Foo2]) printSourceAnnotations(classOf[Foo3]) @@ -130,8 +141,18 @@ object Test4 { classOf[Foo7].getDeclaredConstructors foreach printSourceAnnotations classOf[Foo8].getDeclaredFields foreach printSourceAnnotations classOf[Foo8].getDeclaredMethods foreach printSourceAnnotations + classOf[Foo8].getDeclaredConstructors foreach printParamSourceAnnotations classOf[Foo9].getDeclaredFields.sortWith((x, y) => x.toString < y.toString) foreach printSourceAnnotations classOf[Foo9].getDeclaredMethods.sortWith((x, y) => x.toString < y.toString) foreach printSourceAnnotations + classOf[Foo10].getDeclaredFields.sortWith((x, y) => x.toString < y.toString) foreach printSourceAnnotations + classOf[Foo10].getDeclaredMethods.sortWith((x, y) => x.toString < y.toString) foreach printSourceAnnotations + classOf[Foo10].getDeclaredConstructors foreach printParamSourceAnnotations + classOf[Foo11].getDeclaredFields.sortWith((x, y) => x.toString < y.toString) foreach printSourceAnnotations + classOf[Foo11].getDeclaredMethods.sortWith((x, y) => x.toString < y.toString) foreach printSourceAnnotations + classOf[Foo11].getDeclaredConstructors foreach printParamSourceAnnotations + classOf[Foo12].getDeclaredFields.sortWith((x, y) => x.toString < y.toString) foreach printSourceAnnotations + classOf[Foo12].getDeclaredMethods.sortWith((x, y) => x.toString < y.toString) foreach printSourceAnnotations + classOf[Foo12].getDeclaredConstructors foreach printParamSourceAnnotations } } |