summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/run/t4788-separate-compilation.check5
-rw-r--r--test/files/run/t4788-separate-compilation/CAnnotation_1.java5
-rw-r--r--test/files/run/t4788-separate-compilation/C_1.scala2
-rw-r--r--test/files/run/t4788-separate-compilation/D_1.scala5
-rw-r--r--test/files/run/t4788-separate-compilation/RAnnotation_1.java5
-rw-r--r--test/files/run/t4788-separate-compilation/R_1.scala2
-rw-r--r--test/files/run/t4788-separate-compilation/SAnnotation_1.java5
-rw-r--r--test/files/run/t4788-separate-compilation/S_1.scala2
-rw-r--r--test/files/run/t4788-separate-compilation/Test_2.scala35
-rw-r--r--test/files/run/t4788.check5
-rw-r--r--test/files/run/t4788/C.scala2
-rw-r--r--test/files/run/t4788/CAnnotation.java5
-rw-r--r--test/files/run/t4788/D.scala5
-rw-r--r--test/files/run/t4788/R.scala2
-rw-r--r--test/files/run/t4788/RAnnotation.java5
-rw-r--r--test/files/run/t4788/S.scala2
-rw-r--r--test/files/run/t4788/SAnnotation.java5
-rw-r--r--test/files/run/t4788/Test.scala35
18 files changed, 132 insertions, 0 deletions
diff --git a/test/files/run/t4788-separate-compilation.check b/test/files/run/t4788-separate-compilation.check
new file mode 100644
index 0000000000..172ad90102
--- /dev/null
+++ b/test/files/run/t4788-separate-compilation.check
@@ -0,0 +1,5 @@
+Some(@Ljava/lang/Deprecated;())
+None
+None
+Some(@LCAnnotation;() // invisible)
+Some(@LRAnnotation;())
diff --git a/test/files/run/t4788-separate-compilation/CAnnotation_1.java b/test/files/run/t4788-separate-compilation/CAnnotation_1.java
new file mode 100644
index 0000000000..7120218d62
--- /dev/null
+++ b/test/files/run/t4788-separate-compilation/CAnnotation_1.java
@@ -0,0 +1,5 @@
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.CLASS;
+
+@Retention(value=CLASS)
+@interface CAnnotation {}
diff --git a/test/files/run/t4788-separate-compilation/C_1.scala b/test/files/run/t4788-separate-compilation/C_1.scala
new file mode 100644
index 0000000000..aba9b595e4
--- /dev/null
+++ b/test/files/run/t4788-separate-compilation/C_1.scala
@@ -0,0 +1,2 @@
+@CAnnotation
+class C
diff --git a/test/files/run/t4788-separate-compilation/D_1.scala b/test/files/run/t4788-separate-compilation/D_1.scala
new file mode 100644
index 0000000000..c2479fba86
--- /dev/null
+++ b/test/files/run/t4788-separate-compilation/D_1.scala
@@ -0,0 +1,5 @@
+@Deprecated
+class DJava
+
+@deprecated("", "")
+class DScala
diff --git a/test/files/run/t4788-separate-compilation/RAnnotation_1.java b/test/files/run/t4788-separate-compilation/RAnnotation_1.java
new file mode 100644
index 0000000000..f24cf66f7b
--- /dev/null
+++ b/test/files/run/t4788-separate-compilation/RAnnotation_1.java
@@ -0,0 +1,5 @@
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Retention(value=RUNTIME)
+@interface RAnnotation {}
diff --git a/test/files/run/t4788-separate-compilation/R_1.scala b/test/files/run/t4788-separate-compilation/R_1.scala
new file mode 100644
index 0000000000..ab0cd065d9
--- /dev/null
+++ b/test/files/run/t4788-separate-compilation/R_1.scala
@@ -0,0 +1,2 @@
+@RAnnotation
+class R
diff --git a/test/files/run/t4788-separate-compilation/SAnnotation_1.java b/test/files/run/t4788-separate-compilation/SAnnotation_1.java
new file mode 100644
index 0000000000..471f27d82a
--- /dev/null
+++ b/test/files/run/t4788-separate-compilation/SAnnotation_1.java
@@ -0,0 +1,5 @@
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+@Retention(value=SOURCE)
+@interface SAnnotation {}
diff --git a/test/files/run/t4788-separate-compilation/S_1.scala b/test/files/run/t4788-separate-compilation/S_1.scala
new file mode 100644
index 0000000000..f8756d9bc8
--- /dev/null
+++ b/test/files/run/t4788-separate-compilation/S_1.scala
@@ -0,0 +1,2 @@
+@SAnnotation
+class S
diff --git a/test/files/run/t4788-separate-compilation/Test_2.scala b/test/files/run/t4788-separate-compilation/Test_2.scala
new file mode 100644
index 0000000000..cbbb5ff386
--- /dev/null
+++ b/test/files/run/t4788-separate-compilation/Test_2.scala
@@ -0,0 +1,35 @@
+import java.io.PrintWriter;
+
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm.util._
+import scala.tools.nsc.util.stringFromWriter
+
+object Test extends BytecodeTest {
+ def annotationsForClass(className: String): Option[String] = {
+ val classNode = loadClassNode(className, skipDebugInfo = false)
+ val textifier = new Textifier
+ classNode.accept(new TraceClassVisitor(null, textifier, null))
+
+ val classString = stringFromWriter(w => textifier.print(w))
+ classString
+ .split('\n')
+ .filterNot(_.contains("@Lscala/reflect/ScalaSignature"))
+ .find(_.contains("@L"))
+ .map(_.trim)
+ }
+
+ def show {
+ // It seems like @java.lang.Deprecated shows up in both the
+ // Deprecated attribute and RuntimeVisibleAnnotation attribute,
+ // while @scala.deprecated only shows up in the Deprecated attribute.
+ // The check file just documents status quo, not sure if Scala
+ // should brought in line with Java or not...
+ // See the commit message and SI-8883 for more info.
+ println(annotationsForClass("DJava"))
+ println(annotationsForClass("DScala"))
+
+ println(annotationsForClass("S"))
+ println(annotationsForClass("C"))
+ println(annotationsForClass("R"))
+ }
+}
diff --git a/test/files/run/t4788.check b/test/files/run/t4788.check
new file mode 100644
index 0000000000..172ad90102
--- /dev/null
+++ b/test/files/run/t4788.check
@@ -0,0 +1,5 @@
+Some(@Ljava/lang/Deprecated;())
+None
+None
+Some(@LCAnnotation;() // invisible)
+Some(@LRAnnotation;())
diff --git a/test/files/run/t4788/C.scala b/test/files/run/t4788/C.scala
new file mode 100644
index 0000000000..aba9b595e4
--- /dev/null
+++ b/test/files/run/t4788/C.scala
@@ -0,0 +1,2 @@
+@CAnnotation
+class C
diff --git a/test/files/run/t4788/CAnnotation.java b/test/files/run/t4788/CAnnotation.java
new file mode 100644
index 0000000000..7120218d62
--- /dev/null
+++ b/test/files/run/t4788/CAnnotation.java
@@ -0,0 +1,5 @@
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.CLASS;
+
+@Retention(value=CLASS)
+@interface CAnnotation {}
diff --git a/test/files/run/t4788/D.scala b/test/files/run/t4788/D.scala
new file mode 100644
index 0000000000..c2479fba86
--- /dev/null
+++ b/test/files/run/t4788/D.scala
@@ -0,0 +1,5 @@
+@Deprecated
+class DJava
+
+@deprecated("", "")
+class DScala
diff --git a/test/files/run/t4788/R.scala b/test/files/run/t4788/R.scala
new file mode 100644
index 0000000000..ab0cd065d9
--- /dev/null
+++ b/test/files/run/t4788/R.scala
@@ -0,0 +1,2 @@
+@RAnnotation
+class R
diff --git a/test/files/run/t4788/RAnnotation.java b/test/files/run/t4788/RAnnotation.java
new file mode 100644
index 0000000000..f24cf66f7b
--- /dev/null
+++ b/test/files/run/t4788/RAnnotation.java
@@ -0,0 +1,5 @@
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Retention(value=RUNTIME)
+@interface RAnnotation {}
diff --git a/test/files/run/t4788/S.scala b/test/files/run/t4788/S.scala
new file mode 100644
index 0000000000..f8756d9bc8
--- /dev/null
+++ b/test/files/run/t4788/S.scala
@@ -0,0 +1,2 @@
+@SAnnotation
+class S
diff --git a/test/files/run/t4788/SAnnotation.java b/test/files/run/t4788/SAnnotation.java
new file mode 100644
index 0000000000..471f27d82a
--- /dev/null
+++ b/test/files/run/t4788/SAnnotation.java
@@ -0,0 +1,5 @@
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+@Retention(value=SOURCE)
+@interface SAnnotation {}
diff --git a/test/files/run/t4788/Test.scala b/test/files/run/t4788/Test.scala
new file mode 100644
index 0000000000..cbbb5ff386
--- /dev/null
+++ b/test/files/run/t4788/Test.scala
@@ -0,0 +1,35 @@
+import java.io.PrintWriter;
+
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm.util._
+import scala.tools.nsc.util.stringFromWriter
+
+object Test extends BytecodeTest {
+ def annotationsForClass(className: String): Option[String] = {
+ val classNode = loadClassNode(className, skipDebugInfo = false)
+ val textifier = new Textifier
+ classNode.accept(new TraceClassVisitor(null, textifier, null))
+
+ val classString = stringFromWriter(w => textifier.print(w))
+ classString
+ .split('\n')
+ .filterNot(_.contains("@Lscala/reflect/ScalaSignature"))
+ .find(_.contains("@L"))
+ .map(_.trim)
+ }
+
+ def show {
+ // It seems like @java.lang.Deprecated shows up in both the
+ // Deprecated attribute and RuntimeVisibleAnnotation attribute,
+ // while @scala.deprecated only shows up in the Deprecated attribute.
+ // The check file just documents status quo, not sure if Scala
+ // should brought in line with Java or not...
+ // See the commit message and SI-8883 for more info.
+ println(annotationsForClass("DJava"))
+ println(annotationsForClass("DScala"))
+
+ println(annotationsForClass("S"))
+ println(annotationsForClass("C"))
+ println(annotationsForClass("R"))
+ }
+}