Supposed I have these code :
The code will crash at Map "For Each kk as string" line :
Even if I modified the code become this :
Will still crash the same as above
I use B4J 9.80 (64 bit)
Any help ?
B4J code:
Private Sub sioserver_set_audio_configuration(sock As NettySocketWrapper, value As Object, ack As AckRequest)
Log($"Event set_audio_configuration"$)
If (ack <> Null) Then
If (ack.isAckRequested) Then Log("Acknowledge required") Else Log("Acknowledge not required")
Else
Log("ack is null")
End If
If (value<>Null) Then
Dim valtype As String = GetType(value)
Log($"value type = ${valtype}"$)
If (valtype.Contains("Map")) Then
Dim valuemap As Map = value.As(Map)
If (valuemap.IsInitialized) Then
If (valuemap.Size>0) Then
Log($"valuemap size = ${valuemap.Size}"$)
For Each kk As String In valuemap.Keys
Log($"Key = ${kk}, Value = ${valuemap.Get(kk)}"$)
Next
Else
Log("Valuemap size = 0")
End If
Else
Log("Valuemap not initialized")
End If
Else if (value Is String) Then
Log("value is string")
Else
Log("value is something else")
End If
Else
Log($"set_audio_configuration value is null"$)
End If
End Sub
The code will crash at Map "For Each kk as string" line :
crash log:
Will raise sioserver_set_audio_configuration
jSocketIOServer StartListen at Port = 9000
Client Connected, ID = 6c598310-ea7a-43e2-b709-011ffdfba85d
Event get_network_configuration
get_network_configuration value is null
Event get_audio_configuration
get_audio_configuration value is null
valuetype = java.util.LinkedHashMap
value = {volume_input=0, volume_output=0, switchip=false}
Event set_audio_configuration
Acknowledge required
value type = java.util.LinkedHashMap
valuemap size = 3
Error occurred on line: 128 (Main)
java.lang.RuntimeException: method not supported. Use For Each instead.
at anywheresoftware.b4a.objects.collections.Map.GetKeyAt(Map.java:114)
at anywheresoftware.b4a.objects.collections.Map$IterableMap.Get(Map.java:184)
at b4j.example.main._sioserver_set_audio_configuration(main.java:340)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Even if I modified the code become this :
modified For using index:
For ii = 0 To valuemap.Size-1
Log($"Key = ${valuemap.GetKeyAt(ii)}"$)
Log($"Value = ${valuemap.GetValueAt(ii)}"$)
Next
Will still crash the same as above
I use B4J 9.80 (64 bit)
Any help ?
Last edited: