changeset 7807:6742fb545950

Replace USeModules option with developer option UseModuleBoundaries and only use it to suppress module access checking.
author hseigel
date Wed, 04 Feb 2015 08:34:07 -0500
parents 4bb9951b9a12
children e91779d9e691
files src/share/vm/classfile/modules.cpp src/share/vm/runtime/arguments.cpp src/share/vm/runtime/globals.hpp src/share/vm/runtime/os.cpp src/share/vm/runtime/os.hpp src/share/vm/runtime/reflection.cpp src/share/vm/runtime/thread.cpp
diffstat 7 files changed, 7 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/classfile/modules.cpp	Tue Feb 03 14:09:38 2015 +0000
+++ b/src/share/vm/classfile/modules.cpp	Wed Feb 04 08:34:07 2015 -0500
@@ -521,10 +521,9 @@
 
 jobject Modules::get_module(JNIEnv *env, jclass clazz) {
   oop mirror = JNIHandles::resolve_non_null(clazz);
-  if (mirror == NULL || java_lang_Class::is_primitive(mirror) ||
-    !UseModules) {
-    if (TraceModules && !UseModules) {
-      tty->print_cr("[get_module(): !UseModules, returning NULL]");
+  if (mirror == NULL || java_lang_Class::is_primitive(mirror)) {
+    if (TraceModules) {
+      tty->print_cr("[get_module(): returning NULL]");
     }
     return NULL;
   }
--- a/src/share/vm/runtime/arguments.cpp	Tue Feb 03 14:09:38 2015 +0000
+++ b/src/share/vm/runtime/arguments.cpp	Wed Feb 04 08:34:07 2015 -0500
@@ -3747,10 +3747,6 @@
       CommandLineFlags::printFlags(tty, false);
       vm_exit(0);
     }
-    if (match_option(option, "-XX:-UseModules", &tail)) {
-      // boot class path needs to be expanded before other argument handling
-      os::set_expanded_boot_path();
-    }
 #if INCLUDE_NMT
     if (match_option(option, "-XX:NativeMemoryTracking", &tail)) {
       // The launcher did not setup nmt environment variable properly.
--- a/src/share/vm/runtime/globals.hpp	Tue Feb 03 14:09:38 2015 +0000
+++ b/src/share/vm/runtime/globals.hpp	Wed Feb 04 08:34:07 2015 -0500
@@ -1304,7 +1304,7 @@
           "Decay time (in milliseconds) to re-enable bulk rebiasing of a "  \
           "type after previous bulk rebias")                                \
                                                                             \
-  product(bool, UseModules, true,                                           \
+  develop(bool, UseModuleBoundaries, true,                                  \
           "Use access control to enforce module boundaries")                \
                                                                             \
   product(ccstr, AddModuleRequires, NULL,                                   \
--- a/src/share/vm/runtime/os.cpp	Tue Feb 03 14:09:38 2015 +0000
+++ b/src/share/vm/runtime/os.cpp	Wed Feb 04 08:34:07 2015 -0500
@@ -1167,58 +1167,6 @@
     return formatted_path;
 }
 
-// returns a PATH of all entries in the given directory that do not start with a '.'
-static char* expand_entries_to_path(char* directory, char fileSep, char pathSep) {
-  DIR* dir = os::opendir(directory);
-  if (dir == NULL) return NULL;
-
-  char* path = NULL;
-  size_t path_len = 0;  // path length including \0 terminator
-
-  size_t directory_len = strlen(directory);
-  struct dirent *entry;
-  char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
-  while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
-    const char* name = entry->d_name;
-    if (name[0] == '.') continue;
-
-    size_t name_len = strlen(name);
-    size_t needed = directory_len + name_len + 2;
-    size_t new_len = path_len + needed;
-    if (path == NULL) {
-      path = NEW_C_HEAP_ARRAY(char, new_len, mtInternal);
-    } else {
-      path = REALLOC_C_HEAP_ARRAY(char, path, new_len, mtInternal);
-    }
-    if (path == NULL)
-      break;
-
-    // append <pathSep>directory<fileSep>name
-    char* p = path;
-    if (path_len > 0) {
-      p += (path_len -1);
-      *p = pathSep;
-      p++;
-    }
-
-    strcpy(p, directory);
-    p += directory_len;
-
-    *p = fileSep;
-    p++;
-
-    strcpy(p, name);
-    p += name_len;
-
-    path_len = new_len;
-  }
-
-  FREE_C_HEAP_ARRAY(char, dbuf);
-  os::closedir(dir);
-
-  return path;
-}
-
 bool os::set_boot_path(char fileSep, char pathSep) {
   const char* home = Arguments::get_java_home();
   int home_len = (int)strlen(home);
@@ -1283,44 +1231,6 @@
   return true;
 }
 
-// used to set the boot class path when running without modules
-bool os::set_expanded_boot_path() {
-  const char* home = Arguments::get_java_home();
-  int home_len = (int)strlen(home);
-
-  char fileSep = file_separator()[0];
-  char pathSep = path_separator()[0];
-
-  struct stat st;
-  char* sysclasspath = NULL;
-
-  // no boot class path expansion with jimage
-  char* jimage = format_boot_path("%/lib/modules/bootmodules.jimage", home, home_len, fileSep, pathSep);
-  if (jimage == NULL) return false;
-  bool has_jimage = (os::stat(jimage, &st) == 0);
-  FREE_C_HEAP_ARRAY(char, jimage);
-  if (has_jimage) {
-    return true; // nothing to do
-  }
-
-  // ${java.home}/modules/$MODULE
-  char* modules_dir = format_boot_path("%/modules", home, home_len, fileSep, pathSep);
-  if (modules_dir == NULL) return false;
-  if (os::stat(modules_dir, &st) == 0) {
-    if ((st.st_mode & S_IFDIR) == S_IFDIR) {
-      sysclasspath = expand_entries_to_path(modules_dir, fileSep, pathSep);
-      if (sysclasspath == NULL) return false;
-    }
-  }
-  FREE_C_HEAP_ARRAY(char, modules_dir);
-  if (sysclasspath != NULL) {
-    Arguments::set_sysclasspath(sysclasspath);
-    return true;
-  }
-
-  return false;
-}
-
 /*
  * Splits a path, based on its separator, the number of
  * elements is returned back in n.
--- a/src/share/vm/runtime/os.hpp	Tue Feb 03 14:09:38 2015 +0000
+++ b/src/share/vm/runtime/os.hpp	Wed Feb 04 08:34:07 2015 -0500
@@ -968,9 +968,6 @@
                                 char pathSep);
   static bool set_boot_path(char fileSep, char pathSep);
   static char** split_path(const char* path, int* n);
-
- public:
-  static bool set_expanded_boot_path();
 };
 
 // Note that "PAUSE" is almost always used with synchronization
--- a/src/share/vm/runtime/reflection.cpp	Tue Feb 03 14:09:38 2015 +0000
+++ b/src/share/vm/runtime/reflection.cpp	Wed Feb 04 08:34:07 2015 -0500
@@ -432,7 +432,7 @@
   if (new_class->is_public()) {
     // Ignore modules for DumpSharedSpaces because we do not have any package
     // or module information for modules other than java.base.
-    if (!UseModules || DumpSharedSpaces) {
+    if (!UseModuleBoundaries || DumpSharedSpaces) {
       return ACCESS_OK;
     }
 
--- a/src/share/vm/runtime/thread.cpp	Tue Feb 03 14:09:38 2015 +0000
+++ b/src/share/vm/runtime/thread.cpp	Wed Feb 04 08:34:07 2015 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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
@@ -3540,9 +3540,7 @@
   // code, that for performance reasons, should be compiled.  Also, the module
   // system initialization uses lambda expressions and method references, hence
   // need to run after initialize_jsr292_core_classes().
-  if (UseModules) {
-    call_initModuleRuntime(CHECK_JNI_ERR);
-  }
+  call_initModuleRuntime(CHECK_JNI_ERR);
 
   if (TRACE_START() != JNI_OK) {
     vm_exit_during_initialization("Failed to start tracing backend.");