B4J Question Java error when closing Astream (jSerial library)

yo3ggx

Active Member
Licensed User
Longtime User
I have a java console application which use jSerial library.
When I want to close Astream, before closing the serial port, I get the error:


java.lang.NegativeArraySizeException
at jssc.SerialNativeInterface.readBytes(Native Method)
at jssc.SerialPort.readBytes(SerialPort.java:421)
at anywheresoftware.b4j.serial.Serial$1.read(Serial.java:124)
at anywheresoftware.b4j.serial.Serial$1.read(Serial.java:116)
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:184)
at java.lang.Thread.run(Thread.java:745)
java.lang.RuntimeException: java.lang.NegativeArraySizeException
at anywheresoftware.b4j.serial.Serial$1.read(Serial.java:129)
at anywheresoftware.b4j.serial.Serial$1.read(Serial.java:116)
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:184)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NegativeArraySizeException
at jssc.SerialNativeInterface.readBytes(Native Method)
at jssc.SerialPort.readBytes(SerialPort.java:421)
at anywheresoftware.b4j.serial.Serial$1.read(Serial.java:124)
... 3 more

This error does not affect in any way the functionality of the app, but is logged to the console too.
I have tried:


B4X:
Try
  If Astream.IsInitialized Then Astream.Close
Catch
  //do somthing
End Try
Serial1.Close

but the error is still logged in the console where the application runs.

What can I do to prevent this?

Dan
 

yo3ggx

Active Member
Licensed User
Longtime User
No, serial port is closed after Astream.
In the GUI version of the app I ignore it, as is not visible in the interface, but in the no-GUI mode, the message is displayed in the console.
There is any way to hide it?
As stated in my previous message, a Catch block does not prevent it to be displayed.
 
Upvote 0
Top