B4J Question OpenJDK Server VM warning ?

jinyistudio

Well-Known Member
Licensed User
Longtime User
following is my main codes. Blinkstick.jar,hidapi-1.1.jar download library from http://arvydas.github.io/blinkstick-processing/
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
    #AdditionalJar: BlinkStick.jar
    #AdditionalJar: hidapi-1.1.jar
#end region

Sub Process_Globals
    Dim bs1 As jyBlinkstick
    Dim timer1 As Timer
    Dim flow As Boolean
End Sub

Sub AppStart (Args() As String)
    bs1.Initialize(Me,"bs1","1")
    If bs1.findfirst=1 Then
        Log($"serial        : ${bs1.BlinkStick(0).Serial}"$)
        Log($"Version        : ${bs1.BlinkStick(0).version}"$)
        Log($"Product        : ${bs1.BlinkStick(0).Product}"$)
        Log($"Manufacturer    : ${bs1.BlinkStick(0).Manufacturer}"$)
        Log($"info1            : ${bs1.BlinkStick(0).InfoBlock1}"$)
        Log($"info2            : ${bs1.BlinkStick(0).InfoBlock2}"$)
        Log($"Mode2            : ${bs1.BlinkStick(0).Mode}"$)
 
        timer1.Initialize("timer1",1000)
        timer1.Enabled=True
        flow=False
    End If
 
    StartMessageLoop
 
 
End Sub


Sub timer1_tick
    If flow Then
        bs1.BlinkStick(0).setIndexedColor16(0,0,0,0,0)
    Else
        bs1.BlinkStick(0).setIndexedColor16(0,0,Rnd(1,255),Rnd(1,255),Rnd(1,255))
    End If
    flow = Not(flow)
End Sub

Use OpenJDK 11.0.1-BellSoft
I debug mode with b4j-bridge. I get follow messages when i running jo.InitializeStatic("blinkstick.BlinkStick").RunMethod("findFirst", Null) in the raspberry pi ? o_O but windows 10 is OK

Waiting for debugger to connect...
Program started.
OpenJDK Server VM warning: You have loaded library /tmp/libhidapi-jni-6417314661532003353684.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Error occurred on line: 37 (jyBlinkstick)
java.lang.ClassCastException: class java.lang.UnsatisfiedLinkError cannot be cast to class java.lang.Exception (java.lang.UnsatisfiedLinkError and java.lang.Exception are in module java.base of loader 'bootstrap')
at anywheresoftware.b4a.BA.setLastException(BA.java:377)
at b4j.example.jyblinkstick._findfirst(jyblinkstick.java:111)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessor
Impl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:95)
at b4j.example.main.main(main.java:29)
 
Last edited:

jinyistudio

Well-Known Member
Licensed User
Longtime User
The posted error seems to be in findFirst, not findAll
at b4j.example.jyblinkstick._findfirst(jyblinkstick.java:111)
However it looks misspelled. From your posted link in your original thread it should be findFirst with a capital F
Yes, I misspelled it. sorry, I changed !?
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
attach zip is my class
 

Attachments

  • v1.zip
    66.2 KB · Views: 207
Upvote 0

agraham

Expert
Licensed User
Longtime User
I've downloaded BlinkStick.jar and hidapi-1.1.jar from your link and your project runs fine for me - but I don't have a BlinkStick so

Dim blink As JavaObject = jo.InitializeStatic("blinkstick.BlinkStick").RunMethod("findFirst", Null)

returns Null. However it obviously runs findFirst correctly which in turn interrogates hidapi for USB descriptors. However I don't like the look of the decompilled findFirst code as it only tests the first descriptor to see if it is a BlinkStick which is not necessarily true.
Java:
  public static BlinkStick findFirst() {
    Initialize();
    HIDDeviceInfo[] arrayOfHIDDeviceInfo = findAllDescriptors();
    if (arrayOfHIDDeviceInfo.length > 0) {
      BlinkStick blinkStick = new BlinkStick();
      try {
        blinkStick.setDevice(arrayOfHIDDeviceInfo[0].open());
        return blinkStick;
      } catch (Exception exception) {}
    }
    return null
findAll is a better bet as it loops all the returned descriptors and returns an array of Blinksticks, but of course that is zero length when I try it.

Sorry, but I can see nothing wrong without actually having a Blinkstick to try.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Sorry, but I can see nothing wrong without actually having a Blinkstick to try
but I don't have a BlinkStick so
You also need to run it on a Linux system (that's the reason for the BlinkStick.so library)

It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
@jinyistudio : Have you tried the execstack command to see if you can fix the BlinkStick.so library?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
I've downloaded BlinkStick.jar and hidapi-1.1.jar from your link and your project runs fine for me - but I don't have a BlinkStick so

Dim blink As JavaObject = jo.InitializeStatic("blinkstick.BlinkStick").RunMethod("findFirst", Null)

returns Null. However it obviously runs findFirst correctly which in turn interrogates hidapi for USB descriptors. However I don't like the look of the decompilled findFirst code as it only tests the first descriptor to see if it is a BlinkStick which is not necessarily true.
Java:
  public static BlinkStick findFirst() {
    Initialize();
    HIDDeviceInfo[] arrayOfHIDDeviceInfo = findAllDescriptors();
    if (arrayOfHIDDeviceInfo.length > 0) {
      BlinkStick blinkStick = new BlinkStick();
      try {
        blinkStick.setDevice(arrayOfHIDDeviceInfo[0].open());
        return blinkStick;
      } catch (Exception exception) {}
    }
    return null
findAll is a better bet as it loops all the returned descriptors and returns an array of Blinksticks, but of course that is zero length when I try it.

Sorry, but I can see nothing wrong without actually having a Blinkstick to try.
I've downloaded BlinkStick.jar and hidapi-1.1.jar from your link and your project runs fine for me => Windows Or raspberry pi(Linux) ?
 
Upvote 0
Top