B4J Question Getting variable value through reflection?


Well-Known Member
Licensed User
Longtime User
Im trying to get a variable value through reflection.

There is some discussion here;

Based on that thread I can access global variables but I cant access local variables. Is there any way to access local variables within a sub? This is just test code but ultimately the variable name could be anything and wouldnt be hard coded.

Sub Class_Globals
    Dim bob As String = "Hello"
End Sub

Public Sub Initialize

End Sub

Sub Handle(req As ServletRequest, resp As ServletResponse)  
    Dim bob2 As String = "Goodbye"
    Dim jo As JavaObject = Me
    Log(jo.GetField("_bob")) ' Works  
    Log(jo.GetField("_bob2")) ' Does not work
End sub