Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8273401: Disable JarIndex support in URLClassPath #5524

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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") : false;
Copy link
Member

@dfuch dfuch Sep 15, 2021

Choose a reason for hiding this comment

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

Maybe this should use the same pattern than the other property above:

ENABLE_JAR_INDEX = p != null ? p.equals("true") || p.isEmpty() : false;

Copy link
Member

@dfuch dfuch Sep 15, 2021

Choose a reason for hiding this comment

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

Another question is where to document this property. We will obviously need a CSR and releases notes. I also wonder if it should be promoted into a networking property - which would make it possible to document it in the net.properties file. @AlanBateman what do you think?

Copy link
Contributor

@AlanBateman AlanBateman Sep 15, 2021

Choose a reason for hiding this comment

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

Another question is where to document this property. We will obviously need a CSR and releases notes. I also wonder if it should be promoted into a networking property - which would make it possible to document it in the net.properties file. @AlanBateman what do you think?

jdk.net.URLClassLoader.enableJarIndex is meant to be a temporary property. We could document it in URLClassLoader as an implNote but I'm not sure that it's worth it. I re-worded the CSR to reflect the current proposal and Wang has submitted it. I noted in the CSR that a release note is planned.

Copy link
Contributor

@AlanBateman AlanBateman Sep 15, 2021

Choose a reason for hiding this comment

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

Maybe this should use the same pattern than the other property above:

ENABLE_JAR_INDEX = p != null ? p.equals("true") || p.isEmpty() : false;

Yes, the intention is that -Djdk.net.URLClassLoader.enableJarIndex will re-enable the feature.

Copy link
Contributor

@LanceAndersen LanceAndersen Sep 15, 2021

Choose a reason for hiding this comment

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

I assume the reason for specifically checking for a value of true or an empty string as you envision allowing the property to be explicitly set to false in the future?

Otherwise we could just check if the property is set(regardless of value) to re-enable the feature.

Copy link
Member

@dfuch dfuch Sep 15, 2021

Choose a reason for hiding this comment

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

I would dislike it if -Djdk.net.URLClassPath.enableJarIndex=false meant true...

Copy link
Contributor

@LanceAndersen LanceAndersen Sep 15, 2021

Choose a reason for hiding this comment

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

I can appreciate that and that is a fair point. I guess where I was coming from was that the property is temporary and has to be explicitly specified so ignoring the value seemed worth raising/discussing.

Assuming the current check is kept(which we should based on your input), it should probably be changed to ignore case.

Copy link
Member

@dfuch dfuch Sep 16, 2021

Choose a reason for hiding this comment

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

Given that there is a precedence in this file:

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

I would tend to let the new property follow the same pattern, especially since it's temporary.

Copy link
Contributor Author

@shiyuexw shiyuexw Sep 16, 2021

Choose a reason for hiding this comment

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

Yes,I changed the code to follow the same pattern.

Copy link
Contributor

@LanceAndersen LanceAndersen Sep 16, 2021

Choose a reason for hiding this comment

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

Given that there is a precedence in this file:

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

I would tend to let the new property follow the same pattern, especially since it's temporary.

fair enough :-)

}

/* 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();
@@ -940,7 +946,7 @@ Resource getResource(final String name, boolean check) {
if (entry != null)
return checkResource(name, check, entry);

if (index == null)
if (index == null || !ENABLE_JAR_INDEX)
Copy link
Contributor

@AlanBateman AlanBateman Sep 16, 2021

Choose a reason for hiding this comment

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

Is this needed? When ENABLE_JAR_INDEX is false then I assume index will always be null. I'm only asking is that it would be nice if ENABLE_JAR_INDEX was checked in one place rather than two.

Copy link
Contributor Author

@shiyuexw shiyuexw Sep 16, 2021

Choose a reason for hiding this comment

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

Yes, the check is redundant, and I removed it.

return null;

HashSet<String> visited = new HashSet<>();
@@ -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;