FS#74474 - [sweethome3d] Fails to launch because JRE 17 workaround not updated for JRE 18

Attached to Project: Community Packages
Opened by Rachel (polychoron) - Saturday, 16 April 2022, 00:45 GMT
Last edited by Muflone (muflone) - Sunday, 31 July 2022, 23:09 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Muflone (muflone)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
When running on a system with the latest `java-runtime` (version 18-2 at time of writing), the application does not launch successfully due to removal of support for the `--ilegal-access=permit` option in Java 17.0 (see errors below). I believe the issue has been present since `extra/jre-openjdk` and related packages were bumped up to provide Java 18 on 2022-04-05.

This is a known problem, and there is a check to fallback to an earlier version of Java in such a case inside the `/usr/bin/sweethome3d` wrapper script. However, this check only filters out `java-17-openjdk` as a possible fallback option, not later releases such as the current `java-18-openjdk`. The aforementioned workaround is found around lines 30-44 in `/usr/bin/sweethome3d`, specifically on line 33:

```
$ bat -p /usr/bin/sweethome3d -r 30:44 -n
30 if [ $(vercmp "${JAVA_VERSION}" "17") -gt 0 ]
31 then
32 echo "Warning: Sweethome 3D actually is not compatible with Java version > 16"
33 _PREVIOUS_JAVA_VERSION="$(archlinux-java status | tail -n +2 | sort | cut -d ' ' -f 3 | sort -nr -k 2 -t '-' | grep -vE '17-' -m 1)"
34 if [ -z "${_PREVIOUS_JAVA_VERSION}" ]
35 then
36 echo "No others Java version are available, please install a Java version < 17"
37 exit 1
38 else
39 echo "Falling back to ${_PREVIOUS_JAVA_VERSION}"
40 export JAVA_HOME="/usr/lib/jvm/${_PREVIOUS_JAVA_VERSION}"
41 export JAVA_EXEC="${JAVA_HOME}/bin/java"
42 export JAVA_VERSION="$(${JAVA_EXEC} -version 2>&1 | head -1 | cut -d' ' -f 3 | tr -d '"')"
43 fi
44 fi
```

Recommend updating line 33 to also filter out Java 18 in the final `grep` expression to fix.

END-USER WORKAROUND: Manually force sweethome3d to call an earlier version of Java by setting the `JAVA_HOME` environment variable at runtime, e.g.
```
$ JAVA_HOME=/usr/lib/jvm/java-11-openjdk sweethome3d
```

Additional Info:
```
$ pacman -Qi sweethome3d
Name : sweethome3d
Version : 6.6-4
Description : An interior design application to draw the plan of your house in a 3D
environment
Architecture : x86_64
URL : http://www.sweethome3d.com/
Licenses : GPL custom
Groups : None
Provides : None
Depends On : java-runtime<17 shared-mime-info desktop-file-utils libxext libgl
libxrender libnsl
Optional Deps : None
Required By : None
Optional For : None
Conflicts With : None
Replaces : None
Installed Size : 31.20 MiB
Packager : Allan McRae <allan@archlinux.org>
Build Date : Wed 02 Mar 2022 12:33:55 AM PST
Install Date : Fri 15 Apr 2022 04:47:39 PM PDT
Install Reason : Explicitly installed
Install Script : Yes
Validated By : Signature
$ pacman -Qs jre
local/jre-openjdk 18-2
OpenJDK Java 18 full runtime environment
local/jre-openjdk-headless 18-2
OpenJDK Java 18 headless runtime environment
local/jre11-openjdk 11.0.15.u3-1
OpenJDK Java 11 full runtime environment
local/jre11-openjdk-headless 11.0.15.u3-1
OpenJDK Java 11 headless runtime environment
$ archlinux-java status
Available Java environments:
java-11-openjdk
java-18-openjdk (default)
$ uname -a
Linux hostname 5.17.3-arch1-1 #1 SMP PREEMPT Thu, 14 Apr 2022 01:18:36 +0000 x86_64 GNU/Linux
```

Steps to reproduce:
1. Update system with `$ pacman -Syu` or otherwise install `jre-openjdk>=18` (at time of writing, `jre-openjdk` provides `java-runtime=18-2`).
2. Install at least one older version of the Java Runtime Environment is installed on the system, e.g. version 11 with `$ pacman -S jre11-openjdk`.
3. Ensure `java-18-openjdk` is set as the default Java (if needed):
```
# archlinux-java set java-18-openjdk
```
4. Attempt to launch Sweet Home 3D application. For me, a splash screen now pops up, but the application otherwise appears to hang here until forcibly killed. Errors when launched in a terminal are found below:
```
$ sweethome3d
Warning: Sweethome 3D actually is not compatible with Java version > 16
Falling back to java-18-openjdk
OpenJDK 64-Bit Server VM warning: Ignoring option --illegal-access=permit; support was removed in 17.0
Java 3D: implicit antialiasing enabled
Exception in thread "J3D-Renderer-1" java.lang.IllegalAccessError: class javax.media.j3d.X11NativeConfigTemplate3D (in unnamed module @0x67b64c45) cannot access class sun.awt.X11GraphicsConfig (in module java.desktop) because module java.desktop does not export sun.awt to unnamed module @0x67b64c45
at javax.media.j3d.X11NativeConfigTemplate3D.isGraphicsConfigSupported(X11NativeConfigTemplate3D.java:180)
at javax.media.j3d.NativePipeline.isGraphicsConfigSupported(NativePipeline.java:3341)
at javax.media.j3d.Renderer.doWork(Renderer.java:533)
at javax.media.j3d.J3dThread.run(J3dThread.java:275)
^C
```
This task depends upon

Closed by  Muflone (muflone)
Sunday, 31 July 2022, 23:09 GMT
Reason for closing:  Fixed
Additional comments about closing:  fixed in 7.0.2-1
Comment by Sergio Callegari (callegar) - Saturday, 16 July 2022, 15:02 GMT
it is actually enough to change the
grep -vE '17-' -m 1
into
grep -vE '1[78]-' -m 1
Comment by Sergio Cambra (sergiocambra) - Saturday, 16 July 2022, 16:22 GMT
I have fixed sweethome3d.sh to ignore java-18 and any newer version.

Also, I changed PKGBUILD to install latest version, 7.0.

I thought I could send pull request on github, but it's a read-only repository, but changes are in my fork: https://github.com/scambra/svntogit-community/tree/packages/sweethome3d/trunk

Loading...