Bug? CallsubDelayed in compiled library generating error

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
This started happening after I upgraded to v7.80, and was working fine in my last version. When including a compiled B4A library (Project, compile to library) I am getting a java.lang.ClassCastException in the compiled library. This same library works fine when ran in the test program I create it with (debug or release). With the following code in the library itself:
B4X:
' Class Globals definitions:
 Private moCallBack As Object
 Private msBaseEvent As String

' internally generated control event handler:
Private Sub lblDropDown_Click
    ShowList
    If moCallBack <> Null Then
        MyLog("Callback not null")
        If SubExists(moCallBack, msBaseEvent & "DropdownOpened") Then
            MyLog("Sub exists - " & msBaseEvent & "DropdownOpened")
            CallSubDelayed(moCallBack, msBaseEvent & "DropdownOpened")
        End If
    End If
End Sub

I pass in "Me" for the callback object from my activity and a base event prefix, I do not have a "prefix_DropdownOpened" in my activity. The log output from the run is:
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Callback not null
java.lang.ClassCastException: anywheresoftware.b4a.BALayout cannot be cast to java.lang.String

If I comment out the "If SubExists(..." block then the library performs as expected with no event handler in the activity. It should be noted that adding a "DropDownOpened" block event handler in the activity does not prevent the error.
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
The "ComboBoxTest" project is the actual library. The "cboTest" project is a test project that includes the generated library.

Generate the library, load the "cobTest" project and run it (debug is fine). Then click on the dropdown triangle to see the error. If you comment out the code I indicated in my original post in the library and run the test again then the combobox scrollview will be displayed and the same error will be generated when the "DropDownClosed" event SubExists(...) method is invoked.

The library functions fine when ran in its own test program as an included class, I'm only seeing this when using the compiled library. This library worked fine until I recompiled it with V7.80.
 

Attachments

  • ComboBoxTest.zip
    14.5 KB · Views: 290
  • cboTest.zip
    8 KB · Views: 314
Last edited:

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Sorry for the delay in replying, I was on vacation for the holidays. You are correct, I mistakenly used "Activity" in place of "Me" when I created the example program. I will see if this is the same case as the live project.

Thanks!
 
Top