FS#62704 - [arduino] IDE cannot show serial output due to NoSuchMethodError ByteBuffer.flip
Attached to Project:
Community Packages
Opened by Robbert Gurdeep Singh (beardhatcode) - Wednesday, 22 May 2019, 10:06 GMT
Last edited by NicoHood (NicoHood) - Thursday, 13 May 2021, 09:17 GMT
Opened by Robbert Gurdeep Singh (beardhatcode) - Wednesday, 22 May 2019, 10:06 GMT
Last edited by NicoHood (NicoHood) - Thursday, 13 May 2021, 09:17 GMT
|
Details
Description:
Arduino IDE cannot show serial output due to java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer; Additional info: * package version(s): arduino-1:1.8.9-3 (works in arduino-1:1.8.9-1) * board: esp8266 (I don't have other boards to test) Steps to reproduce: 1. Open arduino IDE, 2. Open the attached file (simpleSerial.c) 3. Open the serial monitor 4. Compile and flash 5. The log window shows: Exception in thread "EventThread /dev/ttyUSB0" 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) |
This task depends upon
Closed by NicoHood (NicoHood)
Thursday, 13 May 2021, 09:17 GMT
Reason for closing: Fixed
Additional comments about closing: Force java 8 with 1.8.14-1
Thursday, 13 May 2021, 09:17 GMT
Reason for closing: Fixed
Additional comments about closing: Force java 8 with 1.8.14-1
Downgrading solved it:
pacman -U /var/cache/pacman/pkg/arduino-1\:1.8.9-1-x86_64.pkg.tar.xz
Cannot be fixed in arduino 1:1.8.9-4?
Cannot be fixed in arduino 1:1.8.9-4?
matter... just by opening the tools/serial monitor will cause the issue.
last known working version:
sudo pacman -U /var/cache/pacman/pkg/arduino-1:1.8.9-2-x86_64.pkg.tar.xz
I have the following java related packages installed:
jre8-openjdk 8.u212-1
jre8-openjdk-headless 8.u212-1
tried installing (jre-openjdk and jre-openjdk-headless to get latest versions)
jre-openjdk 11.0.3.u4-1
jre-openjdk-headless 11.0.3.u4-1
even after a restart, the exception still exists when opening the serial monitor window.
SUCCESS!
had to remove jre8-openjdk and jre8-openjdk-headless and install the latest
jre-openjdk and jre-openjdk-headless packages. This updated to version 11 of jdk
and the serial monitor is now running without complaints.
It should be noted that you can switch between multiple Java versions without uninstalling the old version. That's what the `archlinux-java` utility is for. If I'm not mistaken, what it actually does is change the `/usr/lib/jvm/default-runtime` symlink to point to one of the various Java installations. All packages that are for the various runtime versions should show up under `pacman -Ss jre` -- you can install as many different versions as you want. The wiki goes into more detail on this: https://wiki.archlinux.org/index.php/Java#Switching_between_JVM
If whatever you're using requires that jre8 to be default runtime, here is a workaround:
If you look in `/usr/bin/arduino` you'll find a wrapper shell script that is hardcoded to set the default directory. If you copy that wrapper to `/usr/local/bin/arduino` and then edit it, you should be able to override the PATH set in the wrapper to the desired runtime -- thus making Arduino use one Java version while the rest of the system uses another.
It's kind of an ugly approach, but it's all I could think of off the top of my head. If anyone knows anything better let me know. (Also, if this really is the best way, maybe someone should open an issue with the packager for the `arduino` package -- ask them to create a wrapper script that allows you to set this via environment variables.
Edit: I tried using JRE10, and it fixed the GUI -- and fixed the error message too. Interesting.
depends=('gtk2' 'desktop-file-utils' 'shared-mime-info' 'java-runtime>=8' 'arduino-builder')
to java-runtime>=10
depends=('gtk2' 'desktop-file-utils' 'shared-mime-info' 'java-runtime>=10' 'arduino-builder')
The reason is that even though using java 10 or 11 resolves this particular issue I get warnings when I use them:
$ archlinux-java status
Available Java environments:
java-10-openjdk (default)
java-11-openjdk
java-8-openjdk
$ /usr/share/arduino/arduino
Picked up JAVA_TOOL_OPTIONS:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by processing.app.linux.GTKLookAndFeelFixer (file:/usr/share/arduino/lib/arduino-core.jar) to field com.sun.java.swing.plaf.gtk.GTKLookAndFeel.styleFactory
WARNING: Please consider reporting this to the maintainers of processing.app.linux.GTKLookAndFeelFixer
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
This doesn't happen when using the Java 8 shipped with arduino-1.8.9:
$ /home/wink/bin/arduino-1.8.9/java/bin/java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
Which you can see is different from Arch Linux Java 8:
$ archlinux-java status
Available Java environments:
java-10-openjdk
java-11-openjdk
java-8-openjdk (default)
$ /usr/bin/java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b01)
OpenJDK 64-Bit Server VM (build 25.212-b01, mixed mode)
Also the package arduino-1:1.8.9-2-x86_64.pkg.tar.xz works fine on my machine, while arduino-1:1.8.9-3-x86_64.pkg.tar.xz has the problem with the serial monitor. Perhaps identify what changed between the two packages.
Arduino-1.8.9-2 works but nothing higher.
Exception in thread "EventThread /dev/ttyUSB0" java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
is still the error displayed when trying to use the serial monitor.
$ java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
Not present with Nano & old bootloader, but present with (new) bootloader
openjdk version "14.0.2" 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12)
OpenJDK 64-Bit Server VM (build 14.0.2+12, mixed mode)
with Arduino 1.8.13
https://github.com/arduino/Arduino/issues/8903
Maybe the java-runtime depend should be made >8 or something like that?
So to fix this as a user choose a default jdk >= 8 and to fix the package make the jdk that is used to build the package a dependency and use the versioned path instead of the default.