8183238: Obsolete CheckEndorsedAndExtDirs and remove checks for lib/endorsed and lib/ext

Reviewed-by: dholmes, mchung, alanb
This commit is contained in:
Ioi Lam 2018-03-29 20:15:23 -07:00
parent 590eded063
commit 526bcdab19
5 changed files with 4 additions and 241 deletions

View File

@ -1,5 +1,5 @@
'\" t
.\" Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved.
.\" Copyright (c) 1994, 2018, 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
@ -1178,65 +1178,6 @@ Verify all classes\&.
.PP
These options control the runtime behavior of the Java HotSpot VM\&.
.PP
\-XX:+CheckEndorsedAndExtDirs
.RS 4
Enables the option to prevent the
\fBjava\fR
command from running a Java application if it uses the endorsed\-standards override mechanism or the extension mechanism\&. This option checks if an application is using one of these mechanisms by checking the following:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The
\fBjava\&.ext\&.dirs\fR
or
\fBjava\&.endorsed\&.dirs\fR
system property is set\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The
\fBlib/endorsed\fR
directory exists and is not empty\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The
\fBlib/ext\fR
directory contains any JAR files other than those of the JDK\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The system\-wide platform\-specific extension directory contains any JAR files\&.
.RE
.RE
.PP
\-XX:+DisableAttachMechanism
.RS 4
Enables the option that disables the mechanism that lets tools attach to the JVM\&. By default, this option is disabled, meaning that the attach mechanism is enabled and you can use tools such as

View File

@ -512,7 +512,6 @@ static SpecialFlag const special_jvm_flags[] = {
{ "InitialRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
{ "UseMembar", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
{ "IgnoreUnverifiableClassesDuringDump", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
{ "CheckEndorsedAndExtDirs", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
{ "CompilerThreadHintNoPreempt", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) },
{ "VMThreadHintNoPreempt", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) },
{ "PrintSafepointStatistics", JDK_Version::jdk(11), JDK_Version::jdk(12), JDK_Version::jdk(13) },
@ -536,6 +535,7 @@ static SpecialFlag const special_jvm_flags[] = {
{ "ShowSafepointMsgs", JDK_Version::undefined(), JDK_Version::jdk(11), JDK_Version::jdk(12) },
{ "FastTLABRefill", JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
{ "SafepointSpinBeforeYield", JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
{ "CheckEndorsedAndExtDirs", JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
{ "DeferThrSuspendLoopCount", JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
{ "DeferPollingPageLoopCount", JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
{ "PermSize", JDK_Version::undefined(), JDK_Version::jdk(8), JDK_Version::undefined() },
@ -3302,69 +3302,12 @@ void Arguments::fix_appclasspath() {
}
}
static bool has_jar_files(const char* directory) {
DIR* dir = os::opendir(directory);
if (dir == NULL) return false;
struct dirent *entry;
char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtArguments);
bool hasJarFile = false;
while (!hasJarFile && (entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
const char* name = entry->d_name;
const char* ext = name + strlen(name) - 4;
hasJarFile = ext > name && (os::file_name_strcmp(ext, ".jar") == 0);
}
FREE_C_HEAP_ARRAY(char, dbuf);
os::closedir(dir);
return hasJarFile ;
}
static int check_non_empty_dirs(const char* path) {
const char separator = *os::path_separator();
const char* const end = path + strlen(path);
int nonEmptyDirs = 0;
while (path < end) {
const char* tmp_end = strchr(path, separator);
if (tmp_end == NULL) {
if (has_jar_files(path)) {
nonEmptyDirs++;
jio_fprintf(defaultStream::output_stream(),
"Non-empty directory: %s\n", path);
}
path = end;
} else {
char* dirpath = NEW_C_HEAP_ARRAY(char, tmp_end - path + 1, mtArguments);
memcpy(dirpath, path, tmp_end - path);
dirpath[tmp_end - path] = '\0';
if (has_jar_files(dirpath)) {
nonEmptyDirs++;
jio_fprintf(defaultStream::output_stream(),
"Non-empty directory: %s\n", dirpath);
}
FREE_C_HEAP_ARRAY(char, dirpath);
path = tmp_end + 1;
}
}
return nonEmptyDirs;
}
jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) {
// check if the default lib/endorsed directory exists; if so, error
char path[JVM_MAXPATHLEN];
const char* fileSep = os::file_separator();
jio_snprintf(path, JVM_MAXPATHLEN, "%s%slib%sendorsed", Arguments::get_java_home(), fileSep, fileSep);
if (CheckEndorsedAndExtDirs) {
int nonEmptyDirs = 0;
// check endorsed directory
nonEmptyDirs += check_non_empty_dirs(path);
// check the extension directories
nonEmptyDirs += check_non_empty_dirs(Arguments::get_ext_dirs());
if (nonEmptyDirs > 0) {
return JNI_ERR;
}
}
DIR* dir = os::opendir(path);
if (dir != NULL) {
jio_fprintf(defaultStream::output_stream(),

View File

@ -1241,9 +1241,6 @@ public:
product(bool, CheckJNICalls, false, \
"Verify all arguments to JNI calls") \
\
product(bool, CheckEndorsedAndExtDirs, false, \
"Verify the endorsed and extension directories are not used") \
\
product(bool, UseFastJNIAccessors, true, \
"Use optimized versions of Get<Primitive>Field") \
\

View File

@ -1,5 +1,5 @@
'\" t
.\" Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved.
.\" Copyright (c) 1994, 2018, 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
@ -1173,65 +1173,6 @@ Verify all classes\&.
.PP
These options control the runtime behavior of the Java HotSpot VM\&.
.PP
\-XX:+CheckEndorsedAndExtDirs
.RS 4
Enables the option to prevent the
\fBjava\fR
command from running a Java application if it uses the endorsed\-standards override mechanism or the extension mechanism\&. This option checks if an application is using one of these mechanisms by checking the following:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The
\fBjava\&.ext\&.dirs\fR
or
\fBjava\&.endorsed\&.dirs\fR
system property is set\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The
\fBlib/endorsed\fR
directory exists and is not empty\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The
\fBlib/ext\fR
directory contains any JAR files other than those of the JDK\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The system\-wide platform\-specific extension directory contains any JAR files\&.
.RE
.RE
.PP
\-XX:+DisableAttachMechanism
.RS 4
Enables the option that disables the mechanism that lets tools attach to the JVM\&. By default, this option is disabled, meaning that the attach mechanism is enabled and you can use tools such as

View File

@ -1,5 +1,5 @@
'\" t
.\" Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved.
.\" Copyright (c) 1994, 2018, 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
@ -1173,65 +1173,6 @@ Verify all classes\&.
.PP
These options control the runtime behavior of the Java HotSpot VM\&.
.PP
\-XX:+CheckEndorsedAndExtDirs
.RS 4
Enables the option to prevent the
\fBjava\fR
command from running a Java application if it uses the endorsed\-standards override mechanism or the extension mechanism\&. This option checks if an application is using one of these mechanisms by checking the following:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The
\fBjava\&.ext\&.dirs\fR
or
\fBjava\&.endorsed\&.dirs\fR
system property is set\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The
\fBlib/endorsed\fR
directory exists and is not empty\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The
\fBlib/ext\fR
directory contains any JAR files other than those of the JDK\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
The system\-wide platform\-specific extension directory contains any JAR files\&.
.RE
.RE
.PP
\-XX:+DisableAttachMechanism
.RS 4
Enables the option that disables the mechanism that lets tools attach to the JVM\&. By default, this option is disabled, meaning that the attach mechanism is enabled and you can use tools such as