Annotations have now retention of "RUNTIME" by default. Java retention is generated as given by kotlin annotation. Annotation rendering changed.

Annotation arguments with default values are rendered as ... if renderDefaultAnnotationArguments is true.
Tests: java retention does not taken into account by Descriptor comparator.
Java retentinon changed to kotlin retention in some tests + one new test with java retention added.
More accurate tests for intentions in byte code (visibility controlled).
This commit is contained in:
Mikhail Glukhikh
2015-07-03 12:11:08 +03:00
parent 4a27b4d614
commit 609d696202
68 changed files with 214 additions and 242 deletions
@@ -1,6 +1,3 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b) class MyClass
fun box(): String {
@@ -15,8 +12,7 @@ fun box(): String {
return "OK"
}
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val i: Int,
val s: Short,
val f: Float,
@@ -1,6 +1,3 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.bool, Foo.c, Foo.str) class MyClass
fun box(): String {
@@ -18,8 +15,7 @@ fun box(): String {
return "OK"
}
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val i: Int,
val s: Short,
val f: Float,
@@ -1,6 +1,3 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.c) class MyClass
fun box(): String {
@@ -16,8 +13,7 @@ fun box(): String {
return "OK"
}
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val i: Int,
val s: Short,
val f: Float,
@@ -1,10 +1,8 @@
import java.lang.annotation.*
import java.lang.reflect.Method
import kotlin.reflect.jvm.java
import kotlin.test.assertEquals
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(val x: String)
annotation(retention = AnnotationRetention.RUNTIME) class Ann(val x: String)
fun testMethod(method: Method, name: String) {
assertEquals("OK", method.getAnnotation(javaClass<Ann>()).x, "On method of test named `$name`")
@@ -1,8 +1,6 @@
import kotlin.reflect.KClass
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME)
annotation
annotation(retention = AnnotationRetention.RUNTIME)
class Ann(val args: Array<KClass<*>>)
fun box(): String {
@@ -1,8 +1,6 @@
import kotlin.reflect.KClass
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME)
annotation
annotation(retention = AnnotationRetention.RUNTIME)
class Ann(val arg: KClass<*>)
fun box(): String {
@@ -1,8 +1,6 @@
import kotlin.reflect.KClass
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME)
annotation
annotation(retention = AnnotationRetention.RUNTIME)
class Ann(vararg val args: KClass<*>)
fun box(): String {
@@ -1,9 +1,6 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import kotlin.platform.platformStatic
Retention(RetentionPolicy.RUNTIME)
annotation class testAnnotation
annotation(retention = AnnotationRetention.RUNTIME) class testAnnotation
class A {
@@ -1,12 +1,8 @@
// KT-5665
import java.lang.annotation.*
annotation(retention = AnnotationRetention.RUNTIME) class First
Retention(RetentionPolicy.RUNTIME)
annotation class First
Retention(RetentionPolicy.RUNTIME)
annotation class Second(val value: String)
annotation(retention = AnnotationRetention.RUNTIME) class Second(val value: String)
enum class E {
@First
@@ -1,10 +1,8 @@
import java.lang.annotation.*
import java.lang.reflect.Method
import kotlin.reflect.jvm.java
import kotlin.test.assertEquals
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(val x: String)
annotation(retention = AnnotationRetention.RUNTIME) class Ann(val x: String)
fun foo0(block: () -> Unit) = block.javaClass
fun foo1(block: (String) -> Unit) = block.javaClass
@@ -1,8 +1,6 @@
import java.lang.annotation.*
import kotlin.test.assertEquals
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(val x: Int)
annotation(retention = AnnotationRetention.RUNTIME) class Ann(val x: Int)
class A {
Ann(1) fun foo(x: Int, y: Int = 2, z: Int) {}
@@ -1,10 +1,7 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import kotlin.reflect.KClass
import kotlin.reflect.jvm.java
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val i: Int = 1,
val s: String = "a",
val a: Ann2 = Ann2(),
@@ -1,7 +1,4 @@
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME)
annotation class First
annotation(retention = AnnotationRetention.RUNTIME) class First
class MyClass() {
public var x: String by Delegate()
@@ -1,6 +1,3 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.bool, Foo.c, Foo.str) class MyClass
fun box(): String {
@@ -18,8 +15,7 @@ fun box(): String {
return "OK"
}
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val i: Int,
val s: Short,
val f: Float,
@@ -1,6 +1,3 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann(i, s, f, d, l, b, bool, c, str) class MyClass
fun box(): String {
@@ -18,8 +15,7 @@ fun box(): String {
return "OK"
}
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val i: Int,
val s: Short,
val f: Float,
@@ -1,6 +1,3 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann(A.B.i) class MyClass
fun box(): String {
@@ -10,8 +7,7 @@ fun box(): String {
return "OK"
}
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(val i: Int)
annotation(retention = AnnotationRetention.RUNTIME) class Ann(val i: Int)
class A {
class B {
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val b: Byte,
val s: Short,
val i: Int,
@@ -1,6 +1,3 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann(i) class MyClass
fun box(): String {
@@ -10,8 +7,7 @@ fun box(): String {
return "OK"
}
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(val i: Int)
annotation(retention = AnnotationRetention.RUNTIME) class Ann(val i: Int)
val i2: Int = 1
val i: Int = i2
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(vararg val p: Int)
annotation(retention = AnnotationRetention.RUNTIME) class Ann(vararg val p: Int)
Ann() class MyClass1
Ann(1) class MyClass2
+1 -5
View File
@@ -1,10 +1,6 @@
package test
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(val c1: Int)
annotation(retention = AnnotationRetention.RUNTIME) class Ann(val c1: Int)
Ann('a' - 'a') class MyClass
+1 -5
View File
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val b: Byte,
val s: Short,
val i: Int,
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Int,
val p2: Int,
val p3: Int,
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Int,
val p2: Short,
val p3: Byte,
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Int,
val p2: Int,
val p3: Int,
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Int,
val p2: Byte,
val p4: Int,
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Int,
val p2: Int,
val p4: Long,
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Byte,
val p2: Short,
val p3: Int,
+1 -5
View File
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Byte,
val p2: Short,
val p3: Int,
+1 -5
View File
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Byte,
val p2: Short,
val p3: Int,
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Byte,
val p2: Short,
val p3: Int,
+1 -5
View File
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Byte,
val p2: Short,
val p3: Int,
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Int,
val p2: Int,
val p3: Int,
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Byte,
val p2: Short,
val p3: Int,
@@ -1,8 +1,4 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val p1: Byte,
val p2: Short,
val p3: Int,
@@ -1,8 +1,6 @@
import kotlin.reflect.KClass
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME)
annotation
annotation(retention = AnnotationRetention.RUNTIME)
class Ann(val args: Array<KClass<*>>)
class O
@@ -1,8 +1,6 @@
import kotlin.reflect.KClass
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME)
annotation
annotation(retention = AnnotationRetention.RUNTIME)
class Ann(val arg: KClass<*>)
class OK
@@ -1,8 +1,6 @@
import kotlin.reflect.KClass
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME)
annotation
annotation(retention = AnnotationRetention.RUNTIME)
class Ann(vararg val args: KClass<*>)
class O
@@ -1,8 +1,6 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import java.lang.annotation.Annotation
Retention(RetentionPolicy.RUNTIME) annotation class foo(val name : String)
annotation(retention = AnnotationRetention.RUNTIME) class foo(val name : String)
class Test() {
foo("OK") fun hello(input : String) {
@@ -0,0 +1,9 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann class MyClass
Retention(RetentionPolicy.RUNTIME)
annotation class Ann
// 1 @LAnn;()
@@ -1,9 +1,7 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann class MyClass
Retention(RetentionPolicy.CLASS)
annotation class Ann
annotation(retention = AnnotationRetention.BINARY) class Ann
// 1 @LAnn;()
// 1 invisible
// 1 @LAnn;()
@@ -1,9 +1,6 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann class MyClass
Retention(RetentionPolicy.RUNTIME)
annotation class Ann
annotation(retention = AnnotationRetention.RUNTIME) class Ann
// 1 @LAnn;()
// 1 @LAnn;()
// 0 invisible
@@ -1,9 +1,5 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann class MyClass
Retention(RetentionPolicy.SOURCE)
annotation class Ann
annotation(retention = AnnotationRetention.SOURCE) class Ann
// 0 @LAnn;()
@@ -1,6 +1,4 @@
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME) annotation class SomeAnnotation(val value: String)
annotation(retention = AnnotationRetention.RUNTIME) class SomeAnnotation(val value: String)
class A {
@SomeAnnotation("OK") val property: Int
@@ -1,6 +1,4 @@
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME) annotation class SomeAnnotation(val value: String)
annotation(retention = AnnotationRetention.RUNTIME) class SomeAnnotation(val value: String)
interface T {
@SomeAnnotation("OK") val property: Int
@@ -1,6 +1,4 @@
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME) annotation class SomeAnnotation(val value: String)
annotation(retention = AnnotationRetention.RUNTIME) class SomeAnnotation(val value: String)
@SomeAnnotation("OK") val property: Int
get() = 42
@@ -1,9 +1,6 @@
package a
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME)
annotation class Ann
annotation(retention = AnnotationRetention.RUNTIME) class Ann
interface Tr {
Ann
@@ -1,8 +1,5 @@
package constants
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
public val b: Byte = 100
public val s: Short = 20000
public val i: Int = 2000000
@@ -14,5 +11,4 @@ public val c: Char = '\u03c0' // pi symbol
public val str: String = ":)"
@Retention(RetentionPolicy.RUNTIME)
public annotation class AnnotationClass(public val value: String)
public annotation(retention = AnnotationRetention.RUNTIME) class AnnotationClass(public val value: String)
@@ -1,5 +1,3 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import a.*
Ann(i, s, f, d, l, b, bool, c, str)
@@ -8,8 +6,7 @@ class MyClass1
Ann(i2, s2, f2, d2, l2, b2, bool2, c2, str2)
class MyClass2
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
annotation(retention = AnnotationRetention.RUNTIME) class Ann(
val i: Int,
val s: Short,
val f: Float,
@@ -1,13 +1,13 @@
package
kotlin.annotation.annotation() java.lang.annotation.Retention(value = RetentionPolicy.CLASS) internal final annotation class my : kotlin.Annotation {
kotlin.annotation.annotation() internal final annotation class my : kotlin.Annotation {
public constructor my()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
kotlin.annotation.annotation() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) internal final annotation class my1 : kotlin.Annotation {
kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) internal final annotation class my1 : kotlin.Annotation {
public constructor my1()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -0,0 +1,6 @@
// ALLOW_AST_ACCESS
package test
target(AnnotationTarget.CLASSIFIER)
public annotation class TargetedAnnotation
@@ -0,0 +1,5 @@
package test
kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() public final annotation class TargetedAnnotation : kotlin.Annotation {
/*primary*/ public constructor TargetedAnnotation()
}
@@ -0,0 +1,3 @@
package test
data class My(val x: Int)
@@ -0,0 +1,9 @@
package test
kotlin.data() internal final class My {
/*primary*/ public constructor My(/*0*/ x: kotlin.Int)
internal final val x: kotlin.Int
internal final fun <get-x>(): kotlin.Int
internal final /*synthesized*/ fun component1(): kotlin.Int
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ...): test.My
}
@@ -2,6 +2,4 @@
//SKIP_IN_RUNTIME_TEST
package test
import java.lang.annotation.*
Retention(RetentionPolicy.RUNTIME) annotation class Anno
annotation(retention = AnnotationRetention.RUNTIME) class Anno
@@ -1,5 +1,5 @@
package test
java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME) kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation {
kotlin.annotation.annotation(retention = AnnotationRetention.RUNTIME) internal final annotation class Anno : kotlin.Annotation {
/*primary*/ public constructor Anno()
}