-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metadata for kotlin-reflect (#25)
- Loading branch information
Showing
12 changed files
with
280 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
metadata/org.jetbrains.kotlin/kotlin-reflect/1.7.10/index.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
"reflect-config.json", | ||
"resource-config.json" | ||
] |
93 changes: 93 additions & 0 deletions
93
metadata/org.jetbrains.kotlin/kotlin-reflect/1.7.10/reflect-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
[ | ||
{ | ||
"condition": { | ||
"typeReachable": "kotlin.reflect.jvm.internal.impl.descriptors.FindClassInModuleKt" | ||
}, | ||
"name": "kotlin.Metadata", | ||
"queryAllDeclaredMethods": true | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "kotlin.reflect.jvm.internal.impl.descriptors.runtime.components.ReflectClassStructure" | ||
}, | ||
"name": "kotlin.Metadata", | ||
"methods": [ | ||
{ | ||
"name": "bv", | ||
"parameterTypes": [] | ||
}, | ||
{ | ||
"name": "d1", | ||
"parameterTypes": [] | ||
}, | ||
{ | ||
"name": "d2", | ||
"parameterTypes": [] | ||
}, | ||
{ | ||
"name": "k", | ||
"parameterTypes": [] | ||
}, | ||
{ | ||
"name": "mv", | ||
"parameterTypes": [] | ||
}, | ||
{ | ||
"name": "pn", | ||
"parameterTypes": [] | ||
}, | ||
{ | ||
"name": "xi", | ||
"parameterTypes": [] | ||
}, | ||
{ | ||
"name": "xs", | ||
"parameterTypes": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "kotlin.reflect.jvm.internal.impl.descriptors.runtime.components.ReflectKotlinClass$Factory" | ||
}, | ||
"name": "kotlin.Metadata" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedMemberScope$OptimizedImplementation" | ||
}, | ||
"name": "kotlin.Metadata", | ||
"queryAllDeclaredMethods": true | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedMemberScope$OptimizedImplementation" | ||
}, | ||
"name": "kotlin.Unit" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "kotlin.reflect.jvm.internal.KDeclarationContainerImpl" | ||
}, | ||
"name": "kotlin.jvm.internal.DefaultConstructorMarker" | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "kotlin.jvm.internal.Reflection" | ||
}, | ||
"name": "kotlin.reflect.jvm.internal.ReflectionFactoryImpl", | ||
"methods": [ | ||
{ | ||
"name": "<init>", | ||
"parameterTypes": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"condition": { | ||
"typeReachable": "kotlin.reflect.jvm.internal.impl.resolve.scopes.DescriptorKindFilter" | ||
}, | ||
"name": "kotlin.reflect.jvm.internal.impl.resolve.scopes.DescriptorKindFilter", | ||
"allPublicFields": true | ||
} | ||
] |
13 changes: 13 additions & 0 deletions
13
metadata/org.jetbrains.kotlin/kotlin-reflect/1.7.10/resource-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"bundles": [], | ||
"resources": { | ||
"includes": [ | ||
{ | ||
"condition": { | ||
"typeReachable": "kotlin.reflect.jvm.internal.impl.serialization.deserialization.builtins.BuiltInsLoaderImpl" | ||
}, | ||
"pattern": "kotlin/.+\\.kotlin_builtins" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"latest": true, | ||
"metadata-version": "1.7.10", | ||
"module": "org.jetbrains.kotlin:kotlin-reflect", | ||
"tested-versions": [ | ||
"1.7.10" | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tests/src/org.jetbrains.kotlin/kotlin-reflect/1.7.10/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
|
||
import org.graalvm.internal.tck.TestUtils | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck" | ||
id "org.jetbrains.kotlin.jvm" version "1.7.10" | ||
} | ||
|
||
String libraryVersion = TestUtils.testedLibraryVersion | ||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-reflect:$libraryVersion" | ||
testImplementation 'org.assertj:assertj-core:3.22.0' | ||
} | ||
|
||
graalvmNative { | ||
agent { | ||
defaultMode = "conditional" | ||
modes { | ||
conditional { | ||
userCodeFilterPath = "user-code-filter.json" | ||
} | ||
} | ||
metadataCopy { | ||
mergeWithExisting = true | ||
inputTaskNames.add("test") | ||
outputDirectories.add("src/test/resources/META-INF/native-image/org.jetbrains.kotlin/kotlin-reflect") | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
tests/src/org.jetbrains.kotlin/kotlin-reflect/1.7.10/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
library.version = 1.7.10 | ||
metadata.dir = org.jetbrains.kotlin/kotlin-reflect/1.7.10 |
20 changes: 20 additions & 0 deletions
20
tests/src/org.jetbrains.kotlin/kotlin-reflect/1.7.10/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
|
||
pluginManagement { | ||
def tckPath = Objects.requireNonNullElse( | ||
System.getenv("GVM_TCK_TCKDIR"), | ||
"../../../../tck-build-logic" | ||
) | ||
includeBuild(tckPath) | ||
} | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT" | ||
} | ||
|
||
rootProject.name = 'kotlin-reflect-tests' |
68 changes: 68 additions & 0 deletions
68
...etbrains.kotlin/kotlin-reflect/1.7.10/src/test/kotlin/kotlinreflect/KotlinReflectTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package kotlinreflect | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import kotlin.reflect.KParameter | ||
import kotlin.reflect.full.createType | ||
import kotlin.reflect.full.memberProperties | ||
|
||
class KotlinReflectTests { | ||
@Test | ||
fun test() { | ||
val klass = Foo::class | ||
val ctor = klass.constructors.first { it.parameters.isEmpty() } | ||
val foo = ctor.call() | ||
|
||
val method = klass.members.first { it.name == "method" } | ||
assertThat(method.parameters).hasSize(1) | ||
assertThat(method.parameters[0].kind).isEqualTo(KParameter.Kind.INSTANCE) | ||
|
||
val methodWithArgs = klass.members.first { it.name == "methodWithArgs" } | ||
assertThat(methodWithArgs.parameters).hasSize(2) | ||
assertThat(methodWithArgs.parameters[1].type).isEqualTo(String::class.createType()) | ||
|
||
val methodWithResult = klass.members.first { it.name == "methodWithResult" } | ||
assertThat(methodWithResult.returnType).isEqualTo(Int::class.createType()) | ||
val result = methodWithResult.call(foo) | ||
assertThat(result).isEqualTo(1) | ||
|
||
val annotatedMethod = klass.members.first { it.name == "annotatedMethod" } | ||
assertThat(annotatedMethod.annotations).hasSize(1) | ||
assertThat(annotatedMethod.annotations[0]).isInstanceOf(TestAnnotation::class.java) | ||
assertThat((annotatedMethod.annotations[0] as TestAnnotation).value).isEqualTo("annotation-on-method") | ||
|
||
val stringProperty = klass.memberProperties.first { it.name == "stringProperty" } | ||
assertThat(stringProperty.returnType).isEqualTo(String::class.createType()) | ||
assertThat(stringProperty.get(foo)).isEqualTo("string-1") | ||
|
||
val annotatedProperty = klass.memberProperties.first { it.name == "annotatedProperty" } | ||
assertThat(annotatedProperty.annotations).hasSize(1) | ||
assertThat(annotatedProperty.annotations[0]).isInstanceOf(TestAnnotation::class.java) | ||
assertThat((annotatedProperty.annotations[0] as TestAnnotation).value).isEqualTo("annotation-on-field") | ||
} | ||
} | ||
|
||
class Foo { | ||
val stringProperty = "string-1" | ||
|
||
@TestAnnotation("annotation-on-field") | ||
val annotatedProperty = 1 | ||
|
||
fun method() { | ||
} | ||
|
||
fun methodWithArgs(first: String) { | ||
} | ||
|
||
fun methodWithResult(): Int = 1 | ||
|
||
@TestAnnotation("annotation-on-method") | ||
fun annotatedMethod() { | ||
} | ||
} | ||
|
||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD, | ||
AnnotationTarget.PROPERTY) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class TestAnnotation(val value: String) | ||
|
9 changes: 9 additions & 0 deletions
9
...n/kotlin-reflect/1.7.10/src/test/resources/META-INF/native-image/test/reflect-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{ | ||
"name": "kotlinreflect.Foo", | ||
"allDeclaredMethods": true, | ||
"allDeclaredFields": true, | ||
"allDeclaredConstructors": true, | ||
"allDeclaredClasses": true | ||
} | ||
] |
10 changes: 10 additions & 0 deletions
10
tests/src/org.jetbrains.kotlin/kotlin-reflect/1.7.10/user-code-filter.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"rules": [ | ||
{ | ||
"excludeClasses": "**" | ||
}, | ||
{ | ||
"includeClasses": "kotlin.**" | ||
} | ||
] | ||
} |