diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java index fe088499103..5accf9593c1 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ - // Portions Copyright [2016-2023] [Payara Foundation and/or its affiliates] + // Portions Copyright [2016-2024] [Payara Foundation and/or its affiliates] package com.sun.enterprise.loader; @@ -613,12 +613,17 @@ private byte[] loadClassData0(final URLEntry res, final String entryName) { return AccessController.doPrivileged((PrivilegedAction) () -> { try { if (res.isJar) { // It is a jarfile.. - JarFile zip = res.zip; - JarFile jar = new JarFile(res.file, false, JarFile.OPEN_READ, - Runtime.Version.parse(System.getProperty("java.version"))); - JarEntry entry = jar.getJarEntry(entryName); + JarEntry entry; + if (res.zip.isMultiRelease()) { + // optimization, the below op takes time, so avoid it as necessary + JarFile jar = new JarFile(res.file, false, JarFile.OPEN_READ, + Runtime.Version.parse(System.getProperty("java.version"))); + entry = jar.getJarEntry(entryName); + } else { + entry = res.zip.getJarEntry(entryName); + } if (entry != null) { - byte[] classData = getClassData(zip.getInputStream(entry)); + byte[] classData = getClassData(res.zip.getInputStream(entry)); res.setProtectionDomain(ASURLClassLoader.this, entry.getCertificates()); return classData; }