B4J Question Wrapping library - not initialized class is not passed as a reference.

mindful

Active Member
Licensed User
I have started wrapping a java library to ease my use of it with B4J (I was using it with JavaObject). I stumbled upon something that I don't get and I can replicate with the ResultSet object.

B4X:
'code module Module1
Sub Process_Globals
    Public rs As ResultSet
End Sub

Sub AppStart(Args() As String)
    Log(rs.IsInitialized) 'rs not initialized
    InitRSInSub(rs)
    Log(rs.IsInitialized) 'rs not initialized
End Sub

Private Sub InitRSInSub(MyRS As ResultSet)
    Dim SQLObject As SQL
    SQLObject.Initialize2(......)   'initialize a connection to the database
    Dim query As String = .....    'create a query
    MyRS = SQLObject.ExecQuery(query)
    Log(MyRS.IsInitialized) 'myrs is initialized but just in the sub's scope
End Sub

I have the same stiution with a class in the library I wrapped. Why isn't "rs" passed as reference ?
 

mindful

Active Member
Licensed User
If I change the InitRSInSub to return a ResultSet it works. So the only explinantion is that the ResultSet object is passed by value and not by reference. But how does B4J do it ?

If I create a class in B4J which I don't initialize then pass it to a sub in which i do the initialization then a passed object is initialized too ....o_O
 
Upvote 0

mindful

Active Member
Licensed User
P.S. I wrapped the class with the AbsObjectWrapper (just like the ResultSet) as I don't do anything to it just want to expose it's methods in b4j.
 
Upvote 0
Top