Skip to content

Commit 767ed0f

Browse files
committed
docs: enhance comments in JavaRunner and Runner for clarity
1 parent a4cbd91 commit 767ed0f

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

samples/demo-android/src/main/java/com/highcapable/kavaref/demo/runner/JavaRunner.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,33 @@ private JavaRunner() {
3333
}
3434

3535
public static String run() {
36+
// Enable KavaRef debug level logging.
3637
KavaRef.setLogLevel(KavaRefRuntime.LogLevel.DEBUG);
37-
38+
// Resolve the Test class using KavaRef.
3839
var memberScope = KavaRef.resolveClass(Test.class);
40+
// Create an instance of the Test class using the resolved class.
3941
var test = memberScope.constructor()
4042
.emptyParameters()
4143
.build()
4244
.get(0)
4345
.create();
44-
46+
// Invoke a method, modify a field, and retrieve a value using the resolved class.
4547
memberScope.method()
4648
.name("test")
4749
.parameters(String.class)
4850
.build()
4951
.get(0)
5052
.of(test)
5153
.invoke("reflection test");
52-
54+
// Modify the field 'myTest' and retrieve its value using the resolved class.
5355
memberScope.field()
5456
.name("myTest")
5557
.type(String.class)
5658
.build()
5759
.get(0)
5860
.of(test)
5961
.set("Hello modified reflection test");
60-
62+
// Retrieve the value of the field 'myTest' using the resolved class.
6163
var testString = (String) memberScope.method()
6264
.name("getTest")
6365
.emptyParameters()

samples/demo-android/src/main/java/com/highcapable/kavaref/demo/runner/Runner.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,55 @@ object Runner {
3131

3232
@JvmStatic
3333
fun run(): Pair<String?, String?> {
34+
// Enable KavaRef debug level logging.
3435
KavaRef.logLevel = KavaRefRuntime.LogLevel.DEBUG
3536

37+
// Resolve the Test class using KavaRef.
38+
// Create an instance of the Test class using the resolved class.
3639
val test = Test::class.resolve()
3740
.firstConstructor {
3841
emptyParameters()
3942
}.create()
4043

44+
// Invoke a method, modify a field, and retrieve a value using the resolved class.
45+
// (1) Call from Class.
4146
Test::class.resolve()
4247
.firstMethod {
4348
name = "test"
4449
parameters(String::class)
4550
}.of(test).invoke("reflection test")
4651

52+
// (2) Call from Object.
4753
test.asResolver()
4854
.firstMethod {
4955
name = "test"
5056
parameters(String::class)
5157
}.invoke("reflection test")
5258

59+
// Modify the field 'myTest' and retrieve its value using the resolved class.
60+
// (1) Call from Class.
5361
Test::class.resolve()
5462
.firstField {
5563
name = "myTest"
5664
type = String::class
5765
}.of(test).set("Hello modified reflection test")
5866

67+
// (2) Call from Object.
5968
test.asResolver()
6069
.firstField {
6170
name = "myTest"
6271
type = String::class
6372
}.set("Hello modified reflection test")
6473

74+
// Retrieve the value of the field 'myTest' using the resolved class.
75+
// (1) Call from Class.
6576
val testString1 = Test::class.resolve()
6677
.firstMethod {
6778
name = "getTest"
6879
emptyParameters()
6980
}.of(test).invoke<String>()
7081

82+
// (2) Call from Object.
7183
val testString2 = test.asResolver()
7284
.firstMethod {
7385
name = "getTest"

0 commit comments

Comments
 (0)