diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-10-07 22:38:52 +0200 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-10-07 22:38:52 +0200 |
commit | 75886dc44366470fb3221aaf4de35e9de9e71a1d (patch) | |
tree | 573061493890622f01cbe62a882f3a00af037928 /test/files/run/t4788/Test.scala | |
parent | 382b33e539c77c3af317b606a1463e2826e60f95 (diff) | |
parent | c14e0532fcd6d68c43a3c974efec9d15b6e4b217 (diff) | |
download | scala-75886dc44366470fb3221aaf4de35e9de9e71a1d.tar.gz scala-75886dc44366470fb3221aaf4de35e9de9e71a1d.tar.bz2 scala-75886dc44366470fb3221aaf4de35e9de9e71a1d.zip |
Merge pull request #4026 from soc/SI-4788-new
SI-4788/SI-5948 Respect RetentionPolicy of Java annotations
Diffstat (limited to 'test/files/run/t4788/Test.scala')
-rw-r--r-- | test/files/run/t4788/Test.scala | 35 |
1 files changed, 35 insertions, 0 deletions
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")) + } +} |