[Solved] My Java dies on Thread::sleep(*)

  • Platform information:
    • Hardware: KVM based virtual machine with plenty of resources on HP/Intel hardware
    • OS: OpenSUSE Leap 15.0
    • Java Runtime Environment: java-10-openjdk-headless-10.0.2.0 java-10-openjdk-10.0.2.0
    • openHAB version: openhab2-2.4.0
  • Issue of the topic: Based on the example OpenHAB Exec Binding explained in detail on 433MHz radio transmitter example I have managed to setup rules which control some serial devices. After some struggles every thing now works as expected - except when I insert the sleep function. Then I get a ugly java dump in my log. (The send command executes in about 20 mSec. so it wil only be triggered in rare cases)
  • Please post configurations (if applicable):
    • Rules code related to the issue
  when
    Member of gDIOrelays received command
  then
    val num = triggeringItem.name.toString.split("DIOrelay_").get(1) 
//     while(rs485_send.state != OFF){
    Thread::sleep(5)  //   <--- kills jre
//     }
    if(receivedCommand == ON){
      rs485_send_Args.sendCommand("#021" + num +"01")
    }else{
      rs485_send_Args.sendCommand("#021" + num +"00")
    }
 end
  • If logs where generated please post these here using code fences:
2019-05-18 13:36:24.084 [ERROR] [access.reflect.ReflectionTypeFactory] - class org.eclipse.xtext.common.types.access.reflect.ReflectionTypeFactory cannot access interface jdk.internal.vm.annotation.Contended (in module java.base) because module java.base does not export jdk.internal.vm.annotation to unnamed module @32d54242
java.lang.IllegalAccessException: class org.eclipse.xtext.common.types.access.reflect.ReflectionTypeFactory cannot access interface jdk.internal.vm.annotation.Contended (in module java.base) because module java.base does not export jdk.internal.vm.annotation to unnamed module @32d54242
        at jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:360) ~[?:?]
        at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:589) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:556) ~[?:?]

followed by several pages, full log at http://vink-slott.dk/aema2Uho/openhab.log

Should I use another java version or do the community have any other suggestions?

Thanks
Klaus

You should downgrade to java 8:

OK, thanks. That solved it. But is’nt Java 8 quite old at this time? On my system I have the choice of 8, 10 and 11.

Support for newer java is on the way and I think also proofed to work. Not yet recomended though.

In the past there has been reports about problems with OpenJDK. Searching this forum gives more on this topic. You can try newer java with Oracle or Zulu java.

openHAB 2.4 works only with java 8.
openHAB 2.5 will work with Java 8 and newer. Except serial interfaces. The library that we use has serious problems on java 11 and Windows and upstream doesn’t know how to fix them.

1 Like

God to know. The problem using thread:sleep was the only one I encountered before downgrading, but then again - I am quite new to OH and have only interfaced a few things yet.
Actually I do interface to a serial device, but I opted to use the exec binding and handle the serial stuff in python due to that I already had a functional program.