L leongcc Member Licensed User Longtime User Jan 10, 2013 #1 I am trying to get used to Reflection. 1) This is an experimental program that gets a "java.lang.ClassNotFoundException". Can someone point out my mistake. Code: Dim r As Reflector Dim args(1) As Object args(0) = 5000 Dim Types(2) As String Types(0) = "java.lang.long" r.RunStaticMethod("SystemClock", "sleep", args, Types) 2) The wiki for Reflection has the following statement appearing in several places: Protected and private methods may be accessed if allowed by any security manager which may be present. Click to expand... I am curious what security manager would allow access to private methods. Is this a hint that there is an undocumented "AllowRunPrivateMethod" function in Reflection ?
I am trying to get used to Reflection. 1) This is an experimental program that gets a "java.lang.ClassNotFoundException". Can someone point out my mistake. Code: Dim r As Reflector Dim args(1) As Object args(0) = 5000 Dim Types(2) As String Types(0) = "java.lang.long" r.RunStaticMethod("SystemClock", "sleep", args, Types) 2) The wiki for Reflection has the following statement appearing in several places: Protected and private methods may be accessed if allowed by any security manager which may be present. Click to expand... I am curious what security manager would allow access to private methods. Is this a hint that there is an undocumented "AllowRunPrivateMethod" function in Reflection ?
Erel B4X founder Staff member Licensed User Longtime User Jan 10, 2013 #2 Code: r.RunStaticMethod("android.os.SystemClock", "sleep", args, Types) 2) You can access private and protected in Android. Upvote 0
Code: r.RunStaticMethod("android.os.SystemClock", "sleep", args, Types) 2) You can access private and protected in Android.
L leongcc Member Licensed User Longtime User Jan 10, 2013 #3 Thanks for the reply. 1) I have tried this already, same error generated. I have also checked that android.os.Bundle is imported. Please advise if there is any place I should check. Code: r.RunStaticMethod("android.os.SystemClock", "sleep", args, Types) 2) Android does not allow calling private method of system class. eg. private method setPin() in class BluetoothDevice. So I think the wiki and you mean the private methods of my/another applications? Upvote 0
Thanks for the reply. 1) I have tried this already, same error generated. I have also checked that android.os.Bundle is imported. Please advise if there is any place I should check. Code: r.RunStaticMethod("android.os.SystemClock", "sleep", args, Types) 2) Android does not allow calling private method of system class. eg. private method setPin() in class BluetoothDevice. So I think the wiki and you mean the private methods of my/another applications?
Erel B4X founder Staff member Licensed User Longtime User Jan 10, 2013 #4 1) The size of Types is 2 instead of 1. Note that you can write it like this: Code: r.RunStaticMethod("android.os.SystemClock", "sleep", Array As Object(5000), _| Array As String("java.lang.long") Sleeping for 5 seconds may cause an ANR dialog to appear. There is no good reason to block the main thread for 5 seconds. 2) I haven't tried to call this method. Though if there is any error it is not related to the reflection call. Upvote 0
1) The size of Types is 2 instead of 1. Note that you can write it like this: Code: r.RunStaticMethod("android.os.SystemClock", "sleep", Array As Object(5000), _| Array As String("java.lang.long") Sleeping for 5 seconds may cause an ANR dialog to appear. There is no good reason to block the main thread for 5 seconds. 2) I haven't tried to call this method. Though if there is any error it is not related to the reflection call.