This commit is contained in:
Vladimir Kozlov 2014-12-11 15:06:12 -08:00
commit 48b6c6007f
2530 changed files with 113850 additions and 21998 deletions

View file

@ -115,8 +115,6 @@ exit_hook_t Arguments::_exit_hook = NULL;
vfprintf_hook_t Arguments::_vfprintf_hook = NULL;
SystemProperty *Arguments::_java_ext_dirs = NULL;
SystemProperty *Arguments::_java_endorsed_dirs = NULL;
SystemProperty *Arguments::_sun_boot_library_path = NULL;
SystemProperty *Arguments::_java_library_path = NULL;
SystemProperty *Arguments::_java_home = NULL;
@ -125,6 +123,7 @@ SystemProperty *Arguments::_sun_boot_class_path = NULL;
char* Arguments::_meta_index_path = NULL;
char* Arguments::_meta_index_dir = NULL;
char* Arguments::_ext_dirs = NULL;
// Check if head of 'option' matches 'name', and sets 'tail' remaining part of option string
@ -184,8 +183,6 @@ void Arguments::init_system_properties() {
// Following are JVMTI agent writable properties.
// Properties values are set to NULL and they are
// os specific they are initialized in os::init_system_properties_values().
_java_ext_dirs = new SystemProperty("java.ext.dirs", NULL, true);
_java_endorsed_dirs = new SystemProperty("java.endorsed.dirs", NULL, true);
_sun_boot_library_path = new SystemProperty("sun.boot.library.path", NULL, true);
_java_library_path = new SystemProperty("java.library.path", NULL, true);
_java_home = new SystemProperty("java.home", NULL, true);
@ -194,8 +191,6 @@ void Arguments::init_system_properties() {
_java_class_path = new SystemProperty("java.class.path", "", true);
// Add to System Property list.
PropertyList_add(&_system_properties, _java_ext_dirs);
PropertyList_add(&_system_properties, _java_endorsed_dirs);
PropertyList_add(&_system_properties, _sun_boot_library_path);
PropertyList_add(&_system_properties, _java_library_path);
PropertyList_add(&_system_properties, _java_home);
@ -313,6 +308,7 @@ static ObsoleteFlag obsolete_jvm_flags[] = {
{ "UseFastAccessorMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
{ "UseFastEmptyMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
#endif // ZERO
{ "UseCompilerSafepoints", JDK_Version::jdk(9), JDK_Version::jdk(10) },
{ NULL, JDK_Version(0), JDK_Version(0) }
};
@ -327,9 +323,12 @@ bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) {
const ObsoleteFlag& flag_status = obsolete_jvm_flags[i];
// <flag>=xxx form
// [-|+]<flag> form
if ((strncmp(flag_status.name, s, strlen(flag_status.name)) == 0) ||
size_t len = strlen(flag_status.name);
if (((strncmp(flag_status.name, s, len) == 0) &&
(strlen(s) == len)) ||
((s[0] == '+' || s[0] == '-') &&
(strncmp(flag_status.name, &s[1], strlen(flag_status.name)) == 0))) {
(strncmp(flag_status.name, &s[1], len) == 0) &&
(strlen(&s[1]) == len))) {
if (JDK_Version::current().compare(flag_status.accept_until) == -1) {
*version = flag_status.obsoleted_in;
return true;
@ -344,13 +343,9 @@ bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) {
// components, in order:
//
// prefix // from -Xbootclasspath/p:...
// endorsed // the expansion of -Djava.endorsed.dirs=...
// base // from os::get_system_properties() or -Xbootclasspath=
// suffix // from -Xbootclasspath/a:...
//
// java.endorsed.dirs is a list of directories; any jar or zip files in the
// directories are added to the sysclasspath just before the base.
//
// This could be AllStatic, but it isn't needed after argument processing is
// complete.
class SysClassPath: public StackObj {
@ -364,16 +359,9 @@ public:
inline void add_suffix(const char* suffix);
inline void reset_path(const char* base);
// Expand the jar/zip files in each directory listed by the java.endorsed.dirs
// property. Must be called after all command-line arguments have been
// processed (in particular, -Djava.endorsed.dirs=...) and before calling
// combined_path().
void expand_endorsed();
inline const char* get_base() const { return _items[_scp_base]; }
inline const char* get_prefix() const { return _items[_scp_prefix]; }
inline const char* get_suffix() const { return _items[_scp_suffix]; }
inline const char* get_endorsed() const { return _items[_scp_endorsed]; }
// Combine all the components into a single c-heap-allocated string; caller
// must free the string if/when no longer needed.
@ -390,20 +378,17 @@ private:
// base are allocated in the C heap and freed by this class.
enum {
_scp_prefix, // from -Xbootclasspath/p:...
_scp_endorsed, // the expansion of -Djava.endorsed.dirs=...
_scp_base, // the default sysclasspath
_scp_suffix, // from -Xbootclasspath/a:...
_scp_nitems // the number of items, must be last.
};
const char* _items[_scp_nitems];
DEBUG_ONLY(bool _expansion_done;)
};
SysClassPath::SysClassPath(const char* base) {
memset(_items, 0, sizeof(_items));
_items[_scp_base] = base;
DEBUG_ONLY(_expansion_done = false;)
}
SysClassPath::~SysClassPath() {
@ -411,7 +396,6 @@ SysClassPath::~SysClassPath() {
for (int i = 0; i < _scp_nitems; ++i) {
if (i != _scp_base) reset_item_at(i);
}
DEBUG_ONLY(_expansion_done = false;)
}
inline void SysClassPath::set_base(const char* base) {
@ -433,7 +417,7 @@ inline void SysClassPath::add_suffix(const char* suffix) {
inline void SysClassPath::reset_item_at(int index) {
assert(index < _scp_nitems && index != _scp_base, "just checking");
if (_items[index] != NULL) {
FREE_C_HEAP_ARRAY(char, _items[index], mtInternal);
FREE_C_HEAP_ARRAY(char, _items[index]);
_items[index] = NULL;
}
}
@ -447,41 +431,11 @@ inline void SysClassPath::reset_path(const char* base) {
//------------------------------------------------------------------------------
void SysClassPath::expand_endorsed() {
assert(_items[_scp_endorsed] == NULL, "can only be called once.");
const char* path = Arguments::get_property("java.endorsed.dirs");
if (path == NULL) {
path = Arguments::get_endorsed_dir();
assert(path != NULL, "no default for java.endorsed.dirs");
}
char* expanded_path = NULL;
const char separator = *os::path_separator();
const char* const end = path + strlen(path);
while (path < end) {
const char* tmp_end = strchr(path, separator);
if (tmp_end == NULL) {
expanded_path = add_jars_to_path(expanded_path, path);
path = end;
} else {
char* dirpath = NEW_C_HEAP_ARRAY(char, tmp_end - path + 1, mtInternal);
memcpy(dirpath, path, tmp_end - path);
dirpath[tmp_end - path] = '\0';
expanded_path = add_jars_to_path(expanded_path, dirpath);
FREE_C_HEAP_ARRAY(char, dirpath, mtInternal);
path = tmp_end + 1;
}
}
_items[_scp_endorsed] = expanded_path;
DEBUG_ONLY(_expansion_done = true;)
}
// Combine the bootclasspath elements, some of which may be null, into a single
// c-heap-allocated string.
char* SysClassPath::combined_path() {
assert(_items[_scp_base] != NULL, "empty default sysclasspath");
assert(_expansion_done, "must call expand_endorsed() first.");
size_t lengths[_scp_nitems];
size_t total_len = 0;
@ -536,7 +490,7 @@ SysClassPath::add_to_path(const char* path, const char* str, bool prepend) {
cp_tmp += str_len;
*cp_tmp = separator;
memcpy(++cp_tmp, path, old_len + 1); // copy the trailing null
FREE_C_HEAP_ARRAY(char, path, mtInternal);
FREE_C_HEAP_ARRAY(char, path);
} else {
cp = REALLOC_C_HEAP_ARRAY(char, path, len, mtInternal);
char* cp_tmp = cp + old_len;
@ -571,10 +525,10 @@ char* SysClassPath::add_jars_to_path(char* path, const char* directory) {
char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtInternal);
sprintf(jarpath, "%s%s%s", directory, dir_sep, name);
path = add_to_path(path, jarpath, false);
FREE_C_HEAP_ARRAY(char, jarpath, mtInternal);
FREE_C_HEAP_ARRAY(char, jarpath);
}
}
FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
FREE_C_HEAP_ARRAY(char, dbuf);
os::closedir(dir);
return path;
}
@ -709,7 +663,7 @@ static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) {
static bool set_string_flag(char* name, const char* value, Flag::Flags origin) {
if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false;
// Contract: CommandLineFlags always returns a pointer that needs freeing.
FREE_C_HEAP_ARRAY(char, value, mtInternal);
FREE_C_HEAP_ARRAY(char, value);
return true;
}
@ -733,10 +687,10 @@ static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags
}
(void) CommandLineFlags::ccstrAtPut(name, &value, origin);
// CommandLineFlags always returns a pointer that needs freeing.
FREE_C_HEAP_ARRAY(char, value, mtInternal);
FREE_C_HEAP_ARRAY(char, value);
if (free_this_too != NULL) {
// CommandLineFlags made its own copy, so I must delete my own temp. buffer.
FREE_C_HEAP_ARRAY(char, free_this_too, mtInternal);
FREE_C_HEAP_ARRAY(char, free_this_too);
}
return true;
}
@ -934,10 +888,18 @@ bool Arguments::process_argument(const char* arg,
Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true);
if (fuzzy_matched != NULL) {
jio_fprintf(defaultStream::error_stream(),
"Did you mean '%s%s%s'?\n",
"Did you mean '%s%s%s'? ",
(fuzzy_matched->is_bool()) ? "(+/-)" : "",
fuzzy_matched->_name,
(fuzzy_matched->is_bool()) ? "" : "=<value>");
if (is_newly_obsolete(fuzzy_matched->_name, &since)) {
char version[256];
since.to_string(version, sizeof(version));
jio_fprintf(defaultStream::error_stream(),
"Warning: support for %s was removed in %s\n",
fuzzy_matched->_name,
version);
}
}
}
@ -1261,10 +1223,8 @@ static void disable_adaptive_size_policy(const char* collector_name) {
void Arguments::set_parnew_gc_flags() {
assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
"control point invariant");
assert(UseParNewGC, "Error");
// Turn off AdaptiveSizePolicy for parnew until it is complete.
disable_adaptive_size_policy("UseParNewGC");
assert(UseConcMarkSweepGC, "CMS is expected to be on here");
assert(UseParNewGC, "ParNew should always be used with CMS");
if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
@ -1305,21 +1265,12 @@ void Arguments::set_parnew_gc_flags() {
void Arguments::set_cms_and_parnew_gc_flags() {
assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC, "Error");
assert(UseConcMarkSweepGC, "CMS is expected to be on here");
// If we are using CMS, we prefer to UseParNewGC,
// unless explicitly forbidden.
if (FLAG_IS_DEFAULT(UseParNewGC)) {
FLAG_SET_ERGO(bool, UseParNewGC, true);
}
assert(UseParNewGC, "ParNew should always be used with CMS");
// Turn off AdaptiveSizePolicy by default for cms until it is complete.
disable_adaptive_size_policy("UseConcMarkSweepGC");
// In either case, adjust ParallelGCThreads and/or UseParNewGC
// as needed.
if (UseParNewGC) {
set_parnew_gc_flags();
}
set_parnew_gc_flags();
size_t max_heap = align_size_down(MaxHeapSize,
CardTableRS::ct_max_alignment_constraint());
@ -1789,14 +1740,11 @@ void Arguments::set_gc_specific_flags() {
// Set per-collector flags
if (UseParallelGC || UseParallelOldGC) {
set_parallel_gc_flags();
} else if (UseConcMarkSweepGC) { // Should be done before ParNew check below
} else if (UseConcMarkSweepGC) {
set_cms_and_parnew_gc_flags();
} else if (UseParNewGC) { // Skipped if CMS is set above
set_parnew_gc_flags();
} else if (UseG1GC) {
set_g1_gc_flags();
}
check_deprecated_gcs();
check_deprecated_gc_flags();
if (AssumeMP && !UseSerialGC) {
if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) {
@ -2157,17 +2105,11 @@ bool Arguments::verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_hea
// Check consistency of GC selection
bool Arguments::check_gc_consistency_user() {
check_gclog_consistency();
bool status = true;
// Ensure that the user has not selected conflicting sets
// of collectors. [Note: this check is merely a user convenience;
// collectors over-ride each other so that only a non-conflicting
// set is selected; however what the user gets is not what they
// may have expected from the combination they asked for. It's
// better to reduce user confusion by not allowing them to
// select conflicting combinations.
// of collectors.
uint i = 0;
if (UseSerialGC) i++;
if (UseConcMarkSweepGC || UseParNewGC) i++;
if (UseConcMarkSweepGC) i++;
if (UseParallelGC || UseParallelOldGC) i++;
if (UseG1GC) i++;
if (i > 1) {
@ -2175,26 +2117,30 @@ bool Arguments::check_gc_consistency_user() {
"Conflicting collector combinations in option list; "
"please refer to the release notes for the combinations "
"allowed\n");
status = false;
return false;
}
return status;
}
void Arguments::check_deprecated_gcs() {
if (UseConcMarkSweepGC && !UseParNewGC) {
warning("Using the DefNew young collector with the CMS collector is deprecated "
"and will likely be removed in a future release");
jio_fprintf(defaultStream::error_stream(),
"It is not possible to combine the DefNew young collector with the CMS collector.\n");
return false;
}
if (UseParNewGC && !UseConcMarkSweepGC) {
// !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
// set up UseSerialGC properly, so that can't be used in the check here.
warning("Using the ParNew young collector with the Serial old collector is deprecated "
"and will likely be removed in a future release");
jio_fprintf(defaultStream::error_stream(),
"It is not possible to combine the ParNew young collector with the Serial old collector.\n");
return false;
}
return true;
}
void Arguments::check_deprecated_gc_flags() {
if (FLAG_IS_CMDLINE(UseParNewGC)) {
warning("The UseParNewGC flag is deprecated and will likely be removed in a future release");
}
if (FLAG_IS_CMDLINE(MaxGCMinorPauseMillis)) {
warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated"
"and will likely be removed in future release");
@ -2203,15 +2149,6 @@ void Arguments::check_deprecated_gc_flags() {
warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. "
"Use MaxRAMFraction instead.");
}
if (FLAG_IS_CMDLINE(UseCMSCompactAtFullCollection)) {
warning("UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.");
}
if (FLAG_IS_CMDLINE(CMSFullGCsBeforeCompaction)) {
warning("CMSFullGCsBeforeCompaction is deprecated and will likely be removed in a future release.");
}
if (FLAG_IS_CMDLINE(UseCMSCollectionPassing)) {
warning("UseCMSCollectionPassing is deprecated and will likely be removed in a future release.");
}
}
// Check stack pages settings
@ -2310,7 +2247,7 @@ bool Arguments::check_vm_args_consistency() {
FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
}
status = status && ArgumentsExt::check_gc_consistency_user();
status = status && check_gc_consistency_user();
status = status && check_stack_pages();
status = status && verify_percentage(CMSIncrementalSafetyFactor,
@ -3050,6 +2987,20 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
#endif
// -D
} else if (match_option(option, "-D", &tail)) {
if (match_option(option, "-Djava.endorsed.dirs=", &tail)) {
// abort if -Djava.endorsed.dirs is set
jio_fprintf(defaultStream::output_stream(),
"-Djava.endorsed.dirs is not supported. Endorsed standards and standalone APIs\n"
"in modular form will be supported via the concept of upgradeable modules.\n");
return JNI_EINVAL;
}
if (match_option(option, "-Djava.ext.dirs=", &tail)) {
// abort if -Djava.ext.dirs is set
jio_fprintf(defaultStream::output_stream(),
"-Djava.ext.dirs is not supported. Use -classpath instead.\n");
return JNI_EINVAL;
}
if (!add_property(tail)) {
return JNI_ENOMEM;
}
@ -3495,11 +3446,89 @@ void Arguments::fix_appclasspath() {
}
}
jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) {
// This must be done after all -D arguments have been processed.
scp_p->expand_endorsed();
static bool has_jar_files(const char* directory) {
DIR* dir = os::opendir(directory);
if (dir == NULL) return false;
if (scp_assembly_required || scp_p->get_endorsed() != NULL) {
struct dirent *entry;
char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
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, mtInternal);
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(SysClassPath* scp_p, bool scp_assembly_required) {
// check if the default lib/endorsed directory exists; if so, error
char path[JVM_MAXPATHLEN];
const char* fileSep = os::file_separator();
sprintf(path, "%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(),
"<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs\n"
"in modular form will be supported via the concept of upgradeable modules.\n");
os::closedir(dir);
return JNI_ERR;
}
sprintf(path, "%s%slib%sext", Arguments::get_java_home(), fileSep, fileSep);
dir = os::opendir(path);
if (dir != NULL) {
jio_fprintf(defaultStream::output_stream(),
"<JAVA_HOME>/lib/ext exists, extensions mechanism no longer supported; "
"Use -classpath instead.\n.");
os::closedir(dir);
return JNI_ERR;
}
if (scp_assembly_required) {
// Assemble the bootclasspath elements into the final path.
Arguments::set_sysclasspath(scp_p->combined_path());
}
@ -3566,7 +3595,12 @@ jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_req
}
}
if (!ArgumentsExt::check_vm_args_consistency()) {
if (UseConcMarkSweepGC && FLAG_IS_DEFAULT(UseParNewGC) && !UseParNewGC) {
// CMS can only be used with ParNew
FLAG_SET_ERGO(bool, UseParNewGC, true);
}
if (!check_vm_args_consistency()) {
return JNI_ERR;
}
@ -3964,7 +3998,7 @@ jint Arguments::apply_ergo() {
// Set heap size based on available physical memory
set_heap_size();
set_gc_specific_flags();
ArgumentsExt::set_gc_specific_flags();
// Initialize Metaspace flags and alignments
Metaspace::ergo_initialize();