diff options
Diffstat (limited to 'test/files/jvm')
-rw-r--r-- | test/files/jvm/annotations.check | 11 | ||||
-rw-r--r-- | test/files/jvm/annotations.scala | 31 | ||||
-rw-r--r-- | test/files/jvm/genericNest.scala (renamed from test/files/jvm/genericNest/genericNest.scala) | 0 | ||||
-rw-r--r-- | test/files/jvm/genericNest/genericNest.jar.desired.sha1 | 1 | ||||
-rw-r--r-- | test/files/jvm/lib/annotations.jar.desired.sha1 | 1 | ||||
-rw-r--r-- | test/files/jvm/lib/nest.jar.desired.sha1 | 1 | ||||
-rw-r--r-- | test/files/jvm/methvsfield.java | 11 | ||||
-rw-r--r-- | test/files/jvm/methvsfield.scala | 4 | ||||
-rw-r--r-- | test/files/jvm/nest.java | 38 | ||||
-rw-r--r-- | test/files/jvm/nest.scala | 21 | ||||
-rw-r--r-- | test/files/jvm/outerEnum.scala (renamed from test/files/jvm/outerEnum/outerEnum.scala) | 0 | ||||
-rw-r--r-- | test/files/jvm/outerEnum/enums.jar.desired.sha1 | 1 | ||||
-rw-r--r-- | test/files/jvm/t1652.check | 2 |
13 files changed, 112 insertions, 10 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 } } diff --git a/test/files/jvm/genericNest/genericNest.scala b/test/files/jvm/genericNest.scala index c1b0210117..c1b0210117 100644 --- a/test/files/jvm/genericNest/genericNest.scala +++ b/test/files/jvm/genericNest.scala diff --git a/test/files/jvm/genericNest/genericNest.jar.desired.sha1 b/test/files/jvm/genericNest/genericNest.jar.desired.sha1 deleted file mode 100644 index e9321262f2..0000000000 --- a/test/files/jvm/genericNest/genericNest.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -b1ec8a095cec4902b3609d74d274c04365c59c04 ?genericNest.jar diff --git a/test/files/jvm/lib/annotations.jar.desired.sha1 b/test/files/jvm/lib/annotations.jar.desired.sha1 deleted file mode 100644 index 2b4292d796..0000000000 --- a/test/files/jvm/lib/annotations.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -02fe2ed93766323a13f22c7a7e2ecdcd84259b6c ?annotations.jar diff --git a/test/files/jvm/lib/nest.jar.desired.sha1 b/test/files/jvm/lib/nest.jar.desired.sha1 deleted file mode 100644 index 674ca79a5b..0000000000 --- a/test/files/jvm/lib/nest.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -cd33e0a0ea249eb42363a2f8ba531186345ff68c ?nest.jar diff --git a/test/files/jvm/methvsfield.java b/test/files/jvm/methvsfield.java new file mode 100644 index 0000000000..dadc98669a --- /dev/null +++ b/test/files/jvm/methvsfield.java @@ -0,0 +1,11 @@ +// This should be compiled with javac and saved +// in ../lib/methvsfield.jar . +class MethVsField +{ + int three = 3; + + int three() + { + return 3; + } +} diff --git a/test/files/jvm/methvsfield.scala b/test/files/jvm/methvsfield.scala new file mode 100644 index 0000000000..e9795ec6a8 --- /dev/null +++ b/test/files/jvm/methvsfield.scala @@ -0,0 +1,4 @@ +// bug #1062 +object Test extends Application { + println((new MethVsField).three) +} diff --git a/test/files/jvm/nest.java b/test/files/jvm/nest.java new file mode 100644 index 0000000000..3f6f0bebbd --- /dev/null +++ b/test/files/jvm/nest.java @@ -0,0 +1,38 @@ +package nestpkg; + + +/** This file is needed for test 'nest.scala'. It should + * be compiled with javac and packaged into lib/nest.jar + */ +public class nest { + public static class best { + public static class rest { + public static rest test = new rest(); + public static int x = 10; + public int inc(int i) { + return i + 1; + } + } + } + + + String name = "Outer name"; + + public class Inn { + int x; + + public Inn(int x) { + this.x = x; + } + + public void doSomething() { + System.out.println("Inn " + name + " x: " + x); + } + } + + protected class ProtInn { + public void doSomething() { + System.out.println("ProtInn " + name); + } + } +} diff --git a/test/files/jvm/nest.scala b/test/files/jvm/nest.scala new file mode 100644 index 0000000000..3ab62484fa --- /dev/null +++ b/test/files/jvm/nest.scala @@ -0,0 +1,21 @@ +//############################################################################ +// Test Scala interaction with Java nested classes and static members. +//############################################################################ + +/** found in nest.jar, compiled from nest.java */ +import nestpkg._; + +object Test extends Application { + val x = nest.best.rest.test + Console.println(x.inc(1)) + + val o = new nest.best; + val r = new nest.best.rest; + Console.println(nest.best.rest.test.inc(2)) + Console.println(nest.best.rest.x) + + print("Instantiating public inner class: ") + val outer = new nest + val inn = new outer.Inn(42) + inn.doSomething +} diff --git a/test/files/jvm/outerEnum/outerEnum.scala b/test/files/jvm/outerEnum.scala index 18794b7dbe..18794b7dbe 100644 --- a/test/files/jvm/outerEnum/outerEnum.scala +++ b/test/files/jvm/outerEnum.scala diff --git a/test/files/jvm/outerEnum/enums.jar.desired.sha1 b/test/files/jvm/outerEnum/enums.jar.desired.sha1 deleted file mode 100644 index 46cd8e92cf..0000000000 --- a/test/files/jvm/outerEnum/enums.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -981392dbd1f727b152cd1c908c5fce60ad9d07f7 ?enums.jar diff --git a/test/files/jvm/t1652.check b/test/files/jvm/t1652.check new file mode 100644 index 0000000000..dfa480ce6e --- /dev/null +++ b/test/files/jvm/t1652.check @@ -0,0 +1,2 @@ +OK1 +OK2 |