mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
Support parameter names for Java 8 classes in reflection
Also support specifying additional options to javac in codegen tests, which was needed to compile Java sources with the "-parameters" option
This commit is contained in:
5
compiler/testData/codegen/java8/boxWithJava/reflection/realParameterNames/J.java
vendored
Normal file
5
compiler/testData/codegen/java8/boxWithJava/reflection/realParameterNames/J.java
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
public class J {
|
||||
public J(String constructorParam) {}
|
||||
|
||||
public static void foo(int methodParam) {}
|
||||
}
|
||||
15
compiler/testData/codegen/java8/boxWithJava/reflection/realParameterNames/K.kt
vendored
Normal file
15
compiler/testData/codegen/java8/boxWithJava/reflection/realParameterNames/K.kt
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// JAVAC_OPTIONS: -parameters
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
val methodParam = J::foo.parameters.single()
|
||||
if (methodParam.name == null) return "Fail: method parameter has no name"
|
||||
assertEquals("methodParam", methodParam.name)
|
||||
|
||||
val constructorParam = J::class.constructors.single().parameters.single()
|
||||
if (constructorParam.name == null) return "Fail: constructor parameter has no name"
|
||||
assertEquals("constructorParam", constructorParam.name)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
5
compiler/testData/codegen/java8/boxWithJava/reflection/synthesizedParameterNames/J.java
vendored
Normal file
5
compiler/testData/codegen/java8/boxWithJava/reflection/synthesizedParameterNames/J.java
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
public class J {
|
||||
public J(String constructorParam) {}
|
||||
|
||||
public static void foo(int methodParam) {}
|
||||
}
|
||||
13
compiler/testData/codegen/java8/boxWithJava/reflection/synthesizedParameterNames/K.kt
vendored
Normal file
13
compiler/testData/codegen/java8/boxWithJava/reflection/synthesizedParameterNames/K.kt
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
val methodParam = J::foo.parameters.single()
|
||||
if (methodParam.name == null) return "Fail: method parameter has no name"
|
||||
assertEquals("arg0", methodParam.name)
|
||||
|
||||
val constructorParam = J::class.constructors.single().parameters.single()
|
||||
if (constructorParam.name == null) return "Fail: constructor parameter has no name"
|
||||
assertEquals("arg0", constructorParam.name)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user