Skip to content
Permalink
Browse files
8273401: Disable JarIndex support in URLClassPath
Reviewed-by: dfuchs, lancea, alanb, mchung
  • Loading branch information
shiyuexw authored and Hui Shi committed Sep 26, 2021
1 parent 5ec1cdc commit 7700b25460b9898060602396fed7bc590ba242b8
Showing 3 changed files with 11 additions and 4 deletions.
@@ -90,6 +90,7 @@ public class URLClassPath {
private static final boolean DISABLE_ACC_CHECKING;
private static final boolean DISABLE_CP_URL_CHECK;
private static final boolean DEBUG_CP_URL_CHECK;
private static final boolean ENABLE_JAR_INDEX;

static {
Properties props = GetPropertyAction.privilegedGetProperties();
@@ -109,6 +110,9 @@ public class URLClassPath {
// the check is not disabled).
p = props.getProperty("jdk.net.URLClassPath.showIgnoredClassPathEntries");
DEBUG_CP_URL_CHECK = p != null ? p.equals("true") || p.isEmpty() : false;

p = props.getProperty("jdk.net.URLClassPath.enableJarIndex");
ENABLE_JAR_INDEX = p != null ? p.equals("true") || p.isEmpty() : false;
}

/* The original search path of URLs. */
@@ -763,8 +767,10 @@ public Void run() throws IOException {
System.err.println("Opening " + csu);
Thread.dumpStack();
}

jar = getJarFile(csu);
if (!ENABLE_JAR_INDEX) {
return null;
}
index = JarIndex.getJarIndex(jar);
if (index != null) {
String[] jarfiles = index.getJarFiles();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
* @summary InvalidJarIndexException due to bug in sun.misc.JarIndex.merge()
* Test URLClassLoader usage of the merge method when using indexes
* @author Diego Belfer
* @run main/othervm -Djdk.net.URLClassPath.enableJarIndex=true JarIndexMergeForClassLoaderTest
*/
import java.io.BufferedReader;
import java.io.File;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
* jdk.httpserver
* jdk.compiler
* jdk.zipfs
* @run main/othervm Basic
* @run main/othervm -Djdk.net.URLClassPath.enableJarIndex=true Basic
*/

import java.io.IOException;

1 comment on commit 7700b25

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 7700b25 Sep 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.