Bug? Obfuscation and resumable subs

OliverA

Expert
Licensed User
Longtime User
Using the line(s)
B4X:
    HandleUploads
If False Then CallSub(Me, "HandleUploads") 'to avoid obfuscation issues
causes an compilation error in Release and Release (obfuscated) modes when the HandleUpload sub is a resumable sub. The compiler will produce the following output:
B4J version: 5.51
Parsing code. (0.01s)
Compiling code. (0.09s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Compiling generated Java code. Error
B4J line: 66
End Sub
javac 1.8.0_112
src\b4j\example\uploader.java:287: error: incompatible types: void cannot be converted to Object
return _handleuploads();
^
1 error

Please note that I'm just using this type of code because I found it in the ClientKVS code (https://www.b4x.com/android/forum/threads/b4x-cloudkvs-synchronized-key-value-store.63536/) and with an explanation for this code provided in this thread (https://www.b4x.com/android/forum/threads/if-false-then-in-cloudkvs.72453/#content). I do not use obfuscated code, but I thought to just include it in my programming practices. It may turn out not to be a bug, but just a fact that Subs handled this way may not be resumable.

I'm attaching two projects, one that causes the compilation error and one with the workaround.
Note#1: The code is just for demonstration purposes and is not really functional beyond that point.
Note#2: Under windows, the code will create a subfolder named "ScanServer" in AppData\Roaming that needs to be manually cleaned up.
 

Attachments

  • ScanServer.issue.zip
    6 KB · Views: 265
  • ScanServer.workaround.zip
    6.3 KB · Views: 254

OliverA

Expert
Licensed User
Longtime User
Would somebody please move this to the B4J forum Bugs/Wishes list. Thank you, Oliver.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that the "dummy" CallSub is no longer required. The compiler will not obfuscate that name because it now recognizes the usage in this line:
B4X:
csu.CallSubDelayedPlus(Me, "HandleQueue", 30000) 'in the CloudKVS client code

There is a bug here. It is not related to obfuscation. It is related to an optimization of CallSub calls to class methods (in release mode).
It is fixed for the next update.

As a workaround for now (when it is needed):
B4X:
'change
CallSub(Object, "Sub1")
'to:
CallSub(Object, "" & "Sub1")
 
Top