[Trisquel-devel] [PATCH 5/5] Fix proguard runtime with java pointing to Java 8
Denis 'GNUtoo' Carikli
GNUtoo at cyberdimension.org
Fri Sep 3 18:53:46 CEST 2021
Trisquel 9 has at least two java runtimes: java-8-openjdk and
java-11-openjdk.
When configuring update-alternatives to use java-8-openjdk, we
have the following error when running 'proguard':
Error: A JNI error has occurred, please check your installation
and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError:
proguard/ProGuard has been compiled by a more recent version of
the Java Runtime (class file version 53.0), this version of the
Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
This problem isn't theorical as we need Java 8 to build Replicant 6.0
under Trisquel 9, but we also need proguard to work.
This happens because of the combination of two things:
- /usr/bin/proguard has the following content:
#!/bin/sh
exec java -Xss300000 -jar /usr/share/java/proguard.jar "$@"
So it uses the Java selected by update-alternatives, which could be
java-8-openjdk.
- The debian/control file uses the default-jdk package to build
proguard, so it probably build it for newer Java runtimes.
Changing the java versions in debian/control isn't sufficient to
make it work with Java 8.
The solution we chose here is to make sure that it uses Java 11
when running. This way we don't need to modify extensively the
package and we end up with less risk of breakages.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
helpers/make-proguard | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 helpers/make-proguard
diff --git a/helpers/make-proguard b/helpers/make-proguard
new file mode 100644
index 0000000..b8a55cf
--- /dev/null
+++ b/helpers/make-proguard
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Copyright (C) 2021 Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+VERSION=1
+
+. ./config
+
+sed \
+ 's#^exec java #exec /usr/lib/jvm/java-11-openjdk-amd64/bin/java #' \
+ -i ./debian/scripts/proguard
+
+sed 's/default-jre/openjdk-11-jre/g' -i debian/control
+
+changelog "Fix proguard when java points to Java 8"
+
+compile
--
2.33.0
More information about the Trisquel-devel
mailing list