Skip to content

Commit

Permalink
Merge pull request #925 from AdoptOpenJDK/addJarIndexDummy
Browse files Browse the repository at this point in the history
add a dummy implementation of JarIndex to support Java 21+
  • Loading branch information
janakmulani authored Nov 7, 2023
2 parents 111e0fd + b2fb142 commit e655d07
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class JarIndexAccess {
LOG.debug(CLASS_SUN_MISC_JAR_INDEX + " not found - Running jdk9+ ?");
jarIndexClass = Class.forName(CLASS_JDK_INTERNAL_UTIL_JAR_JAR_INDEX);
} catch (ClassNotFoundException exx) {
LOG.error(CLASS_JDK_INTERNAL_UTIL_JAR_JAR_INDEX + " not found");
throw new RuntimeException("JarIndex not found!");
LOG.debug(CLASS_JDK_INTERNAL_UTIL_JAR_JAR_INDEX + " not found");
jarIndexClass = JarIndexDummy.class;
}
}
}
Expand Down Expand Up @@ -79,4 +79,18 @@ private LinkedList<String> getImpl(final String replace) throws NoSuchMethodExce
final Object o = method.invoke(parent, replace);
return (LinkedList<String>) o;
}

/**
* Because starting of JAVA 21 the JarIndex is no longer supported we provide a dummy implementation which always returns {@code null}.
*/
@SuppressWarnings("unused")
private static class JarIndexDummy {
public static Object getJarIndex(JarFile jar) {
return null;
}

public Object get(String fileName) {
return null;
}
}
}

0 comments on commit e655d07

Please sign in to comment.