Other B4J v10.7 BETA with optional parameters, jServer 5 and more

Status
Not open for further replies.

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm happy to release a new BETA version of B4J.
The parser has undergone a major refactoring, resulting in performance improvements and providing the potential for new language features. The first one is optional parameters.

Improvements:
Download link: https://www.b4x.com/b4j/files/beta.exe
 

aeric

Expert
Licensed User
Longtime User
sqlite-jdbc.jar included in the internal libraries. The old sqlite-jdbc-3.7.2.jar is also kept for backward compatibility. It is recommended to reference sqlite-jdbc.jar. This jar will be updated from time to time as sqlite evolves. Current version is 3.53.2.
B4XTable will use the newer version?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Examples for optional parameters:

B4X:
'From:
Dim b() As Byte = "aaaa".GetBytes("UTF-8")
'''
Dim s As String = BytesToString(b, 0, b.Length, "UTF-8")

'To:
Dim b() As Byte = "aaaa".GetBytes
'''
Dim s As String = BytesToString(b)

'From:
Dim j As HttpJob
j.Initialize("", Me) 'unused JobName and always "Me"
j.Download(url)

'To:
Dim j As HttpJob
j.Initialize
j.Download(url)
 
Upvote 0

MichalK73

Well-Known Member
Licensed User
Longtime User
1787820967674.png

I still see jServer in the old version, no version 5. Clean install.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Hello Erel
I've not tried it, but does the DefaultValue work something like these, or am I way out like I presume that I am???

Is it like this, maybe...:
public void ConnectWithOptions(String ssid, @DefaultValue("30000") int timeoutMs, @DefaultValue("false") boolean autoReconnect) {
    // Blah blah blah
}

public void setMode(@DefaultValue("AUTO") String mode) {
    // Blah blah blah
}

Hmm...
 
Upvote 0

Toley

Active Member
Licensed User
Longtime User
Hello Erel
I've not tried it, but does the DefaultValue work something like these, or am I way out like I presume that I am???

Is it like this, maybe...:
public void ConnectWithOptions(String ssid, @DefaultValue("30000") int timeoutMs, @DefaultValue("false") boolean autoReconnect) {
    // Blah blah blah
}

public void setMode(@DefaultValue("AUTO") String mode) {
    // Blah blah blah
}

Hmm...
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
I missed that post, thank you 😁
 
Upvote 0

b4x-de

Active Member
Licensed User
Longtime User
I'm very happy about improvements in exception handling. Would you please provide an example for and more insight into the new ThrowException keyword. Thank you very much!
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that these two features are currently available in B4A and B4J, and will soon be added to B4i.
ThrowException:
B4X:
Public Sub SumPositiveNumbers(x As Int, y As Int) As Int
    If x <= 0 Or y <= 0 Then
        ThrowException("Parameters must be positive.")
    End If
    Return x + y
End Sub

StackTrace:
B4X:
Try
    Dim z As Int = SumPositiveNumbers(1, -2)   
    '...
Catch
    Log(LastException)
    Log(LastException.StackTrace)
End Try

(RuntimeException) java.lang.RuntimeException: Parameters must be positive.
java.lang.RuntimeException: Parameters must be positive.
at anywheresoftware.b4a.keywords.Common.ThrowException(Common.java:682)
at b4j.example.main._sumpositivenumbers(main.java:101) <---------------- useful information here
at b4j.example.main._appstart(main.java:59)

at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:117)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:104)
at b4j.example.main.start(main.java:37)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:1589)

Stack traces are more meaningful in release mode.
 
Upvote 0
Status
Not open for further replies.
Top