style: update demo

This commit is contained in:
2025-09-23 14:39:06 +08:00
parent 3acdee6924
commit 9ef95d7ee2

View File

@@ -30,12 +30,14 @@ import com.highcapable.kavaref.runtime.KavaRefRuntime
fun main() {
// Enable KavaRef debug level logging.
KavaRef.logLevel = KavaRefRuntime.LogLevel.DEBUG
// Resolve the Test class using KavaRef.
// Create an instance of the Test class using the resolved class.
val test = Test::class.resolve()
.firstConstructor {
emptyParameters()
}.create()
// Invoke a method, modify a field, and retrieve a value using the resolved class.
// (1) Call from Class.
Test::class.resolve()
@@ -43,12 +45,14 @@ fun main() {
name = "test"
parameters(String::class)
}.of(test).invoke("reflection test")
// (2) Call from Object.
test.asResolver()
.firstMethod {
name = "test"
parameters(String::class)
}.invoke("reflection test")
// Modify the field 'myTest' and retrieve its value using the resolved class.
// (1) Call from Class.
Test::class.resolve()
@@ -56,12 +60,14 @@ fun main() {
name = "myTest"
type = String::class
}.of(test).set("Hello modified reflection test")
// (2) Call from Object.
test.asResolver()
.firstField {
name = "myTest"
type = String::class
}.set("Hello modified reflection test")
// Retrieve the value of the field 'myTest' using the resolved class.
// (1) Call from Class.
val testString1 = Test::class.resolve()
@@ -69,12 +75,14 @@ fun main() {
name = "getTest"
emptyParameters()
}.of(test).invoke<String>()
// (2) Call from Object.
val testString2 = test.asResolver()
.firstMethod {
name = "getTest"
emptyParameters()
}.invoke<String>()
// Print the value of the field 'myTest'.
println(testString1)
println(testString2)