Skip to content

Commit fdda861

Browse files
committed
use reflection to call method with changed signature in Java 21
1 parent 758e702 commit fdda861

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

core/src/main/java/net/sourceforge/jnlp/tools/JarCertVerifier.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.io.File;
4545
import java.io.IOException;
4646
import java.io.InputStream;
47+
import java.lang.reflect.Method;
4748
import java.security.CodeSigner;
4849
import java.security.KeyStore;
4950
import java.security.Timestamp;
@@ -64,6 +65,7 @@
6465
import java.util.regex.Pattern;
6566
import java.util.zip.ZipException;
6667

68+
import static java.lang.Boolean.TRUE;
6769
import static java.time.temporal.ChronoUnit.MONTHS;
6870

6971
/**
@@ -609,7 +611,7 @@ private void checkCertUsage(final CertPath certPath, final X509Certificate userC
609611

610612
final NetscapeCertTypeExtension extn = new NetscapeCertTypeExtension(encoded);
611613

612-
if (!extn.get(NetscapeCertTypeExtension.OBJECT_SIGNING)) {
614+
if (!hasObjectSigningExtension(extn)) {
613615
certs.get(certPath).setBadNetscapeCertType();
614616
}
615617
}
@@ -618,6 +620,18 @@ private void checkCertUsage(final CertPath certPath, final X509Certificate userC
618620
}
619621
}
620622

623+
private static boolean hasObjectSigningExtension(NetscapeCertTypeExtension extn) throws IOException {
624+
// method return type of "NetscapeCertTypeExtension.get()" has changed from Boolean to boolean with Java 21
625+
try {
626+
final Method getMethod = NetscapeCertTypeExtension.class.getDeclaredMethod("get", String.class);
627+
final Object result = getMethod.invoke(extn, NetscapeCertTypeExtension.OBJECT_SIGNING);
628+
return result == TRUE;
629+
} catch (Exception e) {
630+
LOG.error("Failed to get object_signing from extension", e);
631+
return false;
632+
}
633+
}
634+
621635
/**
622636
* Returns if all jars are signed.
623637
*

0 commit comments

Comments
 (0)