-
-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arduino 1:1.8.9-3(compiled with jdk9?) ByteBuffer breaks libraries #8903
Comments
Just rolled back to package version 1:1.8.9-1, and everything works fine. |
@NicoHood maybe you lost this 😉 |
Same issue here. Rolling back to 1:1.8.9-1 working :) |
What should I do to fix this?? |
I think compiling with java8 should fix it |
But shouldn't Arduino support java 8 and all higher versions? |
I think you need to compile the jars with java 8 exactly, so the dependency here should be |
Ok figure it out, for some reason arch defaults to jdk8, you have to manually set java to a higher version. |
I am not very familiar with java programming. Code compiled with java will only run with java8 interpreter? Or will it run with 8 and every version above? Is the problem that I've compiled the code with java 11, but with an old java8 interpreter it crashes? Changing the OS java version does not sound like a solution, more a workaround. Can somebody please explain me better how this works? |
Kind of a moot point, since the Arduino IDE bundles the correct Java JRE which precisely matches the version of the Java SDK they used to build the code. |
@NicoHood as @PaulStoffregen says, the Java SDK should probably be used. The reason is not all Java 8's are the same. On my arch linux system, just updated:
I have java 8 installed as my default:
And the version reported by java is 1.8.0_212:
Which is slightly different from the version provided by arduino-1.8.9, 1.8.0_191:
And I don't get the "NoSuchMethodError" when I'm using arduino-1.8.9 directly but I do get this error when I install the Arch Linux arduino package. A workaround that is suggested in the Arch Linux bug report 62704 of changing to java 10 or 11 does resolve this bug but then I get some warnings:
So it seems it would be best to change Arch Linux arduino PKGBUILD to use the java provided by arduino and not the system installed version. |
Seems to me this is a problem with Arch Linux. The software Arduino.cc distributes always has the correct JRE bundled, so I do not believe reporting the problem here is correct. |
Hi, i confirm with Java 12 i had issue with the menu theme of Arduino Ide. Reinstalling Java 8 and setting: This was the output running arduino ide with Java 12 as default:
|
I can not access Serial using Java 8 and Arduino Java 12 is not affected by that problem, but shows warnings as reported from some of you. |
I had this same issue on Arch Linux. Using java-8-jdk, the error didn't come up again (and the monitor functioned properly) after switching to java-10-openjdk. This was done by issueing the command:
|
Is there a way to fix java compatibility in the arduino IDE, so users do not need to switch their java version? And another question for packaging arduino: Is the compiling java version a problem, or the running java version? From the comments I understood that only the java runtime version is important. I could add a simple wrapper around the arduino executable that forces to start with java8 (unless the bugs are fixed with newer java versions). |
The implementation is much more straightforward. It should also solve a JDK incompatiblity: java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer; at processing.app.Serial.serialEvent(Serial.java:185) at jssc.SerialPort$LinuxEventThread.run(SerialPort.java:1299) See arduino#8903
on arch, same problem, fixed by @PaulStoffregen, you say
Then why it isn't used when people start on arch using "#> arduino"? |
@molecular A new arduino version was released on arch. Could you please try if it work with java 11 and 14 on your system?
It should work with both, but please try it out. |
On my system with Arduino 1.8.13 from the Arch repository, the Serial monitor works with both java 11 and 14 (though it has been a little circumstantial in the past). I don't know if java 8 is still relevant, but with java-8-openjdk, I still get an error:
|
@facchinm Is this something the arduino team is able to fix, or should I bump the minimum required java version to 11 for the arch package? |
@NicoHood There's a branch https://github.com/cmaglie/Arduino/tree/java-11 for java11 full compatibility but it still needs some testing. |
@facchinm My experience is that the Serial monitor does not work with java-8-openjdk, so I don't see why this version should be forced.. On another note, what is the root cause of this bug? A method that is available in the "bundled JRE" but not in the openjdk? If it's just one misbehaving method, could we replace it with something else that works across the board? |
@gkatev it doesn't work because the package gets compiled using java11 if it's already installed. If you force the PKGBUILD to use jdk8 the package will run seamlessly (I'm on Arch BTW 😉 ) |
@facchinm thanks for this note, I will update the package! However I was unable to reproduce the bug @gkatev reported with java8. On my system the serial monitor seems to work. And I made sure, that archlinux-java was set to 8 of course. @gkatev once the new arduino version is in the arch packages, please let me know if that works for you now on all java versions. Thanks for the feedback! |
@NicoHood I too have had some hit and miss results in the past. As far as I can tell from recent testing, the bug appears as soon as the device sends data on the Serial port, and not before. I upgraded arduino to 1.8.13-2 and was still able to consistently reproduce the bug, with java-8-openjdk.
I also checked some random .class file from the jars (/usr/share/arduino/lib/arduino-core.jar/processing/app/Platform.class) with a hex editor, and saw that the bytes at offset 6 & 7 are 0x0034 (=Java SE 8, according to wikipedia), confirming that they have been compiled with Java 8? If you cannot seem to reproduce the bug yourself, I can look around and try to see what's going. Any pointers welcome! |
Well then I have to ask @facchinm again :-D |
Problem with arch (besides the possible problems on java>8) is based on the shell runner #!/bin/sh
export PATH=/usr/lib/jvm/default-runtime/bin/:"$PATH"
exec /usr/share/arduino/arduino "$@"
If I understood Nico correctly, arduino is built for Arch. So I would make the java that is used for building a hard requirement and explicitly use it here for the I think it only runs with jdk8 if it is build with jdk8, because of an incompatible change for
|
This worked for me on Arch Linux: |
I instead used java-11-openjdk and it worked too |
It happens because of this. My default is Java 8 for other programs but arduino requires newer version because of this error and when I tried to launch arduino following this it still uses default Java version because /usr/bin/arduino adds default one to the front of the PATH. I cannot come up with an idea to solve the problem but I think the problem lies in /usr/bin/arduino. |
I have reverted back to java8, as I saw no other solution than this. |
Can't reproduce with OpenJDK 19.0.2 |
Using RF24 library for nRF24L01
upgraded arduino (1:1.8.9-1 -> 1:1.8.9-3)
OS: arch linux
Following error is thrown after upgrade
Exception in thread "EventThread /dev/ttyUSB1" java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
at processing.app.Serial.serialEvent(Serial.java:185)
at jssc.SerialPort$LinuxEventThread.run(SerialPort.java:1299)
Relevant github issue?
apache/felix#114
The text was updated successfully, but these errors were encountered: