proguard not working with java-8

Project:Trisquel
Version:9.0
Component:Packages
Category:bug report
Priority:normal
Assigned:GNUtoo
Status:patch (ready)
Description

With Trisquel 9 (etiona) I have:

$ update-alternatives --query java
Name: java
Link: /usr/bin/java
Slaves:
 java.1.gz /usr/share/man/man1/java.1.gz
Status: manual
Best: /usr/lib/jvm/java-11-openjdk-amd64/bin/java
Value: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

Alternative: /usr/lib/jvm/java-11-openjdk-amd64/bin/java
Priority: 1111
Slaves:
 java.1.gz /usr/lib/jvm/java-11-openjdk-amd64/man/man1/java.1.gz

Alternative: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Priority: 1081
Slaves:
 java.1.gz /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz

And:

  $ /usr/bin/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 is because proguard uses 'java', and here java defaults to java-8:

 $ cat /usr/bin/proguard
 #!/bin/sh
 
 exec java -Xss300000 -jar /usr/share/java/proguard.jar "$@"

While the correct fix is probably to recompile proguard with java-8, would changing the /usr/bin/proguard script to the following be an acceptable workaround:

 #!/bin/sh
 
 exec /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Xss300000 -jar /usr/share/java/proguard.jar "$@"

Here I've tested proguard by compiling Replicant 6.0 and it didn't complain but I didn't test the resulting images on a real phone yet.

Denis.

Mon, 09/20/2021 - 17:26
Status:active» patch (ready)