changeset 8051:808a93ac60e0

Merge
author mchung
date Fri, 06 Mar 2015 14:27:49 -0800
parents c3b117fa5bde 9f16f5d21ff1
children 00d5206f35f0
files src/os/linux/vm/os_linux.cpp src/share/vm/c1/c1_Runtime1.cpp src/share/vm/classfile/classFileParser.cpp src/share/vm/classfile/classFileParser.hpp src/share/vm/classfile/classLoaderExt.hpp src/share/vm/precompiled/precompiled.hpp src/share/vm/runtime/arguments.cpp src/share/vm/runtime/globals.hpp src/share/vm/runtime/os.hpp src/share/vm/runtime/vmStructs.cpp test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java
diffstat 245 files changed, 6935 insertions(+), 923 deletions(-) [+]
line wrap: on
line diff
--- a/.jcheck/conf	Thu Mar 05 15:21:35 2015 -0800
+++ b/.jcheck/conf	Fri Mar 06 14:27:49 2015 -0800
@@ -1,1 +1,4 @@
 project=jdk9
+comments=lax
+tags=lax
+bugids=dup
--- a/make/aix/makefiles/mapfile-vers-debug	Thu Mar 05 15:21:35 2015 -0800
+++ b/make/aix/makefiles/mapfile-vers-debug	Fri Mar 06 14:27:49 2015 -0800
@@ -190,6 +190,14 @@
                 JVM_Yield;
                 JVM_handle_linux_signal;
 
+                # Modules
+                JVM_DefineModule;
+                JVM_AddReadsModule;
+                JVM_AddModuleExports;
+                JVM_CanReadModule;
+                JVM_IsExportedToModule;
+                JVM_AddModulePackage;
+
                 # debug JVM
                 JVM_AccessVMBooleanFlag;
                 JVM_AccessVMIntFlag;
--- a/make/aix/makefiles/mapfile-vers-product	Thu Mar 05 15:21:35 2015 -0800
+++ b/make/aix/makefiles/mapfile-vers-product	Fri Mar 06 14:27:49 2015 -0800
@@ -188,6 +188,14 @@
                 JVM_Yield;
                 JVM_handle_linux_signal;
 
+                # Modules
+                JVM_DefineModule;
+                JVM_AddReadsModule;
+                JVM_AddModuleExports;
+                JVM_CanReadModule;
+                JVM_IsExportedToModule;
+                JVM_AddModulePackage;
+
                 # miscellaneous functions
                 jio_fprintf;
                 jio_printf;
--- a/make/bsd/makefiles/mapfile-vers-darwin-debug	Thu Mar 05 15:21:35 2015 -0800
+++ b/make/bsd/makefiles/mapfile-vers-darwin-debug	Fri Mar 06 14:27:49 2015 -0800
@@ -187,6 +187,14 @@
                 _JVM_Yield
                 _JVM_handle_bsd_signal
 
+                # Modules
+                _JVM_DefineModule
+                _JVM_AddReadsModule
+                _JVM_AddModuleExports
+                _JVM_CanReadModule
+                _JVM_IsExportedToModule
+                _JVM_AddModulePackage
+                
                 # miscellaneous functions
                 _jio_fprintf
                 _jio_printf
--- a/make/bsd/makefiles/mapfile-vers-darwin-product	Thu Mar 05 15:21:35 2015 -0800
+++ b/make/bsd/makefiles/mapfile-vers-darwin-product	Fri Mar 06 14:27:49 2015 -0800
@@ -187,6 +187,14 @@
                 _JVM_Yield
                 _JVM_handle_bsd_signal
 
+                # Modules
+                _JVM_DefineModule
+                _JVM_AddReadsModule
+                _JVM_AddModuleExports
+                _JVM_CanReadModule
+                _JVM_IsExportedToModule
+                _JVM_AddModulePackage
+
                 # miscellaneous functions
                 _jio_fprintf
                 _jio_printf
--- a/make/bsd/makefiles/mapfile-vers-debug	Thu Mar 05 15:21:35 2015 -0800
+++ b/make/bsd/makefiles/mapfile-vers-debug	Fri Mar 06 14:27:49 2015 -0800
@@ -189,6 +189,14 @@
                 JVM_Yield;
                 JVM_handle_linux_signal;
 
+                # Modules
+                _JVM_DefineModule;
+                _JVM_AddReadsModule;
+                _JVM_AddModuleExports;
+                _JVM_CanReadModule;
+                _JVM_IsExportedToModule;
+                _JVM_AddModulePackage;
+
                 # miscellaneous functions
                 jio_fprintf;
                 jio_printf;
--- a/make/bsd/makefiles/mapfile-vers-product	Thu Mar 05 15:21:35 2015 -0800
+++ b/make/bsd/makefiles/mapfile-vers-product	Fri Mar 06 14:27:49 2015 -0800
@@ -189,6 +189,14 @@
                 JVM_Yield;
                 JVM_handle_linux_signal;
 
+                # Modules
+                _JVM_DefineModule;
+                _JVM_AddReadsModule;
+                _JVM_AddModuleExports;
+                _JVM_CanReadModule;
+                _JVM_IsExportedToModule;
+                _JVM_AddModulePackage;
+
                 # miscellaneous functions
                 jio_fprintf;
                 jio_printf;
--- a/make/linux/makefiles/mapfile-vers-debug	Thu Mar 05 15:21:35 2015 -0800
+++ b/make/linux/makefiles/mapfile-vers-debug	Fri Mar 06 14:27:49 2015 -0800
@@ -189,6 +189,14 @@
                 JVM_Yield;
                 JVM_handle_linux_signal;
 
+                # Modules
+                JVM_DefineModule;
+                JVM_AddReadsModule;
+                JVM_AddModuleExports;
+                JVM_CanReadModule;
+                JVM_IsExportedToModule;
+                JVM_AddModulePackage;
+
                 # miscellaneous functions
                 jio_fprintf;
                 jio_printf;
--- a/make/linux/makefiles/mapfile-vers-product	Thu Mar 05 15:21:35 2015 -0800
+++ b/make/linux/makefiles/mapfile-vers-product	Fri Mar 06 14:27:49 2015 -0800
@@ -189,6 +189,15 @@
                 JVM_Yield;
                 JVM_handle_linux_signal;
 
+                # Modules
+                JVM_DefineModule;
+                JVM_AddReadsModule;
+                JVM_AddModuleExports;
+                JVM_CanReadModule;
+                JVM_IsExportedToModule;
+                JVM_AddModulePackage;
+
+
                 # miscellaneous functions
                 jio_fprintf;
                 jio_printf;
--- a/make/solaris/makefiles/mapfile-vers	Thu Mar 05 15:21:35 2015 -0800
+++ b/make/solaris/makefiles/mapfile-vers	Fri Mar 06 14:27:49 2015 -0800
@@ -189,6 +189,14 @@
                 JVM_Yield;
                 JVM_handle_solaris_signal;
 
+                # Modules
+                JVM_DefineModule;
+                JVM_AddReadsModule;
+                JVM_AddModuleExports;
+                JVM_CanReadModule;
+                JVM_IsExportedToModule;
+                JVM_AddModulePackage;
+
                 # miscellaneous functions
                 jio_fprintf;
                 jio_printf;
--- a/src/os/linux/vm/os_linux.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/os/linux/vm/os_linux.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -110,7 +110,7 @@
 // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
 // getrusage() is prepared to handle the associated failure.
 #ifndef RUSAGE_THREAD
-  #define RUSAGE_THREAD   (1)               /* only the calling thread */
+#define RUSAGE_THREAD   (1)               /* only the calling thread */
 #endif
 
 #define MAX_PATH    (2 * K)
@@ -213,17 +213,17 @@
 
 #ifndef SYS_gettid
 // i386: 224, ia64: 1105, amd64: 186, sparc 143
-  #ifdef __ia64__
-    #define SYS_gettid 1105
-  #elif __i386__
-    #define SYS_gettid 224
-  #elif __amd64__
-    #define SYS_gettid 186
-  #elif __sparc__
-    #define SYS_gettid 143
-  #else
-    #error define gettid for the arch
-  #endif
+#ifdef __ia64__
+#define SYS_gettid 1105
+#elif __i386__
+#define SYS_gettid 224
+#elif __amd64__
+#define SYS_gettid 186
+#elif __sparc__
+#define SYS_gettid 143
+#else
+#error define gettid for the arch
+#endif
 #endif
 
 // Cpu architecture string
@@ -242,15 +242,15 @@
 #elif defined(PPC64)
 static char cpu_arch[] = "ppc64";
 #elif defined(SPARC)
-  #ifdef _LP64
+#  ifdef _LP64
 static char cpu_arch[] = "sparcv9";
-  #else
+#  else
 static char cpu_arch[] = "sparc";
   #endif
 #elif defined(AARCH64)
 static char cpu_arch[] = "aarch64";
 #else
-  #error Add appropriate cpu_arch setting
+#error Add appropriate cpu_arch setting
 #endif
 
 
@@ -265,10 +265,10 @@
 pid_t os::Linux::gettid() {
   int rslt = syscall(SYS_gettid);
   if (rslt == -1) {
-    // old kernel, no NPTL support
-    return getpid();
+     // old kernel, no NPTL support
+     return getpid();
   } else {
-    return (pid_t)rslt;
+     return (pid_t)rslt;
   }
 }
 
@@ -325,16 +325,16 @@
   // Important note: if the location of libjvm.so changes this
   // code needs to be changed accordingly.
 
-  // See ld(1):
-  //      The linker uses the following search paths to locate required
-  //      shared libraries:
-  //        1: ...
-  //        ...
-  //        7: The default directories, normally /lib and /usr/lib.
+// See ld(1):
+//      The linker uses the following search paths to locate required
+//      shared libraries:
+//        1: ...
+//        ...
+//        7: The default directories, normally /lib and /usr/lib.
 #if defined(AMD64) || defined(_LP64) && (defined(SPARC) || defined(PPC) || defined(S390))
-  #define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
+#define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
 #else
-  #define DEFAULT_LIBPATH "/lib:/usr/lib"
+#define DEFAULT_LIBPATH "/lib:/usr/lib"
 #endif
 
 // Base path of extensions installed on the system.
@@ -436,15 +436,15 @@
 static sigset_t unblocked_sigs, vm_sigs, allowdebug_blocked_sigs;
 
 bool os::Linux::is_sig_ignored(int sig) {
-  struct sigaction oact;
-  sigaction(sig, (struct sigaction*)NULL, &oact);
-  void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*,  oact.sa_sigaction)
-                                 : CAST_FROM_FN_PTR(void*,  oact.sa_handler);
+      struct sigaction oact;
+      sigaction(sig, (struct sigaction*)NULL, &oact);
+      void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*,  oact.sa_sigaction)
+                                     : CAST_FROM_FN_PTR(void*,  oact.sa_handler);
   if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN)) {
-    return true;
+           return true;
   } else {
-    return false;
-  }
+           return false;
+}
 }
 
 void os::Linux::signal_sets_init() {
@@ -475,18 +475,18 @@
   sigaddset(&unblocked_sigs, SR_signum);
 
   if (!ReduceSignalUsage) {
-    if (!os::Linux::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
+   if (!os::Linux::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
       sigaddset(&allowdebug_blocked_sigs, SHUTDOWN1_SIGNAL);
-    }
-    if (!os::Linux::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
+   }
+   if (!os::Linux::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL);
       sigaddset(&allowdebug_blocked_sigs, SHUTDOWN2_SIGNAL);
-    }
-    if (!os::Linux::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
+   }
+   if (!os::Linux::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
       sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL);
       sigaddset(&allowdebug_blocked_sigs, SHUTDOWN3_SIGNAL);
-    }
+   }
   }
   // Fill in signals that are blocked by all but the VM thread.
   sigemptyset(&vm_sigs);
@@ -547,59 +547,59 @@
   // and _CS_GNU_LIBPTHREAD_VERSION are supported in glibc >= 2.3.2. Use a
   // generic name for earlier versions.
   // Define macros here so we can build HotSpot on old systems.
-#ifndef _CS_GNU_LIBC_VERSION
-  #define _CS_GNU_LIBC_VERSION 2
-#endif
-#ifndef _CS_GNU_LIBPTHREAD_VERSION
-  #define _CS_GNU_LIBPTHREAD_VERSION 3
-#endif
+# ifndef _CS_GNU_LIBC_VERSION
+# define _CS_GNU_LIBC_VERSION 2
+# endif
+# ifndef _CS_GNU_LIBPTHREAD_VERSION
+# define _CS_GNU_LIBPTHREAD_VERSION 3
+# endif
 
   size_t n = confstr(_CS_GNU_LIBC_VERSION, NULL, 0);
   if (n > 0) {
-    char *str = (char *)malloc(n, mtInternal);
-    confstr(_CS_GNU_LIBC_VERSION, str, n);
-    os::Linux::set_glibc_version(str);
+     char *str = (char *)malloc(n, mtInternal);
+     confstr(_CS_GNU_LIBC_VERSION, str, n);
+     os::Linux::set_glibc_version(str);
   } else {
-    // _CS_GNU_LIBC_VERSION is not supported, try gnu_get_libc_version()
-    static char _gnu_libc_version[32];
-    jio_snprintf(_gnu_libc_version, sizeof(_gnu_libc_version),
-                 "glibc %s %s", gnu_get_libc_version(), gnu_get_libc_release());
-    os::Linux::set_glibc_version(_gnu_libc_version);
+     // _CS_GNU_LIBC_VERSION is not supported, try gnu_get_libc_version()
+     static char _gnu_libc_version[32];
+     jio_snprintf(_gnu_libc_version, sizeof(_gnu_libc_version),
+              "glibc %s %s", gnu_get_libc_version(), gnu_get_libc_release());
+     os::Linux::set_glibc_version(_gnu_libc_version);
   }
 
   n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
   if (n > 0) {
-    char *str = (char *)malloc(n, mtInternal);
-    confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
-    // Vanilla RH-9 (glibc 2.3.2) has a bug that confstr() always tells
-    // us "NPTL-0.29" even we are running with LinuxThreads. Check if this
-    // is the case. LinuxThreads has a hard limit on max number of threads.
-    // So sysconf(_SC_THREAD_THREADS_MAX) will return a positive value.
-    // On the other hand, NPTL does not have such a limit, sysconf()
-    // will return -1 and errno is not changed. Check if it is really NPTL.
-    if (strcmp(os::Linux::glibc_version(), "glibc 2.3.2") == 0 &&
-        strstr(str, "NPTL") &&
-        sysconf(_SC_THREAD_THREADS_MAX) > 0) {
-      free(str);
-      os::Linux::set_libpthread_version("linuxthreads");
-    } else {
-      os::Linux::set_libpthread_version(str);
-    }
+     char *str = (char *)malloc(n, mtInternal);
+     confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+     // Vanilla RH-9 (glibc 2.3.2) has a bug that confstr() always tells
+     // us "NPTL-0.29" even we are running with LinuxThreads. Check if this
+     // is the case. LinuxThreads has a hard limit on max number of threads.
+     // So sysconf(_SC_THREAD_THREADS_MAX) will return a positive value.
+     // On the other hand, NPTL does not have such a limit, sysconf()
+     // will return -1 and errno is not changed. Check if it is really NPTL.
+     if (strcmp(os::Linux::glibc_version(), "glibc 2.3.2") == 0 &&
+         strstr(str, "NPTL") &&
+         sysconf(_SC_THREAD_THREADS_MAX) > 0) {
+       free(str);
+       os::Linux::set_libpthread_version("linuxthreads");
+     } else {
+       os::Linux::set_libpthread_version(str);
+     }
   } else {
     // glibc before 2.3.2 only has LinuxThreads.
     os::Linux::set_libpthread_version("linuxthreads");
   }
 
   if (strstr(libpthread_version(), "NPTL")) {
-    os::Linux::set_is_NPTL();
+     os::Linux::set_is_NPTL();
   } else {
-    os::Linux::set_is_LinuxThreads();
+     os::Linux::set_is_LinuxThreads();
   }
 
   // LinuxThreads have two flavors: floating-stack mode, which allows variable
   // stack size; and fixed-stack mode. NPTL is always floating-stack.
   if (os::Linux::is_NPTL() || os::Linux::supports_variable_stack_size()) {
-    os::Linux::set_is_floating_stack();
+     os::Linux::set_is_floating_stack();
   }
 }
 
@@ -656,9 +656,9 @@
 // should always be true if the function is not inlined.
 
 #if __GNUC__ < 3    // gcc 2.x does not support noinline attribute
-  #define NOINLINE
+#define NOINLINE
 #else
-  #define NOINLINE __attribute__ ((noinline))
+#define NOINLINE __attribute__ ((noinline))
 #endif
 
 static void _expand_stack_to(address bottom) NOINLINE;
@@ -909,9 +909,9 @@
 
   // Aborted due to thread limit being reached
   if (state == ZOMBIE) {
-    thread->set_osthread(NULL);
-    delete osthread;
-    return false;
+      thread->set_osthread(NULL);
+      delete osthread;
+      return false;
   }
 
   // The thread is returned suspended (in state INITIALIZED),
@@ -931,7 +931,7 @@
 
 bool os::create_attached_thread(JavaThread* thread) {
 #ifdef ASSERT
-  thread->verify_not_published();
+    thread->verify_not_published();
 #endif
 
   // Allocate the OSThread object
@@ -1003,7 +1003,7 @@
     // Restore caller's signal mask
     sigset_t sigmask = osthread->caller_sigmask();
     pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
-  }
+   }
 
   delete osthread;
 }
@@ -1059,7 +1059,7 @@
          "os::init did not locate initial thread's stack region");
   if ((address)&dummy >= initial_thread_stack_bottom() &&
       (address)&dummy < initial_thread_stack_bottom() + initial_thread_stack_size()) {
-    return true;
+       return true;
   } else {
     return false;
   }
@@ -1073,10 +1073,10 @@
     while (!feof(fp)) {
       if (fscanf(fp, "%p-%p", &low, &high) == 2) {
         if (low <= addr && addr < high) {
-          if (vma_low)  *vma_low  = low;
-          if (vma_high) *vma_high = high;
-          fclose(fp);
-          return true;
+           if (vma_low)  *vma_low  = low;
+           if (vma_high) *vma_high = high;
+           fclose(fp);
+           return true;
         }
       }
       for (;;) {
@@ -1113,7 +1113,7 @@
   // FIXME: alt signal stack is gone, maybe we can relax this constraint?
   // Problem still exists RH7.2 (IA64 anyway) but 2MB is a little small
   if (stack_size > 2 * K * K IA64_ONLY(*2)) {
-    stack_size = 2 * K * K IA64_ONLY(*2);
+      stack_size = 2 * K * K IA64_ONLY(*2);
   }
   // Try to figure out where the stack base (top) is. This is harder.
   //
@@ -1233,11 +1233,11 @@
 #undef _DFM
 
       if (i != 28 - 2) {
-        assert(false, "Bad conversion from /proc/self/stat");
-        // product mode - assume we are the initial thread, good luck in the
-        // embedded case.
-        warning("Can't detect initial thread stack location - bad conversion");
-        stack_start = (uintptr_t) &rlim;
+         assert(false, "Bad conversion from /proc/self/stat");
+         // product mode - assume we are the initial thread, good luck in the
+         // embedded case.
+         warning("Can't detect initial thread stack location - bad conversion");
+         stack_start = (uintptr_t) &rlim;
       }
     } else {
       // For some reason we can't open /proc/self/stat (for example, running on
@@ -1275,9 +1275,9 @@
   stack_top = align_size_up(stack_top, page_size());
 
   if (max_size && stack_size > max_size) {
-    _initial_thread_stack_size = max_size;
+     _initial_thread_stack_size = max_size;
   } else {
-    _initial_thread_stack_size = stack_size;
+     _initial_thread_stack_size = stack_size;
   }
 
   _initial_thread_stack_size = align_size_down(_initial_thread_stack_size, page_size());
@@ -1334,7 +1334,7 @@
 
 
 #ifndef CLOCK_MONOTONIC
-  #define CLOCK_MONOTONIC (1)
+#define CLOCK_MONOTONIC (1)
 #endif
 
 void os::Linux::clock_init() {
@@ -1377,15 +1377,15 @@
 }
 
 #ifndef SYS_clock_getres
-  #if defined(IA32) || defined(AMD64)
-    #define SYS_clock_getres IA32_ONLY(266)  AMD64_ONLY(229)
-    #define sys_clock_getres(x,y)  ::syscall(SYS_clock_getres, x, y)
-  #else
-    #warning "SYS_clock_getres not defined for this platform, disabling fast_thread_cpu_time"
-    #define sys_clock_getres(x,y)  -1
-  #endif
+#if defined(IA32) || defined(AMD64)
+#define SYS_clock_getres IA32_ONLY(266)  AMD64_ONLY(229)
+#define sys_clock_getres(x,y)  ::syscall(SYS_clock_getres, x, y)
 #else
-  #define sys_clock_getres(x,y)  ::syscall(SYS_clock_getres, x, y)
+#warning "SYS_clock_getres not defined for this platform, disabling fast_thread_cpu_time"
+#define sys_clock_getres(x,y)  -1
+#endif
+#else
+#define sys_clock_getres(x,y)  ::syscall(SYS_clock_getres, x, y)
 #endif
 
 void os::Linux::fast_thread_clock_init() {
@@ -1407,8 +1407,8 @@
   // better than 1 sec. This is extra check for reliability.
 
   if (pthread_getcpuclockid_func &&
-      pthread_getcpuclockid_func(_main_thread, &clockid) == 0 &&
-      sys_clock_getres(clockid, &tp) == 0 && tp.tv_sec == 0) {
+     pthread_getcpuclockid_func(_main_thread, &clockid) == 0 &&
+     sys_clock_getres(clockid, &tp) == 0 && tp.tv_sec == 0) {
     _supports_fast_thread_cpu_time = true;
     _pthread_getcpuclockid = pthread_getcpuclockid_func;
   }
@@ -1751,9 +1751,9 @@
   int rslt = dl_iterate_phdr(address_to_library_name_callback, (void *)&data);
 
   if (rslt) {
-    // buf already contains library name
-    if (offset) *offset = addr - data.base;
-    return true;
+     // buf already contains library name
+     if (offset) *offset = addr - data.base;
+     return true;
   }
   if (dladdr((void*)addr, &dlinfo) != 0) {
     if (dlinfo.dli_fname != NULL) {
@@ -1770,9 +1770,9 @@
   return false;
 }
 
-// Loads .dll/.so and
-// in case of error it checks if .dll/.so was built for the
-// same architecture as Hotspot is running on
+  // Loads .dll/.so and
+  // in case of error it checks if .dll/.so was built for the
+  // same architecture as Hotspot is running on
 
 
 // Remember the stack's state. The Linux dynamic linker will change
@@ -1886,7 +1886,7 @@
 
   bool failed_to_read_elf_head=
     (sizeof(elf_head)!=
-     (::read(file_descriptor, &elf_head,sizeof(elf_head))));
+        (::read(file_descriptor, &elf_head,sizeof(elf_head))));
 
   ::close(file_descriptor);
   if (failed_to_read_elf_head) {
@@ -1902,7 +1902,7 @@
     char*       name;         // String representation
   } arch_t;
 
-#ifndef EM_486
+  #ifndef EM_486
   #define EM_486          6               /* Intel 80486 */
 #endif
 #ifndef EM_AARCH64
@@ -1985,7 +1985,7 @@
   }
 
   assert(running_arch_index != -1,
-         "Didn't find running architecture code (running_arch_code) in arch_array");
+    "Didn't find running architecture code (running_arch_code) in arch_array");
   if (running_arch_index == -1) {
     // Even though running architecture detection failed
     // we may still continue with reporting dlerror() message
@@ -2007,13 +2007,13 @@
   if (lib_arch.compat_class != arch_array[running_arch_index].compat_class) {
     if (lib_arch.name!=NULL) {
       ::snprintf(diag_msg_buf, diag_msg_max_length-1,
-                 " (Possible cause: can't load %s-bit .so on a %s-bit platform)",
-                 lib_arch.name, arch_array[running_arch_index].name);
+        " (Possible cause: can't load %s-bit .so on a %s-bit platform)",
+        lib_arch.name, arch_array[running_arch_index].name);
     } else {
       ::snprintf(diag_msg_buf, diag_msg_max_length-1,
-                 " (Possible cause: can't load this .so (machine code=0x%x) on a %s-bit platform)",
-                 lib_arch.code,
-                 arch_array[running_arch_index].name);
+      " (Possible cause: can't load this .so (machine code=0x%x) on a %s-bit platform)",
+        lib_arch.code,
+        arch_array[running_arch_index].name);
     }
   }
 
@@ -2081,7 +2081,7 @@
 static bool _print_ascii_file(const char* filename, outputStream* st) {
   int fd = ::open(filename, O_RDONLY);
   if (fd == -1) {
-    return false;
+     return false;
   }
 
   char buf[32];
@@ -2096,16 +2096,16 @@
 }
 
 void os::print_dll_info(outputStream *st) {
-  st->print_cr("Dynamic libraries:");
-
-  char fname[32];
-  pid_t pid = os::Linux::gettid();
-
-  jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid);
-
-  if (!_print_ascii_file(fname, st)) {
-    st->print("Can not get library information for pid = %d\n", pid);
-  }
+   st->print_cr("Dynamic libraries:");
+
+   char fname[32];
+   pid_t pid = os::Linux::gettid();
+
+   jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid);
+
+   if (!_print_ascii_file(fname, st)) {
+     st->print("Can not get library information for pid = %d\n", pid);
+   }
 }
 
 int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *param) {
@@ -2195,28 +2195,28 @@
 // an informative string like "6.0.6" or "wheezy/sid". Because of this
 // "Debian " is printed before the contents of the debian_version file.
 void os::Linux::print_distro_info(outputStream* st) {
-  if (!_print_ascii_file("/etc/oracle-release", st) &&
-      !_print_ascii_file("/etc/mandriva-release", st) &&
-      !_print_ascii_file("/etc/mandrake-release", st) &&
-      !_print_ascii_file("/etc/sun-release", st) &&
-      !_print_ascii_file("/etc/redhat-release", st) &&
-      !_print_ascii_file("/etc/lsb-release", st) &&
-      !_print_ascii_file("/etc/SuSE-release", st) &&
-      !_print_ascii_file("/etc/turbolinux-release", st) &&
-      !_print_ascii_file("/etc/gentoo-release", st) &&
-      !_print_ascii_file("/etc/ltib-release", st) &&
-      !_print_ascii_file("/etc/angstrom-version", st) &&
-      !_print_ascii_file("/etc/system-release", st) &&
-      !_print_ascii_file("/etc/os-release", st)) {
-
-    if (file_exists("/etc/debian_version")) {
-      st->print("Debian ");
-      _print_ascii_file("/etc/debian_version", st);
-    } else {
-      st->print("Linux");
-    }
-  }
-  st->cr();
+   if (!_print_ascii_file("/etc/oracle-release", st) &&
+       !_print_ascii_file("/etc/mandriva-release", st) &&
+       !_print_ascii_file("/etc/mandrake-release", st) &&
+       !_print_ascii_file("/etc/sun-release", st) &&
+       !_print_ascii_file("/etc/redhat-release", st) &&
+       !_print_ascii_file("/etc/lsb-release", st) &&
+       !_print_ascii_file("/etc/SuSE-release", st) &&
+       !_print_ascii_file("/etc/turbolinux-release", st) &&
+       !_print_ascii_file("/etc/gentoo-release", st) &&
+       !_print_ascii_file("/etc/ltib-release", st) &&
+       !_print_ascii_file("/etc/angstrom-version", st) &&
+       !_print_ascii_file("/etc/system-release", st) &&
+       !_print_ascii_file("/etc/os-release", st)) {
+
+       if (file_exists("/etc/debian_version")) {
+         st->print("Debian ");
+         _print_ascii_file("/etc/debian_version", st);
+       } else {
+         st->print("Linux");
+       }
+   }
+   st->cr();
 }
 
 void os::Linux::print_libversion_info(outputStream* st) {
@@ -2225,15 +2225,15 @@
   st->print("%s ", os::Linux::glibc_version());
   st->print("%s ", os::Linux::libpthread_version());
   if (os::Linux::is_LinuxThreads()) {
-    st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed");
+     st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed");
   }
   st->cr();
 }
 
 void os::Linux::print_full_memory_info(outputStream* st) {
-  st->print("\n/proc/meminfo:\n");
-  _print_ascii_file("/proc/meminfo", st);
-  st->cr();
+   st->print("\n/proc/meminfo:\n");
+   _print_ascii_file("/proc/meminfo", st);
+   st->cr();
 }
 
 void os::print_memory_info(outputStream* st) {
@@ -2323,8 +2323,8 @@
 
   char dli_fname[MAXPATHLEN];
   bool ret = dll_address_to_library_name(
-                                         CAST_FROM_FN_PTR(address, os::jvm_path),
-                                         dli_fname, sizeof(dli_fname), NULL);
+                CAST_FROM_FN_PTR(address, os::jvm_path),
+                dli_fname, sizeof(dli_fname), NULL);
   assert(ret, "cannot locate libjvm");
   char *rp = NULL;
   if (ret && dli_fname[0] != '\0') {
@@ -2386,11 +2386,11 @@
           rp = realpath(dli_fname, buf);
           if (rp == NULL) {
             return;
-          }
         }
       }
     }
   }
+  }
 
   strncpy(saved_jvm_path, buf, MAXPATHLEN);
   saved_jvm_path[MAXPATHLEN - 1] = '\0';
@@ -2414,13 +2414,13 @@
   // the program is interrupted by Ctrl-C, SIGINT is sent to every thread. We
   // don't want to flood the manager thread with sem_post requests.
   if (sig == SIGINT && Atomic::add(1, &sigint_count) > 1) {
-    return;
+      return;
   }
 
   // Ctrl-C is pressed during error reporting, likely because the error
   // handler fails to abort. Let VM die immediately.
   if (sig == SIGINT && is_error_reported()) {
-    os::die();
+     os::die();
   }
 
   os::signal_notify(sig);
@@ -2431,15 +2431,15 @@
 }
 
 class Semaphore : public StackObj {
- public:
-  Semaphore();
-  ~Semaphore();
-  void signal();
-  void wait();
-  bool trywait();
-  bool timedwait(unsigned int sec, int nsec);
- private:
-  sem_t _semaphore;
+  public:
+    Semaphore();
+    ~Semaphore();
+    void signal();
+    void wait();
+    bool trywait();
+    bool timedwait(unsigned int sec, int nsec);
+  private:
+    sem_t _semaphore;
 };
 
 Semaphore::Semaphore() {
@@ -2686,7 +2686,7 @@
 int os::Linux::commit_memory_impl(char* addr, size_t size, bool exec) {
   int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
   uintptr_t res = (uintptr_t) ::mmap(addr, size, prot,
-                                     MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
+                                   MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
   if (res != (uintptr_t) MAP_FAILED) {
     if (UseNUMAInterleaving) {
       numa_make_global(addr, size);
@@ -2721,12 +2721,12 @@
 
 // Define MAP_HUGETLB here so we can build HotSpot on old systems.
 #ifndef MAP_HUGETLB
-  #define MAP_HUGETLB 0x40000
+#define MAP_HUGETLB 0x40000
 #endif
 
 // Define MADV_HUGEPAGE here so we can build HotSpot on old systems.
 #ifndef MADV_HUGEPAGE
-  #define MADV_HUGEPAGE 14
+#define MADV_HUGEPAGE 14
 #endif
 
 int os::Linux::commit_memory_impl(char* addr, size_t size,
@@ -2794,7 +2794,7 @@
   Linux::numa_tonode_memory(addr, bytes, lgrp_hint);
 }
 
-bool os::numa_topology_changed() { return false; }
+bool os::numa_topology_changed()   { return false; }
 
 size_t os::numa_get_groups_num() {
   int max_node = Linux::numa_max_node();
@@ -2834,17 +2834,17 @@
   int retval = -1;
 
 #if defined(IA32)
-  #ifndef SYS_getcpu
-    #define SYS_getcpu 318
-  #endif
+# ifndef SYS_getcpu
+# define SYS_getcpu 318
+# endif
   retval = syscall(SYS_getcpu, &cpu, NULL, NULL);
 #elif defined(AMD64)
 // Unfortunately we have to bring all these macros here from vsyscall.h
 // to be able to compile on old linuxes.
-  #define __NR_vgetcpu 2
-  #define VSYSCALL_START (-10UL << 20)
-  #define VSYSCALL_SIZE 1024
-  #define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr))
+# define __NR_vgetcpu 2
+# define VSYSCALL_START (-10UL << 20)
+# define VSYSCALL_SIZE 1024
+# define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr))
   typedef long (*vgetcpu_t)(unsigned int *cpu, unsigned int *node, unsigned long *tcache);
   vgetcpu_t vgetcpu = (vgetcpu_t)VSYSCALL_ADDR(__NR_vgetcpu);
   retval = vgetcpu(&cpu, NULL, NULL);
@@ -2894,9 +2894,9 @@
       set_numa_tonode_memory(CAST_TO_FN_PTR(numa_tonode_memory_func_t,
                                             libnuma_dlsym(handle, "numa_tonode_memory")));
       set_numa_interleave_memory(CAST_TO_FN_PTR(numa_interleave_memory_func_t,
-                                                libnuma_dlsym(handle, "numa_interleave_memory")));
+                                            libnuma_dlsym(handle, "numa_interleave_memory")));
       set_numa_set_bind_policy(CAST_TO_FN_PTR(numa_set_bind_policy_func_t,
-                                              libnuma_dlsym(handle, "numa_set_bind_policy")));
+                                            libnuma_dlsym(handle, "numa_set_bind_policy")));
 
 
       if (numa_available() != -1) {
@@ -2968,7 +2968,7 @@
 
 bool os::pd_uncommit_memory(char* addr, size_t size) {
   uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE,
-                                     MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0);
+                MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0);
   return res  != (uintptr_t) MAP_FAILED;
 }
 
@@ -3057,8 +3057,8 @@
     if (mincore((address)stack_extent, os::vm_page_size(), vec) == -1) {
       // Fallback to slow path on all errors, including EAGAIN
       stack_extent = (uintptr_t) get_stack_commited_bottom(
-                                                           os::Linux::initial_thread_stack_bottom(),
-                                                           (size_t)addr - stack_extent);
+                                    os::Linux::initial_thread_stack_bottom(),
+                                    (size_t)addr - stack_extent);
     }
 
     if (stack_extent < (uintptr_t)addr) {
@@ -3131,7 +3131,7 @@
 }
 
 char* os::pd_reserve_memory(size_t bytes, char* requested_addr,
-                            size_t alignment_hint) {
+                         size_t alignment_hint) {
   return anon_mmap(requested_addr, bytes, (requested_addr != NULL));
 }
 
@@ -3322,8 +3322,8 @@
 
   if (!FLAG_IS_DEFAULT(LargePageSizeInBytes) && LargePageSizeInBytes != large_page_size) {
     warning("Setting LargePageSizeInBytes has no effect on this OS. Large page size is "
-            SIZE_FORMAT "%s.", byte_size_in_proper_unit(large_page_size),
-            proper_unit_for_byte_size(large_page_size));
+        SIZE_FORMAT "%s.", byte_size_in_proper_unit(large_page_size),
+        proper_unit_for_byte_size(large_page_size));
   }
 
   return large_page_size;
@@ -3403,7 +3403,7 @@
 }
 
 #ifndef SHM_HUGETLB
-  #define SHM_HUGETLB 04000
+#define SHM_HUGETLB 04000
 #endif
 
 char* os::Linux::reserve_memory_special_shm(size_t bytes, size_t alignment,
@@ -3430,25 +3430,25 @@
   // Currently, size is the total size of the heap
   int shmid = shmget(key, bytes, SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W);
   if (shmid == -1) {
-    // Possible reasons for shmget failure:
-    // 1. shmmax is too small for Java heap.
-    //    > check shmmax value: cat /proc/sys/kernel/shmmax
-    //    > increase shmmax value: echo "0xffffffff" > /proc/sys/kernel/shmmax
-    // 2. not enough large page memory.
-    //    > check available large pages: cat /proc/meminfo
-    //    > increase amount of large pages:
-    //          echo new_value > /proc/sys/vm/nr_hugepages
-    //      Note 1: different Linux may use different name for this property,
-    //            e.g. on Redhat AS-3 it is "hugetlb_pool".
-    //      Note 2: it's possible there's enough physical memory available but
-    //            they are so fragmented after a long run that they can't
-    //            coalesce into large pages. Try to reserve large pages when
-    //            the system is still "fresh".
-    if (warn_on_failure) {
-      jio_snprintf(msg, sizeof(msg), "Failed to reserve shared memory (errno = %d).", errno);
-      warning("%s", msg);
-    }
-    return NULL;
+     // Possible reasons for shmget failure:
+     // 1. shmmax is too small for Java heap.
+     //    > check shmmax value: cat /proc/sys/kernel/shmmax
+     //    > increase shmmax value: echo "0xffffffff" > /proc/sys/kernel/shmmax
+     // 2. not enough large page memory.
+     //    > check available large pages: cat /proc/meminfo
+     //    > increase amount of large pages:
+     //          echo new_value > /proc/sys/vm/nr_hugepages
+     //      Note 1: different Linux may use different name for this property,
+     //            e.g. on Redhat AS-3 it is "hugetlb_pool".
+     //      Note 2: it's possible there's enough physical memory available but
+     //            they are so fragmented after a long run that they can't
+     //            coalesce into large pages. Try to reserve large pages when
+     //            the system is still "fresh".
+     if (warn_on_failure) {
+       jio_snprintf(msg, sizeof(msg), "Failed to reserve shared memory (errno = %d).", errno);
+       warning("%s", msg);
+     }
+     return NULL;
   }
 
   // attach to the region
@@ -3462,11 +3462,11 @@
   shmctl(shmid, IPC_RMID, NULL);
 
   if ((intptr_t)addr == -1) {
-    if (warn_on_failure) {
-      jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err);
-      warning("%s", msg);
-    }
-    return NULL;
+     if (warn_on_failure) {
+       jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err);
+       warning("%s", msg);
+     }
+     return NULL;
   }
 
   return addr;
@@ -3484,7 +3484,7 @@
   if (warn_on_failure) {
     char msg[128];
     jio_snprintf(msg, sizeof(msg), "Failed to reserve large pages memory req_addr: "
-                 PTR_FORMAT " bytes: " SIZE_FORMAT " (errno = %d).", req_addr, bytes, error);
+        PTR_FORMAT " bytes: " SIZE_FORMAT " (errno = %d).", req_addr, bytes, error);
     warning("%s", msg);
   }
 }
@@ -3594,9 +3594,9 @@
   }
 
   if (lp_end != end) {
-    result = ::mmap(lp_end, end - lp_end, prot,
-                    MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,
-                    -1, 0);
+      result = ::mmap(lp_end, end - lp_end, prot,
+                      MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,
+                      -1, 0);
     if (result == MAP_FAILED) {
       ::munmap(start, lp_end - start);
       return NULL;
@@ -3734,12 +3734,12 @@
   // if kernel honors the hint then we can return immediately.
   char * addr = anon_mmap(requested_addr, bytes, false);
   if (addr == requested_addr) {
-    return requested_addr;
+     return requested_addr;
   }
 
   if (addr != NULL) {
-    // mmap() is successful but it fails to reserve at the requested address
-    anon_munmap(addr, bytes);
+     // mmap() is successful but it fails to reserve at the requested address
+     anon_munmap(addr, bytes);
   }
 
   int i;
@@ -4026,12 +4026,12 @@
   if ((s = ::getenv("_JAVA_SR_SIGNUM")) != 0) {
     int sig = ::strtol(s, 0, 10);
     if (sig > 0 || sig < _NSIG) {
-      SR_signum = sig;
+        SR_signum = sig;
     }
   }
 
   assert(SR_signum > SIGSEGV && SR_signum > SIGBUS,
-         "SR_signum must be greater than max(SIGSEGV, SIGBUS), see 4355769");
+        "SR_signum must be greater than max(SIGSEGV, SIGBUS), see 4355769");
 
   sigemptyset(&SR_sigset);
   sigaddset(&SR_sigset, SR_signum);
@@ -4343,12 +4343,12 @@
     signal_setting_t begin_signal_setting = NULL;
     signal_setting_t end_signal_setting = NULL;
     begin_signal_setting = CAST_TO_FN_PTR(signal_setting_t,
-                                          dlsym(RTLD_DEFAULT, "JVM_begin_signal_setting"));
+                             dlsym(RTLD_DEFAULT, "JVM_begin_signal_setting"));
     if (begin_signal_setting != NULL) {
       end_signal_setting = CAST_TO_FN_PTR(signal_setting_t,
-                                          dlsym(RTLD_DEFAULT, "JVM_end_signal_setting"));
+                             dlsym(RTLD_DEFAULT, "JVM_end_signal_setting"));
       get_signal_action = CAST_TO_FN_PTR(get_signal_t,
-                                         dlsym(RTLD_DEFAULT, "JVM_get_signal_action"));
+                            dlsym(RTLD_DEFAULT, "JVM_get_signal_action"));
       libjsig_is_loaded = true;
       assert(UseSignalChaining, "should enable signal-chaining");
     }
@@ -4414,7 +4414,7 @@
 // We will never set this flag, and we should
 // ignore this flag in our diagnostic
 #ifdef SIGNIFICANT_SIGNAL_MASK
-  #undef SIGNIFICANT_SIGNAL_MASK
+#undef SIGNIFICANT_SIGNAL_MASK
 #endif
 #define SIGNIFICANT_SIGNAL_MASK (~0x04000000)
 
@@ -4473,7 +4473,7 @@
 
   // Check: is it our handler?
   if (handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) ||
-      handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) {
+     handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) {
     // It is our signal handler
     // check for flags, reset system-used one!
     if ((int)sa.sa_flags != os::Linux::get_our_sigflags(sig)) {
@@ -4486,7 +4486,7 @@
 }
 
 
-#define DO_SIGNAL_CHECK(sig)                      \
+#define DO_SIGNAL_CHECK(sig) \
   do {                                            \
     if (!sigismember(&check_signal_done, sig)) {  \
       os::Linux::check_signal_handler(sig);       \
@@ -4748,22 +4748,22 @@
   // Add in 2*BytesPerWord times page size to account for VM stack during
   // class initialization depending on 32 or 64 bit VM.
   os::Linux::min_stack_allowed = MAX2(os::Linux::min_stack_allowed,
-                                      (size_t)(StackYellowPages+StackRedPages+StackShadowPages) * Linux::page_size() +
-                                      (2*BytesPerWord COMPILER2_PRESENT(+1)) * Linux::vm_default_page_size());
+            (size_t)(StackYellowPages+StackRedPages+StackShadowPages) * Linux::page_size() +
+                    (2*BytesPerWord COMPILER2_PRESENT(+1)) * Linux::vm_default_page_size());
 
   size_t threadStackSizeInBytes = ThreadStackSize * K;
   if (threadStackSizeInBytes != 0 &&
       threadStackSizeInBytes < os::Linux::min_stack_allowed) {
-    tty->print_cr("\nThe stack size specified is too small, "
-                  "Specify at least %dk",
-                  os::Linux::min_stack_allowed/ K);
-    return JNI_ERR;
+        tty->print_cr("\nThe stack size specified is too small, "
+                      "Specify at least %dk",
+                      os::Linux::min_stack_allowed/ K);
+        return JNI_ERR;
   }
 
   // Make the stack size a multiple of the page size so that
   // the yellow/red zones can be guarded.
   JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes,
-                                                vm_page_size()));
+        vm_page_size()));
 
   Linux::capture_initial_stack(JavaThread::stack_size_at_create());
 
@@ -4773,9 +4773,9 @@
 
   Linux::libpthread_init();
   if (PrintMiscellaneous && (Verbose || WizardMode)) {
-    tty->print_cr("[HotSpot is running with %s, %s(%s)]\n",
-                  Linux::glibc_version(), Linux::libpthread_version(),
-                  Linux::is_floating_stack() ? "floating stack" : "fixed stack");
+     tty->print_cr("[HotSpot is running with %s, %s(%s)]\n",
+          Linux::glibc_version(), Linux::libpthread_version(),
+          Linux::is_floating_stack() ? "floating stack" : "fixed stack");
   }
 
   if (UseNUMA) {
@@ -4826,10 +4826,10 @@
       if (status != 0) {
         if (PrintMiscellaneous && (Verbose || WizardMode)) {
           perror("os::init_2 setrlimit failed");
-        }
       }
     }
   }
+  }
 
   // Initialize lock used to serialize thread creation (see os::create_thread)
   Linux::set_createThread_lock(new Mutex(Mutex::leaf, "createThread_lock", false));
@@ -4913,12 +4913,12 @@
 }
 
 class PcFetcher : public os::SuspendedThreadTask {
- public:
+public:
   PcFetcher(Thread* thread) : os::SuspendedThreadTask(thread) {}
   ExtendedPC result();
- protected:
+protected:
   void do_task(const os::SuspendedThreadTaskContext& context);
- private:
+private:
   ExtendedPC _epc;
 };
 
@@ -4953,17 +4953,17 @@
 int os::Linux::safe_cond_timedwait(pthread_cond_t *_cond,
                                    pthread_mutex_t *_mutex,
                                    const struct timespec *_abstime) {
-  if (is_NPTL()) {
-    return pthread_cond_timedwait(_cond, _mutex, _abstime);
-  } else {
-    // 6292965: LinuxThreads pthread_cond_timedwait() resets FPU control
-    // word back to default 64bit precision if condvar is signaled. Java
-    // wants 53bit precision.  Save and restore current value.
-    int fpu = get_fpu_control_word();
-    int status = pthread_cond_timedwait(_cond, _mutex, _abstime);
-    set_fpu_control_word(fpu);
-    return status;
-  }
+   if (is_NPTL()) {
+      return pthread_cond_timedwait(_cond, _mutex, _abstime);
+   } else {
+      // 6292965: LinuxThreads pthread_cond_timedwait() resets FPU control
+      // word back to default 64bit precision if condvar is signaled. Java
+      // wants 53bit precision.  Save and restore current value.
+      int fpu = get_fpu_control_word();
+      int status = pthread_cond_timedwait(_cond, _mutex, _abstime);
+      set_fpu_control_word(fpu);
+      return status;
+   }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -4976,7 +4976,7 @@
     st->print(PTR_FORMAT ": ", addr);
     if (dlinfo.dli_sname != NULL && dlinfo.dli_saddr != NULL) {
       st->print("%s+%#x", dlinfo.dli_sname,
-                addr - (intptr_t)dlinfo.dli_saddr);
+                 addr - (intptr_t)dlinfo.dli_saddr);
     } else if (dlinfo.dli_fbase != NULL) {
       st->print("<offset %#x>", addr - (intptr_t)dlinfo.dli_fbase);
     } else {
@@ -5142,12 +5142,12 @@
   // With recent kernels, we will perform this check exactly once.
   static sig_atomic_t O_CLOEXEC_is_known_to_work = 0;
   if (!O_CLOEXEC_is_known_to_work) {
-    int flags = ::fcntl(fd, F_GETFD);
+        int flags = ::fcntl(fd, F_GETFD);
     if (flags != -1) {
       if ((flags & FD_CLOEXEC) != 0)
         O_CLOEXEC_is_known_to_work = 1;
       else
-        ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
+            ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
     }
   }
 #endif
@@ -5209,8 +5209,8 @@
 
 // Map a block of memory.
 char* os::pd_map_memory(int fd, const char* file_name, size_t file_offset,
-                        char *addr, size_t bytes, bool read_only,
-                        bool allow_exec) {
+                     char *addr, size_t bytes, bool read_only,
+                     bool allow_exec) {
   int prot;
   int flags = MAP_PRIVATE;
 
@@ -5239,8 +5239,8 @@
 
 // Remap a block of memory.
 char* os::pd_remap_memory(int fd, const char* file_name, size_t file_offset,
-                          char *addr, size_t bytes, bool read_only,
-                          bool allow_exec) {
+                       char *addr, size_t bytes, bool read_only,
+                       bool allow_exec) {
   // same as map_memory() on this OS
   return os::map_memory(fd, file_name, file_offset, addr, bytes, read_only,
                         allow_exec);
@@ -5392,7 +5392,7 @@
     }
   } else {
     jio_fprintf(stderr,
-                "Could not open pause file '%s', continuing immediately.\n", filename);
+      "Could not open pause file '%s', continuing immediately.\n", filename);
   }
 }
 
@@ -5519,28 +5519,28 @@
 
   int v;
   for (;;) {
-    v = _Event;
-    if (Atomic::cmpxchg(v-1, &_Event, v) == v) break;
+      v = _Event;
+      if (Atomic::cmpxchg(v-1, &_Event, v) == v) break;
   }
   guarantee(v >= 0, "invariant");
   if (v == 0) {
-    // Do this the hard way by blocking ...
-    int status = pthread_mutex_lock(_mutex);
-    assert_status(status == 0, status, "mutex_lock");
-    guarantee(_nParked == 0, "invariant");
-    ++_nParked;
-    while (_Event < 0) {
-      status = pthread_cond_wait(_cond, _mutex);
-      // for some reason, under 2.7 lwp_cond_wait() may return ETIME ...
-      // Treat this the same as if the wait was interrupted
-      if (status == ETIME) { status = EINTR; }
-      assert_status(status == 0 || status == EINTR, status, "cond_wait");
-    }
-    --_nParked;
+     // Do this the hard way by blocking ...
+     int status = pthread_mutex_lock(_mutex);
+     assert_status(status == 0, status, "mutex_lock");
+     guarantee(_nParked == 0, "invariant");
+     ++_nParked;
+     while (_Event < 0) {
+        status = pthread_cond_wait(_cond, _mutex);
+        // for some reason, under 2.7 lwp_cond_wait() may return ETIME ...
+        // Treat this the same as if the wait was interrupted
+        if (status == ETIME) { status = EINTR; }
+        assert_status(status == 0 || status == EINTR, status, "cond_wait");
+     }
+     --_nParked;
 
     _Event = 0;
-    status = pthread_mutex_unlock(_mutex);
-    assert_status(status == 0, status, "mutex_unlock");
+     status = pthread_mutex_unlock(_mutex);
+     assert_status(status == 0, status, "mutex_unlock");
     // Paranoia to ensure our locked and lock-free paths interact
     // correctly with each other.
     OrderAccess::fence();
@@ -5558,8 +5558,8 @@
 
   int v;
   for (;;) {
-    v = _Event;
-    if (Atomic::cmpxchg(v-1, &_Event, v) == v) break;
+      v = _Event;
+      if (Atomic::cmpxchg(v-1, &_Event, v) == v) break;
   }
   guarantee(v >= 0, "invariant");
   if (v != 0) return OS_OK;
@@ -5603,7 +5603,7 @@
   }
   --_nParked;
   if (_Event >= 0) {
-    ret = OS_OK;
+     ret = OS_OK;
   }
   _Event = 0;
   status = pthread_mutex_unlock(_mutex);
@@ -5620,8 +5620,8 @@
   //    0 => 1 : just return
   //    1 => 1 : just return
   //   -1 => either 0 or 1; must signal target thread
-  //         That is, we can safely transition _Event from -1 to either
-  //         0 or 1.
+  //          That is, we can safely transition _Event from -1 to either
+  //          0 or 1.
   // See also: "Semaphores in Plan 9" by Mullender & Cox
   //
   // Note: Forcing a transition from "-1" to "1" on an unpark() means
@@ -5855,14 +5855,14 @@
     if (_cur_index != -1) {
       // thread is definitely parked
       if (WorkAroundNPTLTimedWaitHang) {
-        status = pthread_cond_signal(&_cond[_cur_index]);
+        status = pthread_cond_signal (&_cond[_cur_index]);
         assert(status == 0, "invariant");
         status = pthread_mutex_unlock(_mutex);
         assert(status == 0, "invariant");
       } else {
         status = pthread_mutex_unlock(_mutex);
         assert(status == 0, "invariant");
-        status = pthread_cond_signal(&_cond[_cur_index]);
+        status = pthread_cond_signal (&_cond[_cur_index]);
         assert(status == 0, "invariant");
       }
     } else {
@@ -5899,7 +5899,7 @@
   // On IA64 there's no fork syscall, we have to use fork() and hope for
   // the best...
   pid_t pid = NOT_IA64(syscall(__NR_fork);)
-  IA64_ONLY(fork();)
+              IA64_ONLY(fork();)
 
   if (pid < 0) {
     // fork failed
@@ -5930,26 +5930,26 @@
     // Wait for the child process to exit.  This returns immediately if
     // the child has already exited. */
     while (waitpid(pid, &status, 0) < 0) {
-      switch (errno) {
-      case ECHILD: return 0;
-      case EINTR: break;
-      default: return -1;
-      }
+        switch (errno) {
+        case ECHILD: return 0;
+        case EINTR: break;
+        default: return -1;
+        }
     }
 
     if (WIFEXITED(status)) {
-      // The child exited normally; get its exit code.
-      return WEXITSTATUS(status);
+       // The child exited normally; get its exit code.
+       return WEXITSTATUS(status);
     } else if (WIFSIGNALED(status)) {
-      // The child exited because of a signal
-      // The best value to return is 0x80 + signal number,
-      // because that is what all Unix shells do, and because
-      // it allows callers to distinguish between process exit and
-      // process death by signal.
-      return 0x80 + WTERMSIG(status);
+       // The child exited because of a signal
+       // The best value to return is 0x80 + signal number,
+       // because that is what all Unix shells do, and because
+       // it allows callers to distinguish between process exit and
+       // process death by signal.
+       return 0x80 + WTERMSIG(status);
     } else {
-      // Unknown exit code; pass it through
-      return status;
+       // Unknown exit code; pass it through
+       return status;
     }
   }
 }
@@ -5963,43 +5963,43 @@
 // as libawt.so, and renamed libawt_xawt.so
 //
 bool os::is_headless_jre() {
-  struct stat statbuf;
-  char buf[MAXPATHLEN];
-  char libmawtpath[MAXPATHLEN];
-  const char *xawtstr  = "/xawt/libmawt.so";
-  const char *new_xawtstr = "/libawt_xawt.so";
-  char *p;
-
-  // Get path to libjvm.so
-  os::jvm_path(buf, sizeof(buf));
-
-  // Get rid of libjvm.so
-  p = strrchr(buf, '/');
+    struct stat statbuf;
+    char buf[MAXPATHLEN];
+    char libmawtpath[MAXPATHLEN];
+    const char *xawtstr  = "/xawt/libmawt.so";
+    const char *new_xawtstr = "/libawt_xawt.so";
+    char *p;
+
+    // Get path to libjvm.so
+    os::jvm_path(buf, sizeof(buf));
+
+    // Get rid of libjvm.so
+    p = strrchr(buf, '/');
   if (p == NULL) {
     return false;
   } else {
     *p = '\0';
   }
 
-  // Get rid of client or server
-  p = strrchr(buf, '/');
+    // Get rid of client or server
+    p = strrchr(buf, '/');
   if (p == NULL) {
     return false;
   } else {
     *p = '\0';
   }
 
-  // check xawt/libmawt.so
-  strcpy(libmawtpath, buf);
-  strcat(libmawtpath, xawtstr);
-  if (::stat(libmawtpath, &statbuf) == 0) return false;
-
-  // check libawt_xawt.so
-  strcpy(libmawtpath, buf);
-  strcat(libmawtpath, new_xawtstr);
-  if (::stat(libmawtpath, &statbuf) == 0) return false;
-
-  return true;
+    // check xawt/libmawt.so
+    strcpy(libmawtpath, buf);
+    strcat(libmawtpath, xawtstr);
+    if (::stat(libmawtpath, &statbuf) == 0) return false;
+
+    // check libawt_xawt.so
+    strcpy(libmawtpath, buf);
+    strcat(libmawtpath, new_xawtstr);
+    if (::stat(libmawtpath, &statbuf) == 0) return false;
+
+    return true;
 }
 
 // Get the default path to the core file
@@ -6076,12 +6076,12 @@
 
 #ifndef PRODUCT
 
-#define test_log(...)              \
-  do {                             \
-    if (VerboseInternalVMTests) {  \
-      tty->print_cr(__VA_ARGS__);  \
-      tty->flush();                \
-    }                              \
+#define test_log(...) \
+  do {\
+    if (VerboseInternalVMTests) { \
+      tty->print_cr(__VA_ARGS__); \
+      tty->flush(); \
+    }\
   } while (false)
 
 class TestReserveMemorySpecial : AllStatic {
@@ -6125,11 +6125,11 @@
 
   static void test_reserve_memory_special_huge_tlbfs_mixed(size_t size, size_t alignment) {
     if (!UseHugeTLBFS) {
-      return;
+        return;
     }
 
     test_log("test_reserve_memory_special_huge_tlbfs_mixed(" SIZE_FORMAT ", " SIZE_FORMAT ")",
-             size, alignment);
+        size, alignment);
 
     assert(size >= os::large_page_size(), "Incorrect input to test");
 
--- a/src/os/posix/dtrace/hotspot_jni.d	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/os/posix/dtrace/hotspot_jni.d	Fri Mar 06 14:27:49 2015 -0800
@@ -300,6 +300,8 @@
   probe GetLongField__return(uintptr_t);
   probe GetMethodID__entry(void*, void*, const char*, const char*);
   probe GetMethodID__return(uintptr_t);
+  probe GetModule__entry(void*, void*);
+  probe GetModule__return(void*);
   probe GetObjectArrayElement__entry(void*, void*, uintptr_t);
   probe GetObjectArrayElement__return(void*);
   probe GetObjectClass__entry(void*, void*);
--- a/src/share/vm/c1/c1_LIRGenerator.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/c1/c1_LIRGenerator.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -3067,7 +3067,7 @@
     LIR_Opr klass = new_pointer_register();
     __ move(new LIR_Address(arg.result(), java_lang_Class::klass_offset_in_bytes(), klass_pointer_type), klass, info);
     LIR_Opr id = new_register(T_LONG);
-    ByteSize offset = TRACE_ID_OFFSET;
+    ByteSize offset = TRACE_KLASS_TRACE_ID_OFFSET;
     LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG);
     __ move(trace_id_addr, id);
     __ logical_or(id, LIR_OprFact::longConst(0x01l), id);
--- a/src/share/vm/c1/c1_Runtime1.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/c1/c1_Runtime1.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -638,7 +638,7 @@
   NOT_PRODUCT(_throw_class_cast_exception_count++;)
   ResourceMark rm(thread);
   char* message = SharedRuntime::generate_class_cast_message(
-    thread, object->klass()->external_name());
+    thread, object->klass());
   SharedRuntime::throw_and_post_jvmti_exception(
     thread, vmSymbols::java_lang_ClassCastException(), message);
 JRT_END
--- a/src/share/vm/ci/ciEnv.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/ci/ciEnv.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -370,9 +370,9 @@
     resolved_klass = ObjArrayKlass::cast(resolved_klass)->bottom_klass();
   }
   if (resolved_klass->oop_is_instance()) {
-    return Reflection::verify_class_access(accessing_klass->get_Klass(),
-                                           resolved_klass,
-                                           true);
+    return (Reflection::verify_class_access(accessing_klass->get_Klass(),
+                                            resolved_klass,
+                                            true) == Reflection::ACCESS_OK);
   }
   return true;
 }
--- a/src/share/vm/classfile/classFileParser.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/classFileParser.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -28,6 +28,8 @@
 #include "classfile/classLoaderData.inline.hpp"
 #include "classfile/defaultMethods.hpp"
 #include "classfile/javaClasses.inline.hpp"
+#include "classfile/moduleEntry.hpp"
+#include "classfile/packageEntry.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/verificationType.hpp"
@@ -4127,6 +4129,17 @@
       this_klass->set_host_klass(host_klass());
     }
 
+    // After the majority of the set up for this_klass has occurred,
+    // set its PackageEntry.  Critical to be done after set_name
+    // and set_host_klass in order to handle anonymous classes
+    // properly.
+    oop cl = this_klass->is_anonymous() ? this_klass->host_klass()->class_loader() :
+                                          this_klass->class_loader();
+
+    Handle clh = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(cl));
+    ClassLoaderData* cld = ClassLoaderData::class_loader_data_or_null(clh());
+    this_klass->set_package(this_klass->name(), cld, CHECK_NULL);
+
     // Set up Method*::intrinsic_id as soon as we know the names of methods.
     // (We used to do this lazily, but now we query it in Rewriter,
     // which is eagerly done for every method, so we might as well do it now,
@@ -4190,8 +4203,13 @@
       }
     }
 
+    // Obtain this_klass' module
+    ModuleEntry* module_entry = this_klass->module();
+    // Check for unnamed module, obtain j.l.r.Module if available
+    Handle class_module(THREAD, ((module_entry == NULL) ? (oop)NULL : module_entry->module()));
+
     // Allocate mirror and initialize static fields
-    java_lang_Class::create_mirror(this_klass, class_loader, protection_domain,
+    java_lang_Class::create_mirror(this_klass, class_loader, class_module, protection_domain,
                                    CHECK_(nullHandle));
 
     // Generate any default methods - default methods are interface methods
@@ -4586,17 +4604,29 @@
 
 void ClassFileParser::check_super_class_access(instanceKlassHandle this_klass, TRAPS) {
   Klass* super = this_klass->super();
-  if ((super != NULL) &&
-      (!Reflection::verify_class_access(this_klass(), super, false))) {
-    ResourceMark rm(THREAD);
-    Exceptions::fthrow(
-      THREAD_AND_LOCATION,
-      vmSymbols::java_lang_IllegalAccessError(),
-      "class %s cannot access its superclass %s",
-      this_klass->external_name(),
-      InstanceKlass::cast(super)->external_name()
-    );
-    return;
+  if (super != NULL) {
+    Reflection::VerifyClassAccessResults vca_result =
+      Reflection::verify_class_access(this_klass(), super, false);
+    if (vca_result != Reflection::ACCESS_OK) {
+      ResourceMark rm(THREAD);
+      char* msg =  Reflection::verify_class_access_msg(this_klass(), super, vca_result);
+      if (msg == NULL) {
+        Exceptions::fthrow(
+          THREAD_AND_LOCATION,
+          vmSymbols::java_lang_IllegalAccessError(),
+          "class %s cannot access its superclass %s",
+          this_klass->external_name(),
+          InstanceKlass::cast(super)->external_name());
+      } else {
+        // Add additional message content.
+        Exceptions::fthrow(
+          THREAD_AND_LOCATION,
+          vmSymbols::java_lang_IllegalAccessError(),
+          "superclass access check failed: %s",
+          msg);
+      }
+      return;
+    }
   }
 }
 
@@ -4607,15 +4637,26 @@
   for (int i = lng - 1; i >= 0; i--) {
     Klass* k = local_interfaces->at(i);
     assert (k != NULL && k->is_interface(), "invalid interface");
-    if (!Reflection::verify_class_access(this_klass(), k, false)) {
+    Reflection::VerifyClassAccessResults vca_result =
+      Reflection::verify_class_access(this_klass(), k, false);
+    if (vca_result != Reflection::ACCESS_OK) {
       ResourceMark rm(THREAD);
-      Exceptions::fthrow(
-        THREAD_AND_LOCATION,
-        vmSymbols::java_lang_IllegalAccessError(),
-        "class %s cannot access its superinterface %s",
-        this_klass->external_name(),
-        InstanceKlass::cast(k)->external_name()
-      );
+      char* msg =  Reflection::verify_class_access_msg(this_klass(), k, vca_result);
+      if (msg == NULL) {
+        Exceptions::fthrow(
+          THREAD_AND_LOCATION,
+          vmSymbols::java_lang_IllegalAccessError(),
+          "class %s cannot access its superinterface %s",
+          this_klass->external_name(),
+          InstanceKlass::cast(k)->external_name());
+      } else {
+        // Add additional message content.
+        Exceptions::fthrow(
+          THREAD_AND_LOCATION,
+          vmSymbols::java_lang_IllegalAccessError(),
+          "superinterface check failed: %s",
+          msg);
+      }
       return;
     }
   }
@@ -4714,12 +4755,13 @@
   const bool is_super      = (flags & JVM_ACC_SUPER)      != 0;
   const bool is_enum       = (flags & JVM_ACC_ENUM)       != 0;
   const bool is_annotation = (flags & JVM_ACC_ANNOTATION) != 0;
+  const bool is_module_info= (flags & JVM_ACC_MODULE)     != 0;
   const bool major_gte_15  = _major_version >= JAVA_1_5_VERSION;
 
   if ((is_abstract && is_final) ||
       (is_interface && !is_abstract) ||
       (is_interface && major_gte_15 && (is_super || is_enum)) ||
-      (!is_interface && major_gte_15 && is_annotation)) {
+      (!is_interface && major_gte_15 && is_annotation) || is_module_info) {
     ResourceMark rm(THREAD);
     Exceptions::fthrow(
       THREAD_AND_LOCATION,
@@ -4869,65 +4911,9 @@
 
 void ClassFileParser::verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) {
   assert(_need_verify, "only called when _need_verify is true");
-  int i = 0;
-  int count = length >> 2;
-  for (int k=0; k<count; k++) {
-    unsigned char b0 = buffer[i];
-    unsigned char b1 = buffer[i+1];
-    unsigned char b2 = buffer[i+2];
-    unsigned char b3 = buffer[i+3];
-    // For an unsigned char v,
-    // (v | v - 1) is < 128 (highest bit 0) for 0 < v < 128;
-    // (v | v - 1) is >= 128 (highest bit 1) for v == 0 or v >= 128.
-    unsigned char res = b0 | b0 - 1 |
-                        b1 | b1 - 1 |
-                        b2 | b2 - 1 |
-                        b3 | b3 - 1;
-    if (res >= 128) break;
-    i += 4;
+  if (!UTF8::is_legal_utf8(buffer, length, _major_version <= 47)) {
+        classfile_parse_error("Illegal UTF8 string in constant pool in class file %s", CHECK);
   }
-  for(; i < length; i++) {
-    unsigned short c;
-    // no embedded zeros
-    guarantee_property((buffer[i] != 0), "Illegal UTF8 string in constant pool in class file %s", CHECK);
-    if(buffer[i] < 128) {
-      continue;
-    }
-    if ((i + 5) < length) { // see if it's legal supplementary character
-      if (UTF8::is_supplementary_character(&buffer[i])) {
-        c = UTF8::get_supplementary_character(&buffer[i]);
-        i += 5;
-        continue;
-      }
-    }
-    switch (buffer[i] >> 4) {
-      default: break;
-      case 0x8: case 0x9: case 0xA: case 0xB: case 0xF:
-        classfile_parse_error("Illegal UTF8 string in constant pool in class file %s", CHECK);
-      case 0xC: case 0xD:  // 110xxxxx  10xxxxxx
-        c = (buffer[i] & 0x1F) << 6;
-        i++;
-        if ((i < length) && ((buffer[i] & 0xC0) == 0x80)) {
-          c += buffer[i] & 0x3F;
-          if (_major_version <= 47 || c == 0 || c >= 0x80) {
-            // for classes with major > 47, c must a null or a character in its shortest form
-            break;
-          }
-        }
-        classfile_parse_error("Illegal UTF8 string in constant pool in class file %s", CHECK);
-      case 0xE:  // 1110xxxx 10xxxxxx 10xxxxxx
-        c = (buffer[i] & 0xF) << 12;
-        i += 2;
-        if ((i < length) && ((buffer[i-1] & 0xC0) == 0x80) && ((buffer[i] & 0xC0) == 0x80)) {
-          c += ((buffer[i-1] & 0x3F) << 6) + (buffer[i] & 0x3F);
-          if (_major_version <= 47 || c >= 0x800) {
-            // for classes with major > 47, c must be in its shortest form
-            break;
-          }
-        }
-        classfile_parse_error("Illegal UTF8 string in constant pool in class file %s", CHECK);
-    }  // end of switch
-  } // end of for
 }
 
 // Checks if name is a legal class name.
@@ -5111,6 +5097,8 @@
 // or <clinit>.  Note that method names may not be <init> or <clinit> in this
 // method.  Because these names have been checked as special cases before
 // calling this method in verify_legal_method_name.
+//
+// This method is also called from jvm.cpp. Be careful about changing it.
 bool ClassFileParser::verify_unqualified_name(
     char* name, unsigned int length, int type) {
   jchar ch;
@@ -5118,8 +5106,15 @@
   for (char* p = name; p != name + length; ) {
     ch = *p;
     if (ch < 128) {
-      p++;
-      if (ch == '.' || ch == ';' || ch == '[' ) {
+      if (ch == '.') {
+        // permit '.' in module names unless it's the first char, or
+        // preceding char is also a '.', or last char is a '.'.
+        if ((type != LegalModule) || (p == name) || (*(p-1) == '.') ||
+          (p == name + length - 1)) {
+          return false;
+        }
+      }
+      if (ch == ';' || ch == '[' ) {
         return false;   // do not permit '.', ';', or '['
       }
       if (type != LegalClass && ch == '/') {
@@ -5128,6 +5123,7 @@
       if (type == LegalMethod && (ch == '<' || ch == '>')) {
         return false;   // do not permit '<' or '>' in method names
       }
+      p++;
     } else {
       char* tmp_p = UTF8::next(p, &ch);
       p = tmp_p;
--- a/src/share/vm/classfile/classFileParser.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/classFileParser.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -204,8 +204,10 @@
 
   ClassFileStream* _stream;              // Actual input stream
 
-  enum { LegalClass, LegalField, LegalMethod }; // used to verify unqualified names
+  public:
+  enum { LegalClass, LegalField, LegalMethod, LegalModule }; // used to verify unqualified names
 
+  private:
   // Accessors
   ClassFileStream* stream()                        { return _stream; }
   void set_stream(ClassFileStream* st)             { _stream = st; }
@@ -379,7 +381,7 @@
   void verify_legal_class_modifiers(jint flags, TRAPS);
   void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS);
   void verify_legal_method_modifiers(jint flags, bool is_interface, Symbol* name, TRAPS);
-  bool verify_unqualified_name(char* name, unsigned int length, int type);
+
   char* skip_over_field_name(char* name, bool slash_ok, unsigned int length);
   char* skip_over_field_signature(char* signature, bool void_ok, unsigned int length, TRAPS);
 
@@ -483,6 +485,7 @@
   static void check_super_interface_access(instanceKlassHandle this_klass, TRAPS);
   static void check_final_method_override(instanceKlassHandle this_klass, TRAPS);
   static void check_illegal_static_method(instanceKlassHandle this_klass, TRAPS);
+  static bool verify_unqualified_name(char* name, unsigned int length, int type);
 };
 
 #endif // SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP
--- a/src/share/vm/classfile/classLoader.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/classLoader.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -30,6 +30,9 @@
 #include "classfile/classLoaderData.inline.hpp"
 #include "classfile/imageFile.hpp"
 #include "classfile/javaClasses.hpp"
+#include "classfile/moduleEntry.hpp"
+#include "classfile/modules.hpp"
+#include "classfile/packageEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "compiler/compileBroker.hpp"
@@ -124,10 +127,12 @@
 PerfCounter*    ClassLoader::_isUnsyncloadClass = NULL;
 PerfCounter*    ClassLoader::_load_instance_class_failCounter = NULL;
 
-ClassPathEntry* ClassLoader::_first_entry         = NULL;
-ClassPathEntry* ClassLoader::_last_entry          = NULL;
-int             ClassLoader::_num_entries         = 0;
+ClassPathEntry* ClassLoader::_first_entry = NULL;
+ClassPathEntry* ClassLoader::_last_entry  = NULL;
+int             ClassLoader::_num_entries = 0;
+ClassPathEntry* ClassLoader::_first_append_entry = NULL;
 PackageHashtable* ClassLoader::_package_hash_table = NULL;
+bool            ClassLoader::_has_bootmodules_jimage = false;
 
 #if INCLUDE_CDS
 SharedPathsMiscInfo* ClassLoader::_shared_paths_misc_info = NULL;
@@ -167,7 +172,6 @@
   _dir = copy;
 }
 
-
 ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) {
   // construct full path name
   char path[JVM_MAXPATHLEN];
@@ -352,6 +356,188 @@
   }
 }
 
+// Find package names for java.base module by scanning directories starting
+// with java_base_path.  Add each found package to the boot classloader's
+// package_entry table.
+// To find package names, look at each sub-directory.  If it contains one or
+// more '.class' files then create a package name from the sub-directory path
+// relative to java_base_path.  Also, make sure that the package name delimeters
+// are virgules.
+static void package_list(char *java_base_path, ModuleEntry* jb_module) {
+  Thread* THREAD = Thread::current();
+  ResourceMark rm(THREAD);
+  struct stat stat_buf;
+  struct dirent* dir_entry;
+  char stat_path[JVM_MAXPATHLEN];
+  ClassLoaderData* null_cld = ClassLoaderData::the_null_class_loader_data();
+  PackageEntryTable* null_cld_packages = null_cld->packages();
+  const char* file_sep = os::file_separator();
+
+  size_t start_len = strlen(java_base_path);
+  char *current_path = java_base_path;
+  GrowableArray<char *>* dir_stack = new GrowableArray<char *>(15);
+  if (TraceModules) {
+    tty->print_cr("module path:  %s", java_base_path);
+  }
+
+  // Loop through all the sub-directories
+  while (current_path != NULL) {
+    bool dir_already_listed = false;
+    DIR *dir = os::opendir(current_path);
+    if (dir == NULL) {
+      vm_exit_during_initialization(
+        "Unable to open modules directory: ", current_path);
+    }
+
+    char *dbuf = NEW_C_HEAP_ARRAY(
+      char, os::readdir_buf_size(current_path), mtInternal);
+
+    MutexLocker m1(Module_lock, THREAD);
+
+    // Look at each entry in the directory.
+    while ((dir_entry = os::readdir(dir, (dirent *)dbuf)) != NULL) {
+      // Ignore anything starting with '.', including '.' and '..'.
+      if (dir_entry->d_name[0] != '.') {
+
+        // Create full path for stat().
+        sprintf(stat_path, "%s%s%s", current_path, file_sep, dir_entry->d_name);
+        int res = os::stat(stat_path, &stat_buf);
+        assert(res == 0, err_msg("os::stat() failed, file: %s", dir_entry->d_name));
+
+        if ((stat_buf.st_mode & S_IFMT) == S_IFDIR) {
+          // It's a sub-directory, push it on the stack to be looked at later.
+          char *dir_name = NEW_RESOURCE_ARRAY(char, strlen(stat_path) + 1);
+          strcpy(dir_name, stat_path);
+          dir_stack->push(dir_name);
+
+        } else if (!dir_already_listed &&
+                   ((stat_buf.st_mode & S_IFMT) == S_IFREG) &&
+                   string_ends_with(dir_entry->d_name, ".class")) {
+          // This directory entry is a file ending in '.class'.  Construct a
+          // package name from its dir by chopping off the original prefix and
+          // starting '/'.
+          char *package_name = current_path + start_len + 1;
+
+          // Ignore classes in .../modules/java.base directory.
+          if (strlen(package_name) != 0) {
+            if (file_sep[0] != '/') { // Change file separators to '/'.
+              for (char* p = package_name; *p != 0; ++p) {
+                if (*p == file_sep[0]) *p = '/';
+              }
+            }
+            // Found the package name, first look it up in the symbol table.
+            TempNewSymbol pkg_name = SymbolTable::new_symbol(package_name, CHECK);
+
+            // Insert into the null class loader's package entry table.
+            PackageEntry* pkg = null_cld_packages->locked_create_entry_or_null(
+                                  pkg_name, jb_module);
+            assert(pkg != NULL,
+                   err_msg("Package %s not found in package entry table", package_name));
+            dir_already_listed = true;
+            if (TraceModules) {
+              tty->print_cr("package:  %s", package_name);
+            }
+          }
+        }
+      }
+    }
+    FREE_C_HEAP_ARRAY(char, dbuf);
+    current_path = dir_stack->is_empty() ? NULL : dir_stack->pop();
+    os::closedir(dir);
+  }
+}
+
+static void process_javabase(const char* path) {
+  Thread* THREAD = Thread::current();
+
+  // The build exploded directory for java.base being opened due to
+  // processing the first well known class java/lang/Object.  Must create
+  // java.base's module entry and package entries for the null class
+  // loader prior to loading j.l.Ojbect.
+  ClassLoaderData* null_cld = ClassLoaderData::the_null_class_loader_data();
+
+  // Get module entry table
+  ModuleEntryTable* null_cld_modules = null_cld->modules();
+  assert(null_cld_modules != NULL, "No module entry table for boot class loader?");
+
+  // Add entry, without a java.lang.reflect.Module object yet.
+  // The j.l.r.m will be added later.
+  ModuleEntry* jb_module = NULL;
+  TempNewSymbol version_symbol = SymbolTable::new_symbol(Modules::default_version(), THREAD);
+  assert(version_symbol != NULL, "Symbol creation failed");
+  TempNewSymbol location_symbol = SymbolTable::new_symbol("jrt:/java.base", THREAD);
+  assert(location_symbol != NULL, "Symbol creation failed");
+  {
+    MutexLocker ml(Module_lock, THREAD);
+    jb_module = null_cld_modules->locked_create_entry_or_null(
+      NULL, vmSymbols::java_base(), version_symbol, location_symbol, null_cld);
+    assert(jb_module != NULL, "no entry created for java.base");
+  }
+
+  if (TraceModules) {
+    tty->print_cr("[Local packages for java.base:]");
+  }
+
+  char modules_path[JVM_MAXPATHLEN];
+  strcpy(modules_path, path);
+  package_list(modules_path, jb_module);
+}
+
+static void process_javabase(ImageFile *image) {
+  Thread* THREAD = Thread::current();
+  ResourceMark rm(THREAD);
+
+  // bootmodules.jimage being opened due to processing
+  // the first well known class java/lang/Object.  Must create
+  // java.base's module entry and package entries for the null
+  // class loader prior to loading j.l.Ojbect.
+  ClassLoaderData* null_cld = ClassLoaderData::the_null_class_loader_data();
+
+  // Get module entry table
+  PackageEntryTable* null_cld_packages = null_cld->packages();
+  ModuleEntryTable* null_cld_modules = null_cld->modules();
+  assert((null_cld_modules != NULL || null_cld_packages != NULL),
+         "No package and/or module table for boot class loader?");
+
+  // Add entry, without a java.lang.reflect.Module object yet.
+  // The j.l.r.m will be added later.
+  TempNewSymbol version_symbol = SymbolTable::new_symbol(Modules::default_version(), THREAD);
+  assert(version_symbol != NULL, "Symbol creation failed");
+  TempNewSymbol location_symbol = SymbolTable::new_symbol("jrt:/java.base", THREAD);
+  assert(location_symbol != NULL, "Symbol creation failed");
+  MutexLocker ml(Module_lock, THREAD);
+  ModuleEntry* jb_module = null_cld_modules->locked_create_entry_or_null(
+    NULL, vmSymbols::java_base(), version_symbol, location_symbol, null_cld);
+  assert(jb_module != NULL, "no entry created for java.base");
+
+  if (TraceModules) {
+    tty->print_cr("[Local packages for java.base:]");
+  }
+
+  GrowableArray<const char*>* packages = image->packages(vmSymbols::java_base()->as_C_string());
+
+  for (int i = 0; i < packages->length(); i++) {
+    // Verify valid package name.
+    const char* package_name = packages->at(i);
+    if (!Modules::verify_package_name((char *)package_name)) {
+      vm_exit_during_initialization(
+        "invalid package name in bootmodules.jimage file",
+        package_name == NULL ? "NULL" : package_name);
+    }
+
+    // Found the package name, first look it up in the symbol table.
+    TempNewSymbol pkg_name = SymbolTable::new_symbol(package_name, CHECK);
+
+    // Insert into the null class loader's package entry table.
+    PackageEntry* pkg = null_cld_packages->locked_create_entry_or_null(pkg_name, jb_module);
+    assert(pkg != NULL, "Package should have been defined and found in package entry table");
+
+    if (TraceModules) {
+      tty->print_cr("  %s", package_name);
+    }
+  }
+}
+
 ClassPathImageEntry::ClassPathImageEntry(char* name) : ClassPathEntry(), _image(new ImageFile(name)) {
   bool opened = _image->open();
   if (!opened) {
@@ -375,11 +561,28 @@
   u8 size;
   _image->get_resource(name, buffer, size);
 
+  if (!buffer) {
+    const char *pslash = strrchr(name, '/');
+
+    if (pslash) {
+      char path[JVM_MAXPATHLEN];
+      int len = pslash - name;
+      strncpy(path, name, len);
+      path[len] = '\0';
+      const char* moduleName = _image->module(path);
+
+      if (moduleName) {
+        jio_snprintf(path, JVM_MAXPATHLEN - 1, "/%s/%s", moduleName, name);
+        _image->get_resource(path, buffer, size);
+      }
+    }
+  }
+
   if (buffer) {
     if (UsePerfData) {
       ClassLoader::perf_sys_classfile_bytes_read()->inc(size);
     }
-    return new ClassFileStream(buffer, (int)size, (char*)name);  // Resource allocated
+    return new ClassFileStream(buffer, (int)size, _image->name());  // Resource allocated
   }
 
   return NULL;
@@ -397,14 +600,8 @@
 
     if (location_data) {
        ImageLocation location(location_data);
-       const char* parent = location.get_attribute(ImageLocation::ATTRIBUTE_PARENT, strings);
-       const char* base = location.get_attribute(ImageLocation::ATTRIBUTE_BASE, strings);
-       const char* extension = location.get_attribute(ImageLocation::ATTRIBUTE_EXTENSION, strings);
-       assert((strlen(parent) + strlen(base) + strlen(extension)) < JVM_MAXPATHLEN, "path exceeds buffer");
        char path[JVM_MAXPATHLEN];
-       strcpy(path, parent);
-       strcat(path, base);
-       strcat(path, extension);
+       _image->location_path(location, path, JVM_MAXPATHLEN);
        ClassLoader::compile_the_world_in(path, loader, CHECK);
     }
   }
@@ -491,7 +688,7 @@
     _shared_paths_misc_info->add_boot_classpath(sys_class_path);
   }
 #endif
-  setup_search_path(sys_class_path);
+  setup_search_path(sys_class_path, true);
 }
 
 #if INCLUDE_CDS
@@ -511,10 +708,11 @@
 }
 #endif
 
-void ClassLoader::setup_search_path(const char *class_path) {
+void ClassLoader::setup_search_path(const char *class_path, bool bootstrap_search) {
   int offset = 0;
   int len = (int)strlen(class_path);
   int end = 0;
+  bool mark_append_entry = false;
 
   // Iterate over class path entries
   for (int start = 0; start < len; start = end) {
@@ -523,10 +721,24 @@
     }
     EXCEPTION_MARK;
     ResourceMark rm(THREAD);
+    mark_append_entry = (mark_append_entry ||
+                         (bootstrap_search && (start == Arguments::bootclasspath_a_index())));
+
     char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
     strncpy(path, &class_path[start], end - start);
     path[end - start] = '\0';
-    update_class_path_entry_list(path, false);
+    update_class_path_entry_list(path, false, mark_append_entry);
+
+    // Check on the state of the boot loader's append path
+    if (mark_append_entry && (_first_append_entry == NULL)) {
+      // Failure to mark the first append entry, most likely
+      // due to a non-existent path. Record the next entry
+      // as the first boot loader append entry.
+      mark_append_entry = true;
+    } else {
+      mark_append_entry = false;
+    }
+
 #if INCLUDE_CDS
     if (DumpSharedSpaces) {
       check_shared_classpath(path);
@@ -538,6 +750,23 @@
   }
 }
 
+static bool is_override_dir(const char *path) {
+  assert(string_ends_with(path, "java.base"), "must end in java.base");
+  if (Arguments::override_dir() != NULL) {
+    size_t path_len = strlen(path);
+    const char *override_path = Arguments::override_dir();
+    size_t override_len = strlen(override_path);
+
+    // Does path_len = override_len + strlen(/java.base)?
+    if(path_len == override_len + 1 + 9 &&
+      (path[override_len] ==  os::file_separator()[0]) &&
+      string_starts_with(path, override_path)) {
+      return true;
+    }
+  }
+  return false;
+}
+
 ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const struct stat* st,
                                                      bool lazy, bool throw_exception, TRAPS) {
   JavaThread* thread = JavaThread::current();
@@ -632,6 +861,18 @@
   return NULL;
 }
 
+// The boot class loader must adhere to specfic visibility rules.
+// Prior to loading a class in a named package, the package is checked
+// to see if it is in a module defined to the boot loader. If the
+// package is not in a module defined to the boot loader, the class
+// must be loaded only in the boot loader's append path, which
+// consists of [-Xbootclasspath/a]; [jvmti appended entries]
+void ClassLoader::set_first_append_entry(ClassPathEntry *new_entry) {
+  if (_first_append_entry == NULL) {
+    _first_append_entry = new_entry;
+  }
+}
+
 // returns true if entry already on class path
 bool ClassLoader::contains_entry(ClassPathEntry *entry) {
   ClassPathEntry* e = _first_entry;
@@ -657,25 +898,44 @@
   _num_entries ++;
 }
 
+void ClassLoader::add_to_list(const char *apath) {
+  update_class_path_entry_list((char*)apath, false, false);
+}
+
 // Returns true IFF the file/dir exists and the entry was successfully created.
 bool ClassLoader::update_class_path_entry_list(const char *path,
                                                bool check_for_duplicates,
+                                               bool mark_append_entry,
                                                bool throw_exception) {
   struct stat st;
   if (os::stat(path, &st) == 0) {
     // File or directory found
     ClassPathEntry* new_entry = NULL;
     Thread* THREAD = Thread::current();
-    new_entry = create_class_path_entry(path, &st, LazyBootClassLoader, throw_exception, CHECK_(false));
+
+    // If entry is the bootmodules.jimage then pass FALSE for 'lazy' to ensure
+    // that the jimage is opened.  This will enable process_javabase() to read it.
+    bool lazy = string_ends_with(path, "bootmodules.jimage") ? false : LazyBootClassLoader;
+
+    new_entry = create_class_path_entry(path, &st, lazy, throw_exception, CHECK_(false));
     if (new_entry == NULL) {
       return false;
     }
+
+    // Ensure that the first boot loader append entry will always be set correctly.
+    assert((!mark_append_entry ||
+            (mark_append_entry && (!check_for_duplicates || !contains_entry(new_entry)))),
+           "failed to mark boot loader's first append boundary");
+
     // The kernel VM adds dynamically to the end of the classloader path and
     // doesn't reorder the bootclasspath which would break java.lang.Package
     // (see PackageInfo).
     // Add new entry to linked list
     if (!check_for_duplicates || !contains_entry(new_entry)) {
       ClassLoaderExt::add_class_path_entry(path, check_for_duplicates, new_entry);
+      if (mark_append_entry) {
+        set_first_append_entry(new_entry);
+      }
     }
     return true;
   } else {
@@ -988,7 +1248,7 @@
 }
 
 
-instanceKlassHandle ClassLoader::load_classfile(Symbol* h_name, TRAPS) {
+instanceKlassHandle ClassLoader::load_classfile(Symbol* h_name, bool search_append_only, TRAPS) {
   ResourceMark rm(THREAD);
   const char* class_name = h_name->as_C_string();
   EventMark m("loading class %s", class_name);
@@ -1005,14 +1265,29 @@
   // Lookup stream for parsing .class file
   ClassFileStream* stream = NULL;
   int classpath_index = 0;
-  ClassPathEntry* e = NULL;
+  ClassPathEntry* e = (!search_append_only ? _first_entry : _first_append_entry);
+  ClassPathEntry* last_e = (!search_append_only ? _first_append_entry : NULL);
   instanceKlassHandle h;
   {
     PerfClassTraceTime vmtimer(perf_sys_class_lookup_time(),
                                ((JavaThread*) THREAD)->get_thread_stat()->perf_timers_addr(),
                                PerfClassTraceTime::CLASS_LOAD);
-    e = _first_entry;
-    while (e != NULL) {
+    if (search_append_only) {
+      // For the boot loader append path search, must calculate
+      // the starting classpath_index prior to attempting to
+      // load the classfile.
+      ClassPathEntry *tmp_e = _first_entry;
+      while ((tmp_e != NULL) && (tmp_e != _first_append_entry)) {
+        tmp_e = tmp_e->next();
+        ++classpath_index;
+      }
+    }
+
+    // Attempt to load the classfile from either:
+    //   - [-Xoverride:dir]; exploded build | bootmodules.jimage
+    //     or
+    //   - [-Xbootclasspath/a]; [jvmti appended entries]
+    while ((e != NULL) && (e != last_e)) {
       stream = e->open_stream(file_name, CHECK_NULL);
       if (!context.check(stream, classpath_index)) {
         return h; // NULL
@@ -1223,6 +1498,45 @@
   return true;
 }
 
+
+void ClassLoader::define_javabase() {
+  ClassPathEntry* e = _first_entry;
+  ClassPathEntry* last_e = _first_append_entry;
+
+  assert(!ModuleEntryTable::javabase_created() && !ClassLoader::has_bootmodules_jimage(),
+         "java.base has already been processed");
+
+  // When looking for the jimage file, only
+  // search the boot loader's module path which
+  // can consist of [-Xoverride]; exploded build | bootmodules.jimage
+  // Do not search the boot loader's append path.
+  while ((e != NULL) && (e != last_e)) {
+    ImageFile *image = e->image();
+    if (image != NULL && string_ends_with(e->name(), "bootmodules.jimage")) {
+      process_javabase(image);
+      set_has_bootmodules_jimage(true);
+      return;
+    }
+    e = e->next();
+  }
+
+  // If bootmodules.jimage has not been located,
+  // assume an exploded build.
+  e = _first_entry;
+  while ((e != NULL) && (e != last_e)) {
+    const char *path = e->name();
+    if (string_ends_with(path, "java.base") &&
+        !is_override_dir(path) &&
+        !e->is_jar_file()) {
+      process_javabase(path);
+      return;
+    }
+    e = e->next();
+  }
+
+  vm_exit_during_initialization("Unable to correctly define java.base from either the exploded build or bootmodules.jimage");
+}
+
 #ifndef PRODUCT
 
 void ClassLoader::verify() {
--- a/src/share/vm/classfile/classLoader.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/classLoader.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -35,6 +35,8 @@
 
 // Class path entry (directory or zip file)
 
+class ImageFile;
+
 class ClassPathEntry: public CHeapObj<mtClass> {
  private:
   ClassPathEntry* _next;
@@ -47,6 +49,7 @@
   }
   virtual bool is_jar_file() = 0;
   virtual const char* name() = 0;
+  virtual ImageFile* image() = 0;
   virtual bool is_lazy();
   // Constructor
   ClassPathEntry();
@@ -65,6 +68,7 @@
  public:
   bool is_jar_file()  { return false;  }
   const char* name()  { return _dir; }
+  ImageFile* image()  { return NULL; }
   ClassPathDirEntry(const char* dir);
   ClassFileStream* open_stream(const char* name, TRAPS);
   // Debugging
@@ -94,6 +98,7 @@
  public:
   bool is_jar_file()  { return true;  }
   const char* name()  { return _zip_name; }
+  ImageFile* image()  { return NULL; }
   ClassPathZipEntry(jzfile* zip, const char* zip_name);
   ~ClassPathZipEntry();
   u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS);
@@ -117,6 +122,7 @@
  public:
   bool is_jar_file();
   const char* name()  { return _path; }
+  ImageFile* image()  { return NULL; }
   LazyClassPathEntry(const char* path, const struct stat* st, bool throw_exception);
   virtual ~LazyClassPathEntry();
   u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS);
@@ -129,7 +135,6 @@
 };
 
 // For java image files
-class ImageFile;
 class ClassPathImageEntry: public ClassPathEntry {
 private:
   ImageFile *_image;
@@ -137,6 +142,7 @@
   bool is_jar_file()  { return false;  }
   bool is_open()  { return _image != NULL; }
   const char* name();
+  ImageFile* image()  { return _image; }
   ClassPathImageEntry(char* name);
   ~ClassPathImageEntry();
   ClassFileStream* open_stream(const char* name, TRAPS);
@@ -194,16 +200,30 @@
   static PerfCounter* _isUnsyncloadClass;
   static PerfCounter* _load_instance_class_failCounter;
 
-  // First entry in linked list of ClassPathEntry instances
+  // First entry in linked list of ClassPathEntry instances.
+  // This consists of entries made up by:
+  //   - boot loader modules
+  //     [-Xoverride]; exploded build | bootmodules.jimage;
+  //   - boot loader append path
+  //     [-Xbootclasspath/a]; [jvmti appended entries]
   static ClassPathEntry* _first_entry;
   // Last entry in linked list of ClassPathEntry instances
   static ClassPathEntry* _last_entry;
   static int _num_entries;
 
+  // Pointer into the linked list of ClassPathEntry instances.
+  // Marks the start of:
+  //   - the boot loader's append path
+  //     [-Xbootclasspath/a]; [jvmti appended entries]
+  static ClassPathEntry* _first_append_entry;
+
   // Hash table used to keep track of loaded packages
   static PackageHashtable* _package_hash_table;
   static const char* _shared_archive;
 
+  // True if the boot path has a bootmodules.jimage
+  static bool _has_bootmodules_jimage;
+
   // Info used by CDS
   CDS_ONLY(static SharedPathsMiscInfo * _shared_paths_misc_info;)
 
@@ -218,7 +238,7 @@
 
   // Initialization
   static void setup_bootstrap_search_path();
-  static void setup_search_path(const char *class_path);
+  static void setup_search_path(const char *class_path, bool setting_bootstrap);
 
   static void load_zip_library();
   static ClassPathEntry* create_class_path_entry(const char *path, const struct stat* st,
@@ -227,11 +247,13 @@
   // Canonicalizes path names, so strcmp will work properly. This is mainly
   // to avoid confusing the zip library
   static bool get_canonical_path(const char* orig, char* out, int len);
+
  public:
   static jboolean decompress(void *in, u8 inSize, void *out, u8 outSize, char **pmsg);
   static int crc32(int crc, const char* buf, int len);
   static bool update_class_path_entry_list(const char *path,
                                            bool check_for_duplicates,
+                                           bool mark_append_entry,
                                            bool throw_exception=true);
   static void print_bootclasspath();
 
@@ -296,8 +318,19 @@
     return _load_instance_class_failCounter;
   }
 
+  // Sets _has_bootmodules_jimage to TRUE if bootmodules.jimage file exists.
+  static void set_has_bootmodules_jimage(bool val) {
+    _has_bootmodules_jimage = val;
+  }
+
+  static bool has_bootmodules_jimage() { return _has_bootmodules_jimage; }
+
+  // Read the packages for module java.base from the bootmodules.jimage
+  // file, if it exists. If it does not, assume exploded build.
+  static void define_javabase();
+
   // Load individual .class file
-  static instanceKlassHandle load_classfile(Symbol* h_name, TRAPS);
+  static instanceKlassHandle load_classfile(Symbol* h_name, bool search_append_only, TRAPS);
 
   // If the specified package has been loaded by the system, then returns
   // the name of the directory or ZIP file that the package was loaded from.
@@ -354,6 +387,8 @@
   static jlong class_link_count();
   static jlong class_link_time_ms();
 
+  static void set_first_append_entry(ClassPathEntry* entry);
+
   // indicates if class path already contains a entry (exact match by name)
   static bool contains_entry(ClassPathEntry* entry);
 
@@ -363,6 +398,9 @@
   // creates a class path zip entry (returns NULL if JAR file cannot be opened)
   static ClassPathZipEntry* create_class_path_zip_entry(const char *apath);
 
+  // add a path to class path list
+  static void add_to_list(const char* apath);
+
   // Debugging
   static void verify()              PRODUCT_RETURN;
 
--- a/src/share/vm/classfile/classLoaderData.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/classLoaderData.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -51,6 +51,8 @@
 #include "classfile/classLoaderData.inline.hpp"
 #include "classfile/javaClasses.hpp"
 #include "classfile/metadataOnStackMark.hpp"
+#include "classfile/moduleEntry.hpp"
+#include "classfile/packageEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "code/codeCache.hpp"
 #include "memory/gcLocker.hpp"
@@ -81,6 +83,7 @@
   // The null-class-loader should always be kept alive.
   _keep_alive(is_anonymous || h_class_loader.is_null()),
   _metaspace(NULL), _unloading(false), _klasses(NULL),
+  _modules(NULL), _packages(NULL),
   _claimed(0), _jmethod_ids(NULL), _handles(NULL), _deallocate_list(NULL),
   _next(NULL), _dependencies(dependencies),
   _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true,
@@ -119,6 +122,9 @@
   if (klass_closure != NULL) {
     classes_do(klass_closure);
   }
+  if (_modules != NULL) {
+    _modules->oops_do(f);
+  }
 }
 
 void ClassLoaderData::Dependencies::oops_do(OopClosure* f) {
@@ -166,6 +172,30 @@
   }
 }
 
+void ClassLoaderData::modules_do(void f(ModuleEntry*)) {
+  if (_modules != NULL) {
+    for (int i = 0; i < _modules->table_size(); i++) {
+      for (ModuleEntry* entry = _modules->bucket(i);
+                              entry != NULL;
+                              entry = entry->next()) {
+        f(entry);
+      }
+    }
+  }
+}
+
+void ClassLoaderData::packages_do(void f(PackageEntry*)) {
+  if (_packages != NULL) {
+    for (int i = 0; i < _packages->table_size(); i++) {
+      for (PackageEntry* entry = _packages->bucket(i);
+                              entry != NULL;
+                              entry = entry->next()) {
+        f(entry);
+      }
+    }
+  }
+}
+
 void ClassLoaderData::record_dependency(Klass* k, TRAPS) {
   ClassLoaderData * const from_cld = this;
   ClassLoaderData * const to_cld = k->class_loader_data();
@@ -334,6 +364,32 @@
   }
 }
 
+PackageEntryTable* ClassLoaderData::packages() {
+  // Lazily create the package entry table at first request.
+  if (_packages == NULL) {
+    MutexLockerEx m1(metaspace_lock(), Mutex::_no_safepoint_check_flag);
+    // Check again if _packages has been allocated while we were getting this lock.
+    if (_packages != NULL) {
+      return _packages;
+    }
+    _packages = new PackageEntryTable(PackageEntryTable::_packagetable_entry_size);
+  }
+  return _packages;
+}
+
+ModuleEntryTable* ClassLoaderData::modules() {
+  // Lazily create the module entry table at first request.
+  if (_modules == NULL) {
+    MutexLockerEx m1(metaspace_lock(), Mutex::_no_safepoint_check_flag);
+    // Check again if _modules has been allocated while we were getting this lock.
+    if (_modules != NULL) {
+      return _modules;
+    }
+    _modules = new ModuleEntryTable(ModuleEntryTable::_moduletable_entry_size);
+  }
+  return _modules;
+}
+
 oop ClassLoaderData::keep_alive_object() const {
   assert(!keep_alive(), "Don't use with CLDs that are artificially kept alive");
   return is_anonymous() ? _klasses->java_mirror() : class_loader();
@@ -351,6 +407,20 @@
   // Release C heap structures for all the classes.
   classes_do(InstanceKlass::release_C_heap_structures);
 
+  // Release C heap allocated hashtable for all the packages.
+  if (_packages != NULL) {
+    // Destroy the table itself
+    delete _packages;
+    _packages = NULL;
+  }
+
+  // Release C heap allocated hashtable for all the modules.
+  if (_modules != NULL) {
+    // Destroy the table itself
+    delete _modules;
+    _modules = NULL;
+  }
+
   Metaspace *m = _metaspace;
   if (m != NULL) {
     _metaspace = NULL;
@@ -673,6 +743,40 @@
   }
 }
 
+void ClassLoaderDataGraph::modules_do(void f(ModuleEntry*)) {
+  assert_locked_or_safepoint(Module_lock);
+  for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
+    cld->modules_do(f);
+  }
+}
+
+void ClassLoaderDataGraph::modules_unloading_do(void f(ModuleEntry*)) {
+  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
+  // Only walk the head until any clds not purged from prior unloading
+  // (CMS doesn't purge right away).
+  for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
+    assert(cld->is_unloading(), "invariant");
+    cld->modules_do(f);
+  }
+}
+
+void ClassLoaderDataGraph::packages_do(void f(PackageEntry*)) {
+  assert_locked_or_safepoint(Module_lock);
+  for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
+    cld->packages_do(f);
+  }
+}
+
+void ClassLoaderDataGraph::packages_unloading_do(void f(PackageEntry*)) {
+  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
+  // Only walk the head until any clds not purged from prior unloading
+  // (CMS doesn't purge right away).
+  for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
+    assert(cld->is_unloading(), "invariant");
+    cld->packages_do(f);
+  }
+}
+
 void ClassLoaderDataGraph::loaded_classes_do(KlassClosure* klass_closure) {
   for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
     cld->loaded_classes_do(klass_closure);
@@ -684,6 +788,7 @@
   // Only walk the head until any clds not purged from prior unloading
   // (CMS doesn't purge right away).
   for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
+    assert(cld->is_unloading(), "invariant");
     cld->classes_do(f);
   }
 }
@@ -749,6 +854,12 @@
   data = _head;
   while (data != NULL) {
     if (data->is_alive(is_alive_closure)) {
+      if (!data->packageTable_is_null()) {
+        data->packages()->purge_all_package_exports();
+      }
+      if (!data->moduleTable_is_null()) {
+        data->modules()->purge_all_module_reads();
+      }
       prev = data;
       data = data->next();
       continue;
@@ -810,7 +921,7 @@
     classes_unloaded = true;
   }
   if (classes_unloaded) {
-    Metaspace::purge();
+  Metaspace::purge();
     set_metaspace_oom(false);
   }
 }
@@ -962,6 +1073,7 @@
 Ticks ClassLoaderDataGraph::_class_unload_time;
 
 void ClassLoaderDataGraph::class_unload_event(Klass* const k) {
+  assert(k != NULL, "invariant");
 
   // post class unload event
   EventClassUnload event(UNTIMED);
--- a/src/share/vm/classfile/classLoaderData.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/classLoaderData.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -53,6 +53,10 @@
 class JNIMethodBlock;
 class JNIHandleBlock;
 class Metadebug;
+class ModuleEntry;
+class PackageEntry;
+class ModuleEntryTable;
+class PackageEntryTable;
 
 // GC root for walking class loader data created
 
@@ -93,6 +97,10 @@
   static void classes_do(KlassClosure* klass_closure);
   static void classes_do(void f(Klass* const));
   static void methods_do(void f(Method*));
+  static void modules_do(void f(ModuleEntry*));
+  static void modules_unloading_do(void f(ModuleEntry*));
+  static void packages_do(void f(PackageEntry*));
+  static void packages_unloading_do(void f(PackageEntry*));
   static void loaded_classes_do(KlassClosure* klass_closure);
   static void classes_unloading_do(void f(Klass* const));
   static bool do_unloading(BoolObjectClosure* is_alive, bool clean_alive);
@@ -174,9 +182,11 @@
   volatile int _claimed;   // true if claimed, for example during GC traces.
                            // To avoid applying oop closure more than once.
                            // Has to be an int because we cas it.
+  JNIHandleBlock* _handles; // Handles to constant pool arrays
+
   Klass* _klasses;         // The classes defined by the class loader.
-
-  JNIHandleBlock* _handles; // Handles to constant pool arrays
+  PackageEntryTable* _packages; // The packages defined by the class loader.
+  ModuleEntryTable* _modules;   // The modules defined by the class loader.
 
   // These method IDs are created for the class loader and set to NULL when the
   // class loader is unloaded.  They are rarely freed, only for redefine classes
@@ -217,6 +227,8 @@
   void loaded_classes_do(KlassClosure* klass_closure);
   void classes_do(void f(InstanceKlass*));
   void methods_do(void f(Method*));
+  void modules_do(void f(ModuleEntry*));
+  void packages_do(void f(PackageEntry*));
 
   // Deallocate free list during class unloading.
   void free_deallocate_list();
@@ -299,6 +311,10 @@
   bool contains_klass(Klass* k);
   void record_dependency(Klass* to, TRAPS);
   void init_dependencies(TRAPS);
+  PackageEntryTable* packages();
+  bool packageTable_is_null() { return (_packages == NULL); }
+  ModuleEntryTable* modules();
+  bool moduleTable_is_null() { return (_modules == NULL); }
 
   void add_to_deallocate_list(Metadata* m);
 
--- a/src/share/vm/classfile/classLoaderExt.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/classLoaderExt.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -67,6 +67,13 @@
   }
   static void append_boot_classpath(ClassPathEntry* new_entry) {
     ClassLoader::add_to_list(new_entry);
+    // During jvmti live phase an entry can be appended to the boot
+    // loader's ClassPathEntry instances.  Need to mark the start
+    // of the boot loader's append path in case there was no reason
+    // to mark it initially in setup_bootstrap_search_path.
+    if (ClassLoader::_first_append_entry == NULL) {
+      ClassLoader::set_first_append_entry(new_entry);
+    }
   }
   static void setup_search_paths() {}
 };
--- a/src/share/vm/classfile/dictionary.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/dictionary.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -777,4 +777,3 @@
 
   _pd_cache_table->verify();
 }
-
--- a/src/share/vm/classfile/imageFile.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/imageFile.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -27,9 +27,12 @@
 #include "runtime/os.inline.hpp"
 #include "utilities/bytes.hpp"
 
+// Used to advance a pointer, unstructured.
+#undef NEXTPTR
+#define NEXTPTR(base, fromType, count, toType) (toType*)((fromType*)(base) + (count))
 
 // Compute the Perfect Hashing hash code for the supplied string.
-u4 ImageStrings::hash_code(const char* string, u4 seed) {
+s4 ImageStrings::hash_code(const char* string, s4 seed) {
   u1* bytes = (u1*)string;
 
   // Compute hash code.
@@ -41,8 +44,28 @@
   return seed & 0x7FFFFFFF;
 }
 
-// Test to see if string begins with start.  If so returns remaining portion
-// of string.  Otherwise, NULL.
+s4 ImageStrings::find(const char* name, s4* redirect, s4 length) {
+  if (!length) {
+    return NOT_FOUND;
+  }
+
+  s4 hash_code = ImageStrings::hash_code(name);
+  s4 index = hash_code % length;
+  s4 value = redirect[index];
+
+  if (value > 0 ) {
+    // Collision value, need to rehash.
+    hash_code = ImageStrings::hash_code(name, value);
+
+    return hash_code % length;
+  } else if (value < 0) {
+    // Direct access.
+    return -1 - value;
+  }
+
+  return NOT_FOUND;
+}
+
 const char* ImageStrings::starts_with(const char* string, const char* start) {
   char ch1, ch2;
 
@@ -74,6 +97,85 @@
   }
 }
 
+ImageModuleData::ImageModuleData(ImageFile* image_file)
+      : _image_file(image_file), _strings(image_file->get_strings()) {
+  char name[JVM_MAXPATHLEN];
+  module_data_name(name, image_file->name());
+  _image_file->get_resource(name, _data, _data_size, true);
+  guarantee(_data, "missing module data");
+
+  _header = NEXTPTR(_data, u1, 0, Header);
+  int ptm_count = _header->_ptm_count;
+  int mtp_count = _header->_mtp_count;
+  _ptm_redirect = NEXTPTR(_header, Header, 1, s4);
+  _ptm_data = NEXTPTR(_ptm_redirect, s4, ptm_count, PTMData);
+  _mtp_redirect = NEXTPTR(_ptm_data, PTMData, ptm_count, s4);
+  _mtp_data = NEXTPTR(_mtp_redirect, s4, mtp_count, MTPData);
+  _mtp_packages = NEXTPTR(_mtp_data, MTPData, mtp_count, s4);
+}
+
+ImageModuleData::~ImageModuleData() {
+  if (_data) {
+    FREE_C_HEAP_ARRAY(u1, _data);
+  }
+}
+
+void ImageModuleData::module_data_name(char* buffer, const char* image_file_name) {
+  const char* slash = strrchr(image_file_name, os::file_separator()[0]);
+  const char* name = slash ? slash + 1 : (char *)image_file_name;
+  const char* dot = strrchr(name, '.');
+
+  if (dot) {
+    int length = dot - name;
+    strncpy(buffer, name, length);
+    buffer[length] = '\0';
+  } else {
+    strcpy(buffer, name);
+  }
+
+  strcat(buffer, ".jdata");
+}
+
+const char* ImageModuleData::package_to_module(const char* package_name) {
+  s4 index = ImageStrings::find(package_name, _ptm_redirect, _header->_ptm_count);
+
+  if (index != ImageStrings::NOT_FOUND) {
+    PTMData* data = _ptm_data + index;
+
+    if (strcmp(package_name, get_string(data->_name_offset)) != 0) {
+      return NULL;
+    }
+
+    return get_string(data->_module_name_offset);
+  }
+
+  return NULL;
+}
+
+GrowableArray<const char*>* ImageModuleData::module_to_packages(const char* module_name) {
+  s4 index = ImageStrings::find(module_name, _mtp_redirect, _header->_mtp_count);
+
+  if (index != ImageStrings::NOT_FOUND) {
+    MTPData* data = _mtp_data + index;
+
+    if (strcmp(module_name, get_string(data->_name_offset)) != 0) {
+      return NULL;
+    }
+
+    GrowableArray<const char*>* packages = new GrowableArray<const char*>();
+    for (int i = 0; i < data->_package_count; i++) {
+      u4 package_name_offset = _mtp_packages[data->_package_offset + i];
+      const char* package_name = get_string(package_name_offset);
+      packages->append(package_name);
+    }
+
+    return packages;
+  }
+
+  return NULL;
+}
+
+
 ImageFile::ImageFile(const char* name) {
   // Copy the image file name.
   _name = NEW_C_HEAP_ARRAY(char, strlen(name)+1, mtClass);
@@ -83,6 +185,7 @@
   _fd = -1;
   _memory_mapped = true;
   _index_data = NULL;
+  _module_data = NULL;
 }
 
 ImageFile::~ImageFile() {
@@ -119,7 +222,7 @@
   // Failing that, read index into C memory.
   if (_index_data == NULL) {
     _memory_mapped = false;
-    _index_data = NEW_RESOURCE_ARRAY(u1, _index_size);
+    _index_data = NEW_C_HEAP_ARRAY(u1, _index_size, mtClass);
 
     if (os::seek_to_file_offset(_fd, 0) == -1) {
       close();
@@ -134,27 +237,32 @@
     return true;
   }
 
-// Used to advance a pointer, unstructured.
-#undef nextPtr
-#define nextPtr(base, fromType, count, toType) (toType*)((fromType*)(base) + (count))
   // Pull tables out from the index.
-  _redirect_table = nextPtr(_index_data, u1, header_size, s4);
-  _offsets_table = nextPtr(_redirect_table, s4, _header._location_count, u4);
-  _location_bytes = nextPtr(_offsets_table, u4, _header._location_count, u1);
-  _string_bytes = nextPtr(_location_bytes, u1, _header._locations_size, u1);
-#undef nextPtr
+  _redirect_table = NEXTPTR(_index_data, u1, header_size, s4);
+  _offsets_table = NEXTPTR(_redirect_table, s4, _header._location_count, u4);
+  _location_bytes = NEXTPTR(_offsets_table, u4, _header._location_count, u1);
+  _string_bytes = NEXTPTR(_location_bytes, u1, _header._locations_size, u1);
+
+  // Load module meta data.
+  _module_data = new ImageModuleData(this);
 
   // Successful open.
   return true;
 }
 
 void ImageFile::close() {
+  // Deallocate module meta data.
+  if (_module_data) {
+    delete _module_data;
+    _module_data = NULL;
+  }
+
   // Dealllocate the index.
   if (_index_data) {
     if (_memory_mapped) {
       os::unmap_memory((char*)_index_data, _index_size);
     } else {
-      FREE_RESOURCE_ARRAY(u1, _index_data, _index_size);
+      FREE_C_HEAP_ARRAY(u1, _index_data);
     }
 
     _index_data = NULL;
@@ -170,27 +278,15 @@
 
 // Return the attribute stream for a named resourced.
 u1* ImageFile::find_location_data(const char* path) const {
-  // Compute hash.
-  u4 hash = ImageStrings::hash_code(path) % _header._location_count;
-  s4 redirect = _redirect_table[hash];
+  s4 index = ImageStrings::find(path, _redirect_table, _header._location_count);
 
-  if (!redirect) {
+  if (index == ImageStrings::NOT_FOUND) {
     return NULL;
   }
 
-  u4 index;
-
-  if (redirect < 0) {
-    // If no collision.
-    index = -redirect - 1;
-  } else {
-    // If collision, recompute hash code.
-    index = ImageStrings::hash_code(path, redirect) % _header._location_count;
-  }
-
-  assert(index < _header._location_count, "index exceeds location count");
+  guarantee((u4)index < _header._location_count, "index exceeds location count");
   u4 offset = _offsets_table[index];
-  assert(offset < _header._locations_size, "offset exceeds location attributes size");
+  guarantee((u4)offset < _header._locations_size, "offset exceeds location attributes size");
 
   if (offset == 0) {
     return NULL;
@@ -199,31 +295,78 @@
   return _location_bytes + offset;
 }
 
+void ImageFile::location_path(ImageLocation& location, char* path, size_t max) const {
+  ImageStrings strings(_string_bytes, _header._strings_size);
+  char* next = path;
+  size_t length;
+
+  const char* module = location.get_attribute(ImageLocation::ATTRIBUTE_MODULE, strings);
+  if (*module != '\0') {
+    length = strlen(module);
+    guarantee(next - path + length + 2 < max, "buffer overflow");
+    *next++ = '/';
+    strcpy(next, module); next += length;
+    *next++ = '/';
+  }
+
+  const char* parent = location.get_attribute(ImageLocation::ATTRIBUTE_PARENT, strings);
+  if (*parent != '\0') {
+    length = strlen(parent);
+    guarantee(next - path + length + 1 < max, "buffer overflow");
+    strcpy(next, parent); next += length;
+    *next++ = '/';
+  }
+
+  const char* base = location.get_attribute(ImageLocation::ATTRIBUTE_BASE, strings);
+  length = strlen(base);
+  guarantee(next - path + length < max, "buffer overflow");
+  strcpy(next, base); next += length;
+
+  const char* extension = location.get_attribute(ImageLocation::ATTRIBUTE_EXTENSION, strings);
+  if (*extension != '\0') {
+    length = strlen(extension);
+    guarantee(next - path + length + 1 < max, "buffer overflow");
+    *next++ = '.';
+    strcpy(next, extension); next += length;
+  }
+
+  guarantee((size_t)(next - path) < max, "buffer overflow");
+  *next = '\0';
+}
+
 // Verify that a found location matches the supplied path.
 bool ImageFile::verify_location(ImageLocation& location, const char* path) const {
-  // Retrieve each path component string.
   ImageStrings strings(_string_bytes, _header._strings_size);
-  // Match a path with each subcomponent without concatenation (copy).
-  // Match up path parent.
+  const char* next = path;
+
+  const char* module = location.get_attribute(ImageLocation::ATTRIBUTE_MODULE, strings);
+  if (*module != '\0') {
+    if (*next++ != '/') return false;
+    if (!(next = ImageStrings::starts_with(next, module))) return false;
+    if (*next++ != '/') return false;
+  }
+
   const char* parent = location.get_attribute(ImageLocation::ATTRIBUTE_PARENT, strings);
-  const char* next = ImageStrings::starts_with(path, parent);
-  // Continue only if a complete match.
-  if (!next) return false;
-  // Match up path base.
+  if (*parent != '\0') {
+    if (!(next = ImageStrings::starts_with(next, parent))) return false;
+    if (*next++ != '/') return false;
+  }
+
   const char* base = location.get_attribute(ImageLocation::ATTRIBUTE_BASE, strings);
-  next = ImageStrings::starts_with(next, base);
-  // Continue only if a complete match.
-  if (!next) return false;
-  // Match up path extension.
+  if (!(next = ImageStrings::starts_with(next, base))) return false;
+
   const char* extension = location.get_attribute(ImageLocation::ATTRIBUTE_EXTENSION, strings);
-  next = ImageStrings::starts_with(next, extension);
+  if (*extension != '\0') {
+    if (*next++ != '.') return false;
+    if (!(next = ImageStrings::starts_with(next, extension))) return false;
+  }
 
   // True only if complete match and no more characters.
-  return next && *next == '\0';
+  return *next == '\0';
 }
 
 // Return the resource for the supplied location.
-u1* ImageFile::get_resource(ImageLocation& location) const {
+u1* ImageFile::get_resource(ImageLocation& location, bool is_C_heap) const {
   // Retrieve the byte offset and size of the resource.
   u8 offset = _index_size + location.get_attribute(ImageLocation::ATTRIBUTE_OFFSET);
   u8 size = location.get_attribute(ImageLocation::ATTRIBUTE_UNCOMPRESSED);
@@ -231,7 +374,8 @@
   u8 read_size = compressed_size ? compressed_size : size;
 
   // Allocate space for the resource.
-  u1* data = NEW_RESOURCE_ARRAY(u1, read_size);
+  u1* data = is_C_heap && !compressed_size ? NEW_C_HEAP_ARRAY(u1, read_size, mtClass)
+                                           : NEW_RESOURCE_ARRAY(u1, read_size);
 
   bool is_read = os::read_at(_fd, data, read_size, offset) == read_size;
   guarantee(is_read, "error reading from image or short read");
@@ -241,7 +385,8 @@
     return data;
   }
 
-  u1* uncompressed = NEW_RESOURCE_ARRAY(u1, size);
+  u1* uncompressed = is_C_heap ? NEW_C_HEAP_ARRAY(u1, size, mtClass)
+                               : NEW_RESOURCE_ARRAY(u1, size);
   char* msg = NULL;
   jboolean res = ClassLoader::decompress(data, compressed_size, uncompressed, size, &msg);
   if (!res) warning("decompression failed due to %s\n", msg);
@@ -250,7 +395,7 @@
   return uncompressed;
 }
 
-void ImageFile::get_resource(const char* path, u1*& buffer, u8& size) const {
+void ImageFile::get_resource(const char* path, u1*& buffer, u8& size, bool is_C_heap) const {
   buffer = NULL;
   size = 0;
   u1* data = find_location_data(path);
@@ -258,29 +403,12 @@
     ImageLocation location(data);
     if (verify_location(location, path)) {
       size = location.get_attribute(ImageLocation::ATTRIBUTE_UNCOMPRESSED);
-      buffer = get_resource(location);
+      buffer = get_resource(location, is_C_heap);
     }
   }
 }
 
-GrowableArray<const char*>* ImageFile::packages(const char* name) {
-  char entry[JVM_MAXPATHLEN];
-  bool overflow = jio_snprintf(entry, sizeof(entry), "%s/packages.offsets", name) == -1;
-  guarantee(!overflow, "package name overflow");
-
-  u1* buffer;
-  u8 size;
-
-  get_resource(entry, buffer, size);
-  guarantee(buffer, "missing module packages reource");
-  ImageStrings strings(_string_bytes, _header._strings_size);
-  GrowableArray<const char*>* pkgs = new GrowableArray<const char*>();
-  int count = size / 4;
-  for (int i = 0; i < count; i++) {
-    u4 offset = Bytes::get_Java_u4(buffer + (i*4));
-    const char* p = strings.get(offset);
-    pkgs->append(p);
-  }
-
-  return pkgs;
+GrowableArray<const char*>* ImageFile::packages(const char* module_name) {
+  guarantee(_module_data, "image file not opened");
+  return _module_data->module_to_packages(module_name);
 }
--- a/src/share/vm/classfile/imageFile.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/imageFile.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -138,6 +138,9 @@
   u4 _size;
 
 public:
+  // Not found result from find routine.
+  static const s4 NOT_FOUND = -1;
+
   // Prime used to generate hash for Perfect Hashing.
   static const u4 HASH_MULTIPLIER = 0x01000193;
 
@@ -155,13 +158,23 @@
   }
 
   // Compute the Perfect Hashing hash code for the supplied string, starting at seed.
-  static u4 hash_code(const char* string, u4 seed);
+  static s4 hash_code(const char* string, s4 seed);
+
+  // Match up a string in the perfect hash table.  Still needs validation
+  // for exact match.
+  static s4 find(const char* name, s4* redirect, s4 length);
 
   // Test to see if string begins with start.  If so returns remaining portion
   // of string.  Otherwise, NULL.  Used to test sections of a path without
   // copying.
   static const char* starts_with(const char* string, const char* start);
 
+  // Test to see if string begins with start char.  If so returns remaining portion
+  // of string.  Otherwise, NULL.  Used to test sections of a path without
+  // copying.
+  inline static const char* starts_with(const char* string, const char ch) {
+    return *string == ch ? string + 1 : NULL;
+  }
 };
 
 // Manage image file location attribute streams.  Within an image, a location's
@@ -200,15 +213,17 @@
 //
 class ImageLocation {
 public:
-  // Attribute kind enumeration.
-  static const u1 ATTRIBUTE_END = 0; // End of attribute stream marker
-  static const u1 ATTRIBUTE_BASE = 1; // String table offset of resource path base
-  static const u1 ATTRIBUTE_PARENT = 2; // String table offset of resource path parent
-  static const u1 ATTRIBUTE_EXTENSION = 3; // String table offset of resource path extension
-  static const u1 ATTRIBUTE_OFFSET = 4; // Container byte offset of resource
-  static const u1 ATTRIBUTE_COMPRESSED = 5; // In image byte size of the compressed resource
-  static const u1 ATTRIBUTE_UNCOMPRESSED = 6; // In memory byte size of the uncompressed resource
-  static const u1 ATTRIBUTE_COUNT = 7; // Number of attribute kinds
+  enum {
+    ATTRIBUTE_END,          // End of attribute stream marker
+    ATTRIBUTE_MODULE,       // String table offset of module name
+    ATTRIBUTE_PARENT,       // String table offset of resource path parent
+    ATTRIBUTE_BASE,         // String table offset of resource path base
+    ATTRIBUTE_EXTENSION,    // String table offset of resource path extension
+    ATTRIBUTE_OFFSET,       // Container byte offset of resource
+    ATTRIBUTE_COMPRESSED,   // In image byte size of the compressed resource
+    ATTRIBUTE_UNCOMPRESSED, // In memory byte size of the uncompressed resource
+    ATTRIBUTE_COUNT         // Number of attribute kinds
+  };
 
 private:
   // Values of inflated attributes.
@@ -255,6 +270,85 @@
   }
 };
 
+//
+// NOTE: needs revision.
+// Each loader requires set of module meta data to identify which modules and
+// packages are managed by that loader.  Currently, there is one image file per
+// loader, so only one  module meta data resource per file.
+//
+// Each element in the module meta data is a native endian 4 byte integer.  Note
+// that entries with zero offsets for string table entries should be ignored (
+// padding for hash table lookup.)
+//
+// Format:
+//    Count of package to module entries
+//    Count of module to package entries
+//    Perfect Hash redirect table[Count of package to module entries]
+//    Package to module entries[Count of package to module entries]
+//        Offset to package name in string table
+//        Offset to module name in string table
+//    Perfect Hash redirect table[Count of module to package entries]
+//    Module to package entries[Count of module to package entries]
+//        Offset to module name in string table
+//        Count of packages in module
+//        Offset to first package in packages table
+//    Packages[]
+//        Offset to package name in string table
+//
+// Manage the image module meta data.
+class ImageModuleData : public CHeapObj<mtClass> {
+    struct Header {
+        s4 _ptm_count;          // Count of package to module entries
+        s4 _mtp_count;          // Count of module to package entries
+    };
+
+    // Hashtable entry
+    struct HashData {
+        s4 _name_offset;        // Name offset in string table
+    };
+
+    // Package to module hashtable entry
+    struct PTMData: public HashData {
+        s4 _module_name_offset; // Module name offset in string table
+    };
+
+    // Module to package hashtable entry
+
+    struct MTPData : public HashData {
+        s4 _package_count;      // Number of packages in module
+        s4 _package_offset;     // Offset in package list
+    };
+
+    ImageFile* _image_file;     // Source image file
+    ImageStrings _strings;      // Image file strings
+    u1* _data;                  // Module data resource data
+    u8 _data_size;              // Size of resource data
+    Header* _header;            // Module data header
+    s4* _ptm_redirect;          // Package to module hashtable redirect
+    PTMData* _ptm_data;         // Package to module data
+    s4* _mtp_redirect;          // Module to packages hashtable redirect
+    MTPData* _mtp_data;         // Module to packages data
+    s4* _mtp_packages;          // Package data (name offsets)
+
+    // Return a string from the string table.
+    inline const char* get_string(u4 offset) {
+      return _strings.get(offset);
+    }
+
+public:
+    ImageModuleData(ImageFile* image_file);
+    ~ImageModuleData();
+
+    // Return the name of tthe module data resource.
+    static void module_data_name(char* buffer, const char* image_file_name);
+
+    // Return the module name a package resides.  Returns NULL if not found.
+    const char* package_to_module(const char* package_name);
+
+    // Returns all the package names in a module.  Returns NULL if not found.
+    GrowableArray<const char*>* module_to_packages(const char* module_name);
+};
+
 // Manage the image file.
 class ImageFile: public CHeapObj<mtClass> {
 private:
@@ -285,6 +379,8 @@
   u1* _location_bytes;  // Location attributes
   u1* _string_bytes;    // String table
 
+  ImageModuleData* _module_data; // Module meta data
+
   // Compute number of bytes in image file index.
   inline u8 index_size() {
     return sizeof(ImageHeader) +
@@ -327,14 +423,22 @@
   // Return the attribute stream for a named resourced.
   u1* find_location_data(const char* path) const;
 
+  // Assemble the location path.
+  void location_path(ImageLocation& location, char* path, size_t max) const;
+
   // Verify that a found location matches the supplied path.
   bool verify_location(ImageLocation& location, const char* path) const;
 
   // Return the resource for the supplied location info.
-  u1* get_resource(ImageLocation& location) const;
+  u1* get_resource(ImageLocation& location, bool is_C_heap = false) const;
 
   // Return the resource associated with the path else NULL if not found.
-  void get_resource(const char* path, u1*& buffer, u8& size) const;
+  void get_resource(const char* path, u1*& buffer, u8& size, bool is_C_heap = false) const;
+
+  // Return the module name a package resides.  Returns NULL if not found.
+  inline const char* module(const char* package_name) {
+    return _module_data->package_to_module(package_name);
+  }
 
   // Return an array of packages for a given module
   GrowableArray<const char*>* packages(const char* name);
--- a/src/share/vm/classfile/javaClasses.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/javaClasses.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "classfile/altHashing.hpp"
 #include "classfile/javaClasses.inline.hpp"
+#include "classfile/moduleEntry.hpp"
 #include "classfile/stringTable.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "code/debugInfo.hpp"
@@ -565,7 +566,7 @@
       }
     }
   }
-  create_mirror(k, Handle(NULL), Handle(NULL), CHECK);
+  create_mirror(k, Handle(NULL), Handle(NULL), Handle(NULL), CHECK);
 }
 
 void java_lang_Class::initialize_mirror_fields(KlassHandle k,
@@ -586,7 +587,7 @@
 }
 
 void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader,
-                                    Handle protection_domain, TRAPS) {
+                                    Handle module, Handle protection_domain, TRAPS) {
   assert(k->java_mirror() == NULL, "should only assign mirror once");
   // Use this moment of initialization to cache modifier_flags also,
   // to support Class.getModifiers().  Instance classes recalculate
@@ -646,6 +647,10 @@
     assert(class_loader() == k->class_loader(), "should be same");
     set_class_loader(mirror(), class_loader());
 
+    // set the module field in the java_lang_Class instance
+    // This may be null during bootstrap but will get fixed up later on.
+    set_module(mirror(), module());
+
     // Setup indirection from klass->mirror last
     // after any exceptions can happen during allocations.
     if (!k.is_null()) {
@@ -659,8 +664,26 @@
     }
     fixup_mirror_list()->push(k());
   }
-}
-
+  // Keep list of classes needing java.base module fixup.
+  if (!ModuleEntryTable::javabase_created()) {
+    if (fixup_jlrM_list() == NULL) {
+      GrowableArray<Klass*>* list =
+        new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(40, true);
+      set_fixup_jlrM_list(list);
+    }
+    if (k->oop_is_instance()) {
+      fixup_jlrM_list()->push(k());
+    } else if (k->oop_is_objArray()) {
+      ObjArrayKlass* obj_arr_klass = ObjArrayKlass::cast(k());
+      fixup_jlrM_list()->push(obj_arr_klass->bottom_klass());
+    }
+  }
+}
+
+void java_lang_Class::fixup_jlrM(KlassHandle k, Handle module, TRAPS) {
+  assert(_module_offset != 0, "must have been computed already");
+  java_lang_Class::set_module(k->java_mirror(), module());
+}
 
 int  java_lang_Class::oop_size(oop java_class) {
   assert(_oop_size_offset != 0, "must be set");
@@ -728,6 +751,16 @@
   return java_class->obj_field(_class_loader_offset);
 }
 
+oop java_lang_Class::module(oop java_class) {
+  assert(_module_offset != 0, "must be set");
+  return java_class->obj_field(_module_offset);
+}
+
+void java_lang_Class::set_module(oop java_class, oop md) {
+  assert(_module_offset != 0, "must be set");
+  java_class->obj_field_put(_module_offset, md);
+}
+
 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
   // This should be improved by adding a field at the Java level or by
   // introducing a new VM klass (see comment in ClassFileParser)
@@ -897,6 +930,10 @@
                  k, vmSymbols::componentType_name(),
                  vmSymbols::class_signature());
 
+  compute_offset(_module_offset,
+                 k, vmSymbols::module_name(),
+                 vmSymbols::module_signature());
+
   // Init lock is a C union with component_mirror.  Only instanceKlass mirrors have
   // init_lock and only ArrayKlass mirrors have component_mirror.  Since both are oops
   // GC treats them the same.
@@ -2445,6 +2482,54 @@
 }
 
 
+int java_lang_reflect_Module::loader_offset;
+int java_lang_reflect_Module::name_offset;
+
+Handle java_lang_reflect_Module::create(Handle loader, Handle module_name, TRAPS) {
+  assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
+
+  Symbol* name = vmSymbols::java_lang_reflect_Module();
+  Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
+  instanceKlassHandle klass (THREAD, k);
+
+  Handle jlrmh = klass->allocate_instance_handle(CHECK_NH);
+  JavaValue result(T_VOID);
+  JavaCalls::call_special(&result, jlrmh, KlassHandle(THREAD, klass()),
+                          vmSymbols::object_initializer_name(),
+                          vmSymbols::java_lang_reflect_module_init_signature(),
+                          loader, module_name, CHECK_NH);
+  return jlrmh;
+}
+
+void java_lang_reflect_Module::compute_offsets() {
+  Klass* k = SystemDictionary::reflect_Module_klass();
+  if(NULL != k) {
+    compute_offset(loader_offset,  k, vmSymbols::loader_name(),  vmSymbols::classloader_signature());
+    compute_offset(name_offset,    k, vmSymbols::name_name(),    vmSymbols::string_signature());
+  }
+}
+
+
+oop java_lang_reflect_Module::loader(oop module) {
+  assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
+  return module->obj_field(loader_offset);
+}
+
+void java_lang_reflect_Module::set_loader(oop module, oop value) {
+  assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
+  module->obj_field_put(loader_offset, value);
+}
+
+oop java_lang_reflect_Module::name(oop module) {
+  assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
+  return module->obj_field(name_offset);
+}
+
+void java_lang_reflect_Module::set_name(oop module, oop value) {
+  assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
+  module->obj_field_put(name_offset, value);
+}
+
 Handle sun_reflect_ConstantPool::create(TRAPS) {
   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
   Klass* k = SystemDictionary::reflect_ConstantPool_klass();
@@ -3162,11 +3247,13 @@
 int java_lang_Class::_oop_size_offset;
 int java_lang_Class::_static_oop_field_count_offset;
 int java_lang_Class::_class_loader_offset;
+int java_lang_Class::_module_offset;
 int java_lang_Class::_protection_domain_offset;
 int java_lang_Class::_component_mirror_offset;
 int java_lang_Class::_init_lock_offset;
 int java_lang_Class::_signers_offset;
 GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL;
+GrowableArray<Klass*>* java_lang_Class::_fixup_jlrM_list = NULL;
 int java_lang_Throwable::backtrace_offset;
 int java_lang_Throwable::detailMessage_offset;
 int java_lang_Throwable::cause_offset;
@@ -3387,6 +3474,7 @@
   sun_reflect_ConstantPool::compute_offsets();
   sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets();
   java_lang_reflect_Parameter::compute_offsets();
+  java_lang_reflect_Module::compute_offsets();
 
   // generated interpreter code wants to know about the offsets we just computed:
   AbstractAssembler::update_delayed_values();
--- a/src/share/vm/classfile/javaClasses.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/javaClasses.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -239,26 +239,32 @@
   static int _init_lock_offset;
   static int _signers_offset;
   static int _class_loader_offset;
+  static int _module_offset;
   static int _component_mirror_offset;
 
   static bool offsets_computed;
   static int classRedefinedCount_offset;
 
   static GrowableArray<Klass*>* _fixup_mirror_list;
+  static GrowableArray<Klass*>* _fixup_jlrM_list;
 
   static void set_init_lock(oop java_class, oop init_lock);
   static void set_protection_domain(oop java_class, oop protection_domain);
   static void set_class_loader(oop java_class, oop class_loader);
+  static void set_module(oop java_class, oop module);
   static void set_component_mirror(oop java_class, oop comp_mirror);
   static void initialize_mirror_fields(KlassHandle k, Handle mirror, Handle protection_domain, TRAPS);
  public:
   static void compute_offsets();
 
   // Instance creation
-  static void create_mirror(KlassHandle k, Handle class_loader,
+  static void create_mirror(KlassHandle k, Handle class_loader, Handle module,
                             Handle protection_domain, TRAPS);
   static void fixup_mirror(KlassHandle k, TRAPS);
   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
+
+  static void fixup_jlrM(KlassHandle k, Handle module, TRAPS);
+
   // Conversion
   static Klass* as_Klass(oop java_class);
   static void set_klass(oop java_class, Klass* klass);
@@ -295,18 +301,28 @@
   static void set_signers(oop java_class, objArrayOop signers);
 
   static oop class_loader(oop java_class);
+  static oop module(oop java_class);
 
   static int oop_size(oop java_class);
   static void set_oop_size(oop java_class, int size);
   static int static_oop_field_count(oop java_class);
   static void set_static_oop_field_count(oop java_class, int size);
 
+
   static GrowableArray<Klass*>* fixup_mirror_list() {
     return _fixup_mirror_list;
   }
   static void set_fixup_mirror_list(GrowableArray<Klass*>* v) {
     _fixup_mirror_list = v;
   }
+
+  static GrowableArray<Klass*>* fixup_jlrM_list() {
+    return _fixup_jlrM_list;
+  }
+  static void set_fixup_jlrM_list(GrowableArray<Klass*>* v) {
+    _fixup_jlrM_list = v;
+  }
+
   // Debugging
   friend class JavaClasses;
   friend class InstanceKlass;   // verification code accesses offsets
@@ -785,6 +801,26 @@
   friend class JavaClasses;
 };
 
+class java_lang_reflect_Module {
+  private:
+    static int loader_offset;
+    static int name_offset;
+    static void compute_offsets();
+
+  public:
+    // Allocation
+    static Handle create(Handle loader, Handle module_name, TRAPS);
+
+    // Accessors
+    static oop loader(oop module);
+    static void set_loader(oop module, oop value);
+
+    static oop name(oop module);
+    static void set_name(oop module, oop value);
+
+  friend class JavaClasses;
+};
+
 // Interface to sun.reflect.ConstantPool objects
 class sun_reflect_ConstantPool {
  private:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/classfile/moduleEntry.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -0,0 +1,334 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "classfile/classLoaderData.hpp"
+#include "classfile/javaClasses.hpp"
+#include "classfile/moduleEntry.hpp"
+#include "memory/resourceArea.hpp"
+#include "oops/oop.inline.hpp"
+#include "oops/symbol.hpp"
+#include "prims/jni.h"
+#include "runtime/handles.inline.hpp"
+#include "runtime/safepoint.hpp"
+#include "trace/traceMacros.hpp"
+#include "utilities/events.hpp"
+#include "utilities/growableArray.hpp"
+#include "utilities/hashtable.inline.hpp"
+
+bool ModuleEntryTable::_javabase_created = false;
+
+// Returns true if this module can read module m
+bool ModuleEntry::can_read(ModuleEntry* m) const {
+  assert(m != NULL, "No module to lookup in this module's reads list");
+  MutexLocker m1(Module_lock);
+  if (_reads == NULL) {
+    return false;
+  } else {
+    return _reads->contains(m);
+  }
+}
+
+// Add a new module to this module's reads list
+void ModuleEntry::add_read(ModuleEntry* m) {
+  assert(m != NULL, "No module to add to this module's reads list");
+  MutexLocker m1(Module_lock);
+  if (_reads == NULL) {
+    // Lazily create a module's reads list
+    // Initial size is 101.
+    _reads = new (ResourceObj::C_HEAP, mtClass) GrowableArray<ModuleEntry*>(101, true);
+  }
+  _reads->append_if_missing(m);
+}
+
+bool ModuleEntry::has_reads() const {
+  return _reads != NULL && !_reads->is_empty();
+}
+
+// Purge dead module entries out of reads list.
+void ModuleEntry::purge_reads() {
+  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
+  if (_reads != NULL) {
+    // Go backwards because this removes entries that are dead.
+    int len = _reads->length();
+    for (int idx = len - 1; idx >= 0; idx--) {
+      ModuleEntry* module_idx = _reads->at(idx);
+      ClassLoaderData* cld = module_idx->loader();
+      if (cld->is_unloading()) {
+        _reads->delete_at(idx);
+      }
+    }
+  }
+}
+
+void ModuleEntry::delete_reads() {
+  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
+  delete _reads;
+  _reads = NULL;
+}
+
+ModuleEntryTable::ModuleEntryTable(int table_size)
+  : Hashtable<oop, mtClass>(table_size, sizeof(ModuleEntry))
+{
+}
+
+ModuleEntryTable::~ModuleEntryTable() {
+  assert_locked_or_safepoint(Module_lock);
+
+  // Walk through all buckets and all entries in each bucket,
+  // freeing each entry.
+  for (int i = 0; i < table_size(); ++i) {
+    for (ModuleEntry* m = bucket(i); m != NULL;) {
+      ModuleEntry* to_remove = m;
+      // read next before freeing.
+      m = m->next();
+
+      if (TraceModules) {
+        ResourceMark rm;
+        tty->print("[deleting module: %s, ", to_remove->name()->as_C_string());
+        to_remove->loader()->print_value();
+        tty->cr();
+      }
+
+      // Clean out the C heap allocated reads list first before freeing the entry
+      to_remove->delete_reads();
+      to_remove->name()->decrement_refcount();
+      to_remove->version()->decrement_refcount();
+      if (to_remove->location() != NULL) {
+        to_remove->location()->decrement_refcount();
+      }
+
+      // Unlink from the Hashtable prior to freeing
+      unlink_entry(to_remove);
+      FREE_C_HEAP_ARRAY(char, to_remove);
+    }
+  }
+  assert(number_of_entries() == 0, "should have removed all entries");
+  assert(new_entry_free_list() == NULL, "entry present on ModuleEntryTable's free list");
+  free_buckets();
+}
+
+ModuleEntry* ModuleEntryTable::new_entry(unsigned int hash, oop module, Symbol* name,
+                                         Symbol* version, Symbol* location,
+                                         ClassLoaderData* class_loader) {
+  assert_locked_or_safepoint(Module_lock);
+
+  ModuleEntry* entry = (ModuleEntry*) NEW_C_HEAP_ARRAY2(char, entry_size(), mtClass, CURRENT_PC);
+
+  // Initialize everything BasicHashtable would
+  entry->set_next(NULL);
+  entry->set_hash(hash);
+  entry->set_literal(module);
+
+  // Initialize fields specific to a ModuleEntry
+  entry->init();
+  entry->set_name(name);
+  name->increment_refcount();
+  entry->set_loader(class_loader);
+  entry->set_version(version);
+  version->increment_refcount();
+  vmassert(entry->location() == NULL, "Unexpected value");
+  if (location != NULL) {
+    entry->set_location(location);
+    location->increment_refcount();
+  }
+  TRACE_INIT_MODULE_ID(entry);
+
+  return entry;
+}
+
+void ModuleEntryTable::add_entry(int index, ModuleEntry* new_entry) {
+  assert_locked_or_safepoint(Module_lock);
+  Hashtable<oop, mtClass>::add_entry(index, (HashtableEntry<oop, mtClass>*)new_entry);
+}
+
+ModuleEntry* ModuleEntryTable::locked_create_entry_or_null(oop module, Symbol* module_name,
+                                                           Symbol *module_version,
+                                                           Symbol *module_location,
+                                                           ClassLoaderData* loader) {
+  assert_locked_or_safepoint(Module_lock);
+  // Check if module already exists.
+  if (lookup_only(module_name) != NULL) {
+    return NULL;
+  } else {
+    ModuleEntry* entry = new_entry(compute_hash(module), module, module_name,
+                                   module_version, module_location, loader);
+    add_entry(index_for(module), entry);
+    return entry;
+  }
+}
+
+// lookup_only by Symbol* to find a ModuleEntry. Before a java.lang.reflect.Module
+// exists only the module name is available.
+ModuleEntry* ModuleEntryTable::lookup_only(Symbol* name) {
+  for (int i = 0; i < table_size(); i++) {
+    for (ModuleEntry* m = bucket(i); m != NULL; m = m->next()) {
+      if (m->name()->fast_compare(name) == 0) {
+        return m;
+      }
+    }
+  }
+  return NULL;
+}
+
+ModuleEntry* ModuleEntryTable::lookup_only(oop module) {
+  int index = index_for(module);
+  for (ModuleEntry* m = bucket(index); m != NULL; m = m->next()) {
+    if (m->module() == module) {
+      return m;
+    }
+  }
+  return NULL;
+}
+
+// Once a j.l.r.Module has been created for java.base during
+// VM initialization, set its corresponding ModuleEntry correctly.
+void ModuleEntryTable::set_javabase_entry(oop m) {
+  Thread* THREAD = Thread::current();
+
+  ModuleEntry* jb_module = lookup_only(vmSymbols::java_base());
+  if (jb_module == NULL) {
+    vm_exit_during_initialization("No module entry for java.base located");
+  }
+
+  // Set the j.l.r.M for java.base's ModuleEntry as well as the static
+  // field within all ModuleEntryTables.
+  jb_module->set_module(m);
+  _javabase_created = true;
+}
+
+void ModuleEntryTable::patch_javabase_entries(TRAPS) {
+  ResourceMark rm;
+
+  // Create the java.lang.reflect.Module object for module 'java.base'.
+  Handle java_base = java_lang_String::create_from_str(vmSymbols::java_base()->as_C_string(), CHECK);
+  Handle jlrM_handle = java_lang_reflect_Module::create(
+                         Handle(ClassLoaderData::the_null_class_loader_data()->class_loader()), java_base, CHECK);
+  if (jlrM_handle.is_null()) {
+    fatal("Cannot create java.lang.reflect.Module object for java.base");
+  }
+
+  if (TraceModules) {
+    tty->print_cr("[MET::patch_javabase_entries, j.l.r.Module for java.base created]");
+  }
+
+  // Set jlrM_handle for java.base module in module entry table.
+  ClassLoaderData::the_null_class_loader_data()->modules()->set_javabase_entry(jlrM_handle());
+
+  // Do the fixups for classes that have already been created.
+  GrowableArray <Klass*>* list = java_lang_Class::fixup_jlrM_list();
+  int list_length = list->length();
+  for (int i = 0; i < list_length; i++) {
+    Klass* k = list->at(i);
+    assert(k->is_klass(), "List should only hold classes");
+    EXCEPTION_MARK;
+    KlassHandle kh(THREAD, k);
+    java_lang_Class::fixup_jlrM(kh, jlrM_handle, CATCH);
+    if (TraceModules) {
+      tty->print_cr("[MET::patch_javabase_entries, patching class %s]", k->external_name());
+    }
+  }
+  delete java_lang_Class::fixup_jlrM_list();
+  java_lang_Class::set_fixup_jlrM_list(NULL);
+
+  if (TraceModules) {
+    tty->print_cr("[MET::patch_javabase_entries, patching complete, fixup array deleted]");
+  }
+}
+
+void ModuleEntryTable::oops_do(OopClosure* f) {
+  for (int i = 0; i < table_size(); i++) {
+    for (ModuleEntry* probe = bucket(i);
+                              probe != NULL;
+                              probe = probe->next()) {
+      probe->oops_do(f);
+    }
+  }
+}
+
+// Remove dead modules from all other alive modules' reads list.
+// This should only occur at class unloading.
+void ModuleEntryTable::purge_all_module_reads() {
+  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
+  for (int i = 0; i < table_size(); i++) {
+    for (ModuleEntry* entry = bucket(i);
+                      entry != NULL;
+                      entry = entry->next()) {
+      entry->purge_reads();
+    }
+  }
+}
+
+#ifndef PRODUCT
+void ModuleEntryTable::print() {
+  tty->print_cr("Module Entry Table (table_size=%d, entries=%d)",
+                table_size(), number_of_entries());
+  for (int i = 0; i < table_size(); i++) {
+    for (ModuleEntry* probe = bucket(i);
+                              probe != NULL;
+                              probe = probe->next()) {
+      probe->print();
+    }
+  }
+}
+
+void ModuleEntry::print() {
+  ResourceMark rm;
+  tty->print_cr("entry "PTR_FORMAT" oop "PTR_FORMAT" name %s loader %s version %s location %s pkgs_with_qexports %d next "PTR_FORMAT,
+                p2i(this), p2i(literal()), name()->as_C_string(), loader()->loader_name(),
+                version()->as_C_string(), location() != NULL ? location()->as_C_string() : "NULL",
+                _pkgs_with_qexports, p2i(next()));
+}
+#endif
+
+void ModuleEntryTable::verify() {
+  int element_count = 0;
+  for (int i = 0; i < table_size(); i++) {
+    for (ModuleEntry* probe = bucket(i);
+                              probe != NULL;
+                              probe = probe->next()) {
+      probe->verify();
+      element_count++;
+    }
+  }
+  guarantee(number_of_entries() == element_count,
+            "Verify of Module Entry Table failed");
+  debug_only(verify_lookup_length((double)number_of_entries() / table_size()));
+}
+
+void ModuleEntry::verify() {
+  guarantee(literal()->is_oop(), "must be an oop");
+}
+
+void ModuleEntry::module_reads_do(ModuleClosure* const f) {
+  assert_locked_or_safepoint(Module_lock);
+  assert(f != NULL, "invariant");
+
+  if (_reads != NULL) {
+    int reads_len = _reads->length();
+    for (int i = 0; i < reads_len; ++i) {
+      f->do_module(_reads->at(i));
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/classfile/moduleEntry.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_CLASSFILE_MODULEENTRY_HPP
+#define SHARE_VM_CLASSFILE_MODULEENTRY_HPP
+
+#include "classfile/classLoaderData.hpp"
+#include "classfile/vmSymbols.hpp"
+#include "oops/symbol.hpp"
+#include "prims/jni.h"
+#include "runtime/mutexLocker.hpp"
+#include "trace/traceMacros.hpp"
+#include "utilities/growableArray.hpp"
+#include "utilities/hashtable.hpp"
+
+class ModuleClosure;
+
+// A ModuleEntry describes a module that has been defined by a call to JVM_DefineModule.
+// It contains:
+//   - a pointer to the java.lang.reflect.Module object for this module.
+//   - Symbol* containing the module's name.
+//   - ClassLoaderData*, class loader of this module.
+//   - a growable array containg other module entries that this module can read.
+//   - a flag indicating if any of the packages defined within this module have qualified
+//     exports.
+//
+class ModuleEntry : public HashtableEntry<oop, mtClass> {
+private:
+  Symbol* _name;
+  ClassLoaderData* _loader;
+  GrowableArray<ModuleEntry*>* _reads; // list of modules that are readable by this module
+  Symbol* _version;   // module version number
+  Symbol* _location;  // module location
+  bool _pkgs_with_qexports; // this module contains 1 or more packages with qualified exports
+  TRACE_DEFINE_TRACE_ID_FIELD;
+
+public:
+  void init() {
+    _name = NULL;
+    _loader = NULL;
+    _reads = NULL;
+    _version = NULL;
+    _location = NULL;
+    _pkgs_with_qexports = false;
+  }
+
+  oop                module() const                 { return literal(); }
+  void               set_module(oop m)              { set_literal(m); }
+
+  Symbol*            name() const                   { return _name; }
+  void               set_name(Symbol* n)            { _name = n; }
+
+  ClassLoaderData*   loader() const                 { return _loader; }
+  void               set_loader(ClassLoaderData* l) { _loader = l; }
+
+  Symbol*            version() const                { return _version; }
+  void               set_version(Symbol* version)   { _version = version; }
+
+  Symbol*            location() const               { return _location; }
+  void               set_location(Symbol* location) { _location = location; }
+
+  bool               can_read(ModuleEntry* m) const;
+  bool               has_reads() const;
+  void               add_read(ModuleEntry* m);
+
+  bool               pkgs_with_qexports()           { return _pkgs_with_qexports; }
+  void               set_pkgs_with_qexports(bool q) { _pkgs_with_qexports = q; }
+
+  ModuleEntry* next() const {
+    return (ModuleEntry*)HashtableEntry<oop, mtClass>::next();
+  }
+  ModuleEntry** next_addr() {
+    return (ModuleEntry**)HashtableEntry<oop, mtClass>::next_addr();
+  }
+
+  // GC support
+  void oops_do(OopClosure* f) {
+    f->do_oop(literal_addr());
+  }
+
+  // iteration support for readability
+  void module_reads_do(ModuleClosure* const f);
+
+  TRACE_DEFINE_TRACE_ID_METHODS;
+
+  // Purge dead weak references out of reads list when any given class loader is unloaded.
+  void purge_reads();
+  void delete_reads();
+
+  void print() PRODUCT_RETURN;
+  void verify();
+};
+
+// Iterator interface
+class ModuleClosure: public StackObj {
+ public:
+  virtual void do_module(ModuleEntry* const module) = 0;
+};
+
+
+// The ModuleEntryTable is a Hashtable containing a list of all modules defined
+// by a particular class loader.  Each module is represented as a ModuleEntry node.
+//
+// Each ModuleEntryTable contains a _javabase_created field indicating if java.base's
+// corresponding j.l.r.Module has been created.  Having this field provided a way to create a
+// ModuleEntry node for java.base very early in bootstrapping in order to obtain
+// java.base's containing packages.  This occurs prior to creation of the j.l.r.Module
+// for java.base during VM initialization.  java.base is the only module that does
+// not have a corresponding JVM_DefineModule() invocation.  It is the JVM's
+// responsibility to create.  Note, within the null boot class loader's ModulEntry table,
+// the ModuleEntry for java.base is hashed at bucket 0.
+//
+// The ModuleEntryTable's lookup is lock free.  Note, that the fastest lookup is to
+// invoke lookup_only with a j.l.r.M.  A lookup_only capability based on a module's
+// name is also provided.
+//
+class ModuleEntryTable : public Hashtable<oop, mtClass> {
+  friend class VMStructs;
+public:
+  enum Constants {
+    _moduletable_entry_size  = 1009  // number of entries in module entry table
+  };
+
+private:
+  static bool _javabase_created;
+
+  ModuleEntry* new_entry(unsigned int hash, oop module, Symbol* name, Symbol* version,
+                         Symbol* location, ClassLoaderData* class_loader);
+  void set_javabase_entry(oop m);
+  void add_entry(int index, ModuleEntry* new_entry);
+
+public:
+  ModuleEntryTable(int table_size);
+  ~ModuleEntryTable();
+
+  int entry_size() const { return BasicHashtable<mtClass>::entry_size(); }
+
+  // Create module in loader's module entry table, if already exists then
+  // return null.  Assume Module_lock has been locked by caller.
+  ModuleEntry* locked_create_entry_or_null(oop module, Symbol* module_name,
+                                           Symbol* module_version,
+                                           Symbol* module_location,
+                                           ClassLoaderData* loader);
+
+  // only lookup module within loader's module entry table
+  ModuleEntry* lookup_only(Symbol* name);
+  ModuleEntry* lookup_only(oop module);
+
+  ModuleEntry* bucket(int i) {
+    return (ModuleEntry*)Hashtable<oop, mtClass>::bucket(i);
+  }
+
+  ModuleEntry** bucket_addr(int i) {
+    return (ModuleEntry**)Hashtable<oop, mtClass>::bucket_addr(i);
+  }
+
+  static bool javabase_created() { return _javabase_created; }
+  static void patch_javabase_entries(TRAPS);
+
+  unsigned int compute_hash(oop module) {
+    if (module == NULL) {
+      // java.base prior to creation of its j.l.r.M
+      return 0;
+    }
+
+    ModuleEntryTable* met = ClassLoaderData::the_null_class_loader_data()->modules();
+    assert(met != NULL, "The null class loader's moduleEntry table should be defined");
+    if (_javabase_created && (module == met->lookup_only(vmSymbols::java_base())->module())) {
+      // java.base after creation of its j.l.r.M
+      return 0;
+    } else {
+      return (unsigned int)(module->identity_hash());
+    }
+  }
+
+  int index_for(oop module) {
+    return hash_to_index(compute_hash(module));
+  }
+
+  // GC support
+  void oops_do(OopClosure* f);
+
+  // purge dead weak references out of reads list
+  void purge_all_module_reads();
+
+  void print() PRODUCT_RETURN;
+  void verify();
+};
+
+#endif // SHARE_VM_CLASSFILE_MODULEENTRY_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/classfile/modules.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -0,0 +1,697 @@
+/*
+* Copyright (c) 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
+* under the terms of the GNU General Public License version 2 only, as
+* published by the Free Software Foundation.
+*
+* This code is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+* version 2 for more details (a copy is included in the LICENSE file that
+* accompanied this code).
+*
+* You should have received a copy of the GNU General Public License version
+* 2 along with this work; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+*
+* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+* or visit www.oracle.com if you need additional information or have any
+* questions.
+*
+*/
+
+#include "precompiled.hpp"
+#include "classfile/classLoader.hpp"
+#include "classfile/classLoaderData.inline.hpp"
+#include "classfile/javaAssertions.hpp"
+#include "classfile/javaClasses.hpp"
+#include "classfile/moduleEntry.hpp"
+#include "classfile/modules.hpp"
+#include "classfile/packageEntry.hpp"
+#include "classfile/stringTable.hpp"
+#include "classfile/symbolTable.hpp"
+#include "classfile/vmSymbols.hpp"
+#include "oops/instanceKlass.hpp"
+#include "oops/objArrayKlass.hpp"
+#include "oops/objArrayOop.inline.hpp"
+#include "runtime/arguments.hpp"
+#include "runtime/handles.inline.hpp"
+#include "runtime/reflection.hpp"
+#include "utilities/utf8.hpp"
+
+
+static bool verify_module_name(char *module_name) {
+  if (module_name == NULL) return false;
+  int len = (int)strlen(module_name);
+  return (len > 0 && len <= Symbol::max_length() &&
+    UTF8::is_legal_utf8((unsigned char *)module_name, len, false) &&
+    ClassFileParser::verify_unqualified_name(module_name, len,
+    ClassFileParser::LegalModule));
+}
+
+bool Modules::verify_package_name(char *package_name) {
+  if (package_name == NULL) return false;
+  int len = (int)strlen(package_name);
+  return (len > 0 && len <= Symbol::max_length() &&
+    UTF8::is_legal_utf8((unsigned char *)package_name, len, false) &&
+    ClassFileParser::verify_unqualified_name(package_name, len,
+    ClassFileParser::LegalClass));
+}
+
+static ModuleEntryTable* get_module_entry_table(Handle h_loader, TRAPS) {
+  h_loader = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(h_loader()));
+  // This code can be called during start-up, before the classLoader's classLoader data got
+  // created.  So, call register_loader() to make sure the classLoader data gets created.
+  ClassLoaderData *loader_cld = SystemDictionary::register_loader(h_loader, CHECK_NULL);
+  return loader_cld->modules();
+}
+
+static PackageEntryTable* get_package_entry_table(Handle h_loader, TRAPS) {
+  h_loader = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(h_loader()));
+  // This code can be called during start-up, before the classLoader's classLoader data got
+  // created.  So, call register_loader() to make sure the classLoader data gets created.
+  ClassLoaderData *loader_cld = SystemDictionary::register_loader(h_loader, CHECK_NULL);
+  return loader_cld->packages();
+}
+
+static PackageEntry* get_package_entry_by_name(Symbol* package,
+                                               Handle h_loader,
+                                               TRAPS) {
+  if (package != NULL) {
+    ResourceMark rm;
+    if (Modules::verify_package_name(package->as_C_string())) {
+      PackageEntryTable* const package_entry_table =
+        get_package_entry_table(h_loader, THREAD);
+      assert(package_entry_table != NULL, "Unexpected null package entry table");
+      return package_entry_table->lookup_only(package);
+    }
+  }
+  return NULL;
+}
+
+static ModuleEntry* get_module_entry_by_package_name(Symbol* package,
+                                                     Handle h_loader,
+                                                     TRAPS) {
+  const PackageEntry* const pkg_entry =
+    get_package_entry_by_name(package, h_loader, THREAD);
+
+  return pkg_entry != NULL ? pkg_entry->module() : NULL;
+}
+
+// Check if -Xoverride:<path> was specified.  If so, prepend <path>/module_name,
+// if it exists, to bootpath so boot loader can find the class files.  Also, if
+// using exploded modules, prepend <java.home>/modules/module_name, if it exists,
+// to bootpath so that its class files can be found by the boot loader.
+static void add_to_boot_loader_list(char *module_name, TRAPS) {
+  // java.base should be handled by argument parsing.
+  assert(strcmp(module_name, "java.base") != 0, "Unexpected java.base module name");
+  char file_sep = os::file_separator()[0];
+  size_t module_len = strlen(module_name);
+
+  // If -Xoverride is set then add path <override-dir>/module_name.
+  char* prefix_path = NULL;
+  if (Arguments::override_dir() != NULL) {
+    size_t len = strlen(Arguments::override_dir()) + module_len + 2;
+    prefix_path = NEW_C_HEAP_ARRAY(char, len, mtInternal);
+    jio_snprintf(prefix_path, len, "%s%c%s", Arguments::override_dir(), file_sep, module_name);
+    struct stat st;
+    // See if Xoverride module path exists.
+    if ((os::stat(prefix_path, &st) != 0)) {
+      FREE_C_HEAP_ARRAY(char, prefix_path);
+      prefix_path = NULL;
+    }
+  }
+
+  // If bootmodules.jimage does not exist then assume exploded form
+  // ${java.home}/modules/<module-name>
+  char* path = NULL;
+  if (!ClassLoader::has_bootmodules_jimage()) {
+    const char* home = Arguments::get_java_home();
+    size_t len = strlen(home) + module_len + 32;
+    path = NEW_C_HEAP_ARRAY(char, len, mtInternal);
+    jio_snprintf(path, len, "%s%cmodules%c%s", home, file_sep, file_sep, module_name);
+    struct stat st;
+    // See if exploded module path exists.
+    if ((os::stat(path, &st) != 0)) {
+      FREE_C_HEAP_ARRAY(char, path);
+      path = NULL;
+    }
+  }
+
+  if (prefix_path != NULL || path != NULL) {
+    HandleMark hm;
+    Handle loader_lock = Handle(THREAD, SystemDictionary::system_loader_lock());
+    ObjectLocker ol(loader_lock, THREAD);
+
+    if (prefix_path != NULL) {
+      if (TraceClassLoading) tty->print_cr("[Opened -Xoverride %s]", prefix_path);
+      ClassLoader::add_to_list(prefix_path);
+    }
+    if (path != NULL) {
+      if (TraceClassLoading) tty->print_cr("[Opened %s]", path);
+      ClassLoader::add_to_list(path);
+    }
+  }
+}
+
+static ModuleEntry* get_module_entry(jobject module, TRAPS) {
+  Handle h_module(THREAD, JNIHandles::resolve(module));
+  oop loader = java_lang_reflect_Module::loader(h_module());
+  Handle h_loader = Handle(loader);
+  ModuleEntryTable* module_table = get_module_entry_table(h_loader, CHECK_NULL);
+  assert(module_table != NULL, "Unexpected null module entry table");
+  return module_table->lookup_only(h_module());
+}
+
+static PackageEntry* get_package_entry(ModuleEntry* module_entry, jstring package, TRAPS) {
+  ResourceMark rm;
+  if (package == NULL) return NULL;
+  const char *package_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(package));
+  if (package_name == NULL) return NULL;
+  TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, CHECK_NULL);
+  PackageEntryTable* package_entry_table = module_entry->loader()->packages();
+  assert(package_entry_table != NULL, "Unexpected null package entry table");
+  return package_entry_table->lookup_only(pkg_symbol);
+}
+
+
+static const char* get_module_version(jstring version) {
+  char* module_version;
+  if (version == NULL) {
+    module_version = (char *)Modules::default_version();
+  } else {
+    module_version = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(version));
+    if (module_version == NULL) module_version = (char *)Modules::default_version();
+  }
+  return module_version;
+}
+
+static char* get_module_name(oop module, TRAPS) {
+  oop name_oop = java_lang_reflect_Module::name(module);
+  if (name_oop == NULL) {
+    THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(), "Null module name");
+  }
+  char* module_name = java_lang_String::as_utf8_string(name_oop);
+  if (!verify_module_name(module_name)) {
+    THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(),
+                   err_msg("Invalid module name: %s",
+                           module_name != NULL ? module_name : "NULL"));
+  }
+  if (strcmp(module_name, vmSymbols::java_base()->as_C_string()) == 0) {
+    THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(),
+                   "Module java.base is already defined");
+  }
+  return module_name;
+}
+
+
+void Modules::define_module(JNIEnv *env, jobject module, jstring version,
+                            jstring location, jobjectArray packages) {
+  JavaThread *THREAD = JavaThread::thread_from_jni_environment(env);
+  ResourceMark rm(THREAD);
+
+  if (module == NULL) {
+    THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null module object");
+  }
+  Handle jlrM_handle(THREAD, JNIHandles::resolve(module));
+
+  char* module_name = get_module_name(jlrM_handle(), CHECK);
+  const char* module_version = get_module_version(version);
+
+  if (TraceModules) {
+    tty->print_cr("In define_module(): Start defining module %s, version: %s]",
+                  module_name, module_version);
+  }
+
+  objArrayOop packages_oop = objArrayOop(JNIHandles::resolve(packages));
+  objArrayHandle packages_h(THREAD, packages_oop);
+  int num_packages = (packages_h == NULL ? 0 : packages_h->length());
+
+  // Check that the list of packages has no duplicates and that the
+  // packages are syntactically ok.
+  GrowableArray<Symbol*>* pkg_list = new GrowableArray<Symbol*>(num_packages);
+  for (int x = 0; x < num_packages; x++) {
+    oop string_obj = packages_h->obj_at(x);
+
+    if (string_obj == NULL || !string_obj->is_a(SystemDictionary::String_klass())) {
+      THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+                err_msg("Bad package name for module: %s", module_name));
+    }
+    char *package_name = java_lang_String::as_utf8_string(string_obj);
+    if (!verify_package_name(package_name)) {
+      THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+                 err_msg("Invalid package name: %s for module: %s",
+                         package_name, module_name));
+    }
+    Symbol* pkg_symbol = SymbolTable::new_symbol(package_name, CHECK);
+    // append_if_missing() returns FALSE if entry already exists.
+    if (!pkg_list->append_if_missing(pkg_symbol)) {
+      THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+                err_msg("Duplicate package name: %s for module %s",
+                        package_name, module_name));
+    }
+  }
+
+  oop loader = java_lang_reflect_Module::loader(jlrM_handle());
+
+  // Make sure loader is not the delegating class loader.
+  assert(loader == java_lang_ClassLoader::non_reflection_class_loader(loader),
+    "Defining a module with delegating class loader");
+
+  Handle h_loader = Handle(loader);
+
+  // Check that loader is a subclass of java.lang.ClassLoader.
+  if (loader != NULL && !java_lang_ClassLoader::is_subclass(h_loader->klass())) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "Class loader is not a subclass of java.lang.ClassLoader");
+  }
+
+  ModuleEntryTable* module_table = get_module_entry_table(h_loader, CHECK);
+  assert(module_table != NULL, "module entry table shouldn't be null");
+
+  // Create symbol* entry for module name.
+  TempNewSymbol module_symbol = SymbolTable::new_symbol(module_name, CHECK);
+
+  int dupl_pkg_index = -1;
+  bool dupl_modules = false;
+  {
+    MutexLocker ml(Module_lock, THREAD);
+
+    PackageEntryTable* package_table = NULL;
+    if (num_packages > 0) {
+      package_table = get_package_entry_table(h_loader, CHECK);
+      assert(package_table != NULL, "Missing package_table");
+
+      // Check that none of the packages exist in the class loader's package table.
+      for (int x = 0; x < pkg_list->length(); x++) {
+        if (package_table->lookup_only(pkg_list->at(x))) {
+          // This could be because the module was already defined.  If so,
+          // report that error instead of the package error.
+          if (module_table->lookup_only(module_symbol) != NULL) {
+            dupl_modules = true;
+          } else {
+            dupl_pkg_index = x;
+          }
+          break;
+        }
+      }
+    }  // if (num_packages > 0)...
+
+    // Add the module and its packages.
+    if (!dupl_modules && dupl_pkg_index == -1) {
+      // Create the entry for this module in the class loader's module entry table.
+
+      // Create symbol* entry for module version.
+      TempNewSymbol version_symbol = SymbolTable::new_symbol(module_version, CHECK);
+
+      // Create symbol* entry for module location.
+      const char* module_location = NULL;
+      TempNewSymbol location_symbol = NULL;
+      if (location != NULL) {
+        module_location =
+          java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(location));
+        if (module_location != NULL) {
+          location_symbol = SymbolTable::new_symbol(module_location, CHECK);
+        }
+      }
+
+      ClassLoaderData* loader_data =
+        ClassLoaderData::class_loader_data_or_null(h_loader());
+      assert(loader_data != NULL, "class loader data shouldn't be null");
+      ModuleEntry* module_entry =
+        module_table->locked_create_entry_or_null(jlrM_handle(), module_symbol,
+          version_symbol, location_symbol, loader_data);
+
+      if (module_entry == NULL) {
+        dupl_modules = true;
+      } else {
+        if (TraceModules) {
+          tty->print("In define_module(): creation of module: %s, version: %s, location: %s, ",
+            module_name, module_version, module_location != NULL ? module_location : "NULL");
+          loader_data->print_value();
+          tty->print_cr(", package #: %d]", pkg_list->length());
+        }
+
+        // Add the packages.
+        assert(pkg_list->length() == 0 || package_table != NULL, "Bad package table");
+        PackageEntry* pkg;
+        for (int y = 0; y < pkg_list->length(); y++) {
+          pkg = package_table->locked_create_entry_or_null(pkg_list->at(y), module_entry);
+          assert(pkg != NULL, "Unable to create a module's package entry");
+
+          if (TraceModules || TracePackages) {
+            tty->print_cr("[In define_module(): creation of package %s for module %s]",
+                          (pkg_list->at(y))->as_C_string(), module_name);
+          }
+
+          // Unable to have a GrowableArray of TempNewSymbol.  Must decrement the refcount of
+          // the Symbol* that was created above for each package. The refcount was incremented
+          // by SymbolTable::new_symbol and as well by the PackageEntry creation.
+          pkg_list->at(y)->decrement_refcount();
+        }
+      }
+    }
+  }  // Release the lock
+
+  // any errors ?
+  if (dupl_modules) {
+     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+               err_msg("Module %s is already defined", module_name));
+  }
+  if (dupl_pkg_index != -1) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              err_msg("Package %s for module %s already exists for class loader",
+                       pkg_list->at(dupl_pkg_index)->as_C_string(), module_name));
+  }
+
+  if (loader == NULL && !Universe::is_module_initialized()) {
+    // Now that the module is defined, if it is in the bootloader, make sure that
+    // its classes can be found.  Check if -Xoverride:<path> was specified.  If
+    // so prepend <path>/module_name, if it exists, to bootpath.  Also, if using
+    // exploded modules, prepend <java.home>/modules/module_name, if it exists,
+    // to bootpath.
+    add_to_boot_loader_list(module_name, CHECK);
+  }
+}
+
+void Modules::add_module_exports(JNIEnv *env, jobject from_module, jstring package, jobject to_module) {
+  JavaThread *THREAD = JavaThread::thread_from_jni_environment(env);
+
+  if (package == NULL) {
+    THROW_MSG(vmSymbols::java_lang_NullPointerException(),
+              "package is null");
+  }
+  if (from_module == NULL) {
+    THROW_MSG(vmSymbols::java_lang_NullPointerException(),
+              "from_module is null");
+  }
+  ModuleEntry* from_module_entry = get_module_entry(from_module, CHECK);
+  if (from_module_entry == NULL) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "from_module cannot be found");
+  }
+  ModuleEntry* to_module_entry;
+  if (to_module == NULL) {
+    to_module_entry = NULL;  // It's the unnamed module.
+  }
+  else {
+    to_module_entry = get_module_entry(to_module, CHECK);
+    if (to_module_entry == NULL) {
+      THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+                "to_module is invalid");
+    }
+  }
+
+  PackageEntry *package_entry = get_package_entry(from_module_entry, package, CHECK);
+
+  if (package_entry == NULL) {
+    ResourceMark rm;
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              err_msg("Package %s not found in from_module %s",
+                      java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(package)),
+                      from_module_entry->name()->as_C_string()));
+  }
+  if (package_entry->module() != from_module_entry) {
+    ResourceMark rm;
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              err_msg("Package: %s found in module %s, not in from_module: %s",
+                      package_entry->name()->as_C_string(),
+                      package_entry->module()->name()->as_C_string(),
+                      from_module_entry->name()->as_C_string()));
+  }
+
+  if (TraceModules) {
+    ResourceMark rm;
+    tty->print_cr("[add_module_exports(): package:module %s:%s is exported to module %s]",
+                  package_entry->name()->as_C_string(),
+                  from_module_entry->name()->as_C_string(),
+                  ((to_module_entry == NULL) ? NULL : to_module_entry->name()->as_C_string()));
+  }
+
+  // If this is a qualified export, make sure the entry has not already been exported
+  // unqualifiedly.
+  if (to_module_entry != NULL && package_entry->is_unqual_exported()) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              err_msg("Bad qualifed export, package %s in module %s is already unqualifiedly exported",
+                      package_entry->name()->as_C_string(),
+                      from_module_entry->name()->as_C_string()));
+  }
+
+  // Do nothing if modules are the same.
+  if (from_module_entry != to_module_entry) {
+    package_entry->set_exported(to_module_entry);
+  }
+}
+
+void Modules::add_reads_module(JNIEnv *env, jobject from_module, jobject to_module) {
+  JavaThread *THREAD = JavaThread::thread_from_jni_environment(env);
+
+  if (from_module == NULL) {
+    THROW_MSG(vmSymbols::java_lang_NullPointerException(),
+              "from_module is null");
+  }
+  if (to_module == NULL) {
+    THROW_MSG(vmSymbols::java_lang_NullPointerException(),
+              "to_module is null");
+  }
+
+  ModuleEntry* from_module_entry = get_module_entry(from_module, CHECK);
+  if (from_module_entry == NULL) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "from_module is not valid");
+  }
+  ModuleEntry* to_module_entry = get_module_entry(to_module, CHECK);
+  if (to_module_entry == NULL) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "to_module is invalid");
+  }
+
+  if (TraceModules) {
+    ResourceMark rm;
+    tty->print_cr("[add_reads_module(): Adding read from module %s to module %s]",
+      from_module_entry->name()->as_C_string(),
+      to_module_entry->name()->as_C_string());
+  }
+
+  // if modules are the same, no need to add the read.
+  if (from_module_entry != to_module_entry) {
+    from_module_entry->add_read(to_module_entry);
+  }
+}
+
+jboolean Modules::can_read_module(JNIEnv *env, jobject asking_module, jobject target_module) {
+  JavaThread *THREAD = JavaThread::thread_from_jni_environment(env);
+
+  if (asking_module == NULL) {
+    THROW_MSG_(vmSymbols::java_lang_NullPointerException(),
+               "asking_module is null", JNI_FALSE);
+  }
+
+  ModuleEntry* asking_module_entry = get_module_entry(asking_module, CHECK_false);
+  if (asking_module_entry == NULL) {
+    THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+               "asking_module is invalid", JNI_FALSE);
+  }
+
+  if (target_module == NULL) {
+    return JNI_TRUE;  // Unnamed module is always readable.
+  }
+
+  ModuleEntry* target_module_entry = get_module_entry(target_module, CHECK_false);
+  if (target_module_entry == NULL) {
+    THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+               "target_module is invalid", JNI_FALSE);
+  }
+
+  if (TraceModules) {
+    ResourceMark rm;
+    tty->print_cr("[can_read_module(): module %s trying to read module %s, allowed = %s",
+                  asking_module_entry->name()->as_C_string(),
+                  target_module_entry->name()->as_C_string(),
+                  BOOL_TO_STR((asking_module_entry == target_module_entry) ||
+                    (asking_module_entry->can_read(target_module_entry))));
+  }
+
+  if (asking_module_entry == target_module_entry) {
+    return true;
+  }
+  return asking_module_entry->can_read(target_module_entry);
+}
+
+jboolean Modules::is_exported_to_module(JNIEnv *env, jobject from_module, jstring package, jobject to_module) {
+  JavaThread *THREAD = JavaThread::thread_from_jni_environment(env);
+
+  if (package == NULL) {
+    THROW_MSG_(vmSymbols::java_lang_NullPointerException(),
+               "package is null", JNI_FALSE);
+  }
+  if (from_module == NULL) {
+    THROW_MSG_(vmSymbols::java_lang_NullPointerException(),
+               "from_module is null", JNI_FALSE);
+  }
+  ModuleEntry* from_module_entry = get_module_entry(from_module, CHECK_false);
+  if (from_module_entry == NULL) {
+    THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+               "from_module is invalid", JNI_FALSE);
+  }
+  ModuleEntry* to_module_entry;
+  if (to_module == NULL) {
+    to_module_entry = NULL;
+  }
+  else {
+    to_module_entry = get_module_entry(to_module, CHECK_false);
+    if (to_module_entry == NULL) {
+      THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+                 "to_module is invalid", JNI_FALSE);
+    }
+  }
+
+  PackageEntry *package_entry = get_package_entry(from_module_entry, package,
+    CHECK_false);
+  if (package_entry == NULL) {
+    ResourceMark rm;
+    THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+               err_msg("Package not found in from_module: %s",
+                       from_module_entry->name()->as_C_string()), JNI_FALSE);
+  }
+  if (package_entry->module() != from_module_entry) {
+    ResourceMark rm;
+    THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
+               err_msg("Package: %s found in module %s, not in from_module: %s",
+                       package_entry->name()->as_C_string(),
+                       package_entry->module()->name()->as_C_string(),
+                       from_module_entry->name()->as_C_string()), JNI_FALSE);
+  }
+
+  if (TracePackages) {
+    ResourceMark rm;
+    tty->print_cr("[is_exported_to_module: package %s from module %s checking if exported to module %s, exported? = %s",
+                  package_entry->name()->as_C_string(),
+                  from_module_entry->name()->as_C_string(),
+                  to_module_entry != NULL ? to_module_entry->name()->as_C_string() : "unnamed",
+                  BOOL_TO_STR(package_entry->is_unqual_exported() ||
+                    (to_module != NULL && package_entry->is_qexported_to(to_module_entry)) ||
+                    (from_module_entry == to_module_entry)));
+  }
+
+  return (package_entry->is_unqual_exported() ||
+          (from_module_entry == to_module_entry) ||
+          (to_module != NULL && package_entry->is_qexported_to(to_module_entry)));
+}
+
+jobject Modules::get_module(JNIEnv *env, jclass clazz) {
+  oop mirror = JNIHandles::resolve_non_null(clazz);
+  if (mirror == NULL || java_lang_Class::is_primitive(mirror)) {
+    if (TraceModules) {
+      tty->print_cr("[get_module(): returning NULL]");
+    }
+    return NULL;
+  }
+
+  Klass* klass = java_lang_Class::as_Klass(mirror);
+  assert(klass->oop_is_instance() || klass->oop_is_objArray() ||
+    klass->oop_is_typeArray(), "Bad Klass");
+
+  oop module;
+  if (klass->oop_is_instance()) {
+    module = java_lang_Class::module(mirror);
+  }
+  else if (klass->oop_is_objArray()) {
+    ObjArrayKlass* obj_arr_klass = ObjArrayKlass::cast(klass);
+    Klass* bottom_klass = obj_arr_klass->bottom_klass();
+    module = java_lang_Class::module(bottom_klass->java_mirror());
+  }
+  else if (klass->oop_is_typeArray()) {
+    Klass* obj_k = SystemDictionary::Object_klass();
+    module = java_lang_Class::module(obj_k->java_mirror());
+  }
+
+  if (TraceModules) {
+    ResourceMark rm;
+    if (module != NULL) {
+      oop module_name = java_lang_reflect_Module::name(module);
+      tty->print("[get_module(): module ");
+      java_lang_String::print(module_name, tty);
+    }
+    else {
+      tty->print("[get_module(): unamed module");
+    }
+    tty->print_cr(" for class %s]", klass->external_name());
+  }
+
+  return JNIHandles::make_local(env, module);
+}
+
+jobject Modules::get_module(Symbol* package_name,
+                           Handle h_loader,
+                           TRAPS) {
+
+  const ModuleEntry* const module =
+    get_module_entry_by_package_name(package_name,
+                                     h_loader,
+                                     THREAD);
+
+  return module != NULL ?
+    JNIHandles::make_local(THREAD, module->literal()) : NULL;
+}
+
+void Modules::add_module_package(JNIEnv *env, jobject module, jstring package) {
+  JavaThread *THREAD = JavaThread::thread_from_jni_environment(env);
+  ResourceMark rm;
+
+  if (module == NULL) {
+    THROW_MSG(vmSymbols::java_lang_NullPointerException(),
+              "module is null");
+  }
+  if (package == NULL) {
+    THROW_MSG(vmSymbols::java_lang_NullPointerException(),
+              "package is null");
+  }
+  ModuleEntry* module_entry = get_module_entry(module, CHECK);
+  if (module_entry == NULL) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "module is invalid");
+  }
+  char *package_name = java_lang_String::as_utf8_string(
+    JNIHandles::resolve_non_null(package));
+  if (package_name == NULL) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Bad package");
+  }
+  if (!verify_package_name(package_name)) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              err_msg("Invalid package name: %s", package_name));
+  }
+
+  if (TraceModules) {
+    ResourceMark rm;
+    tty->print_cr("[add_module_package(): Adding package %s to module %s]",
+                  package_name, module_entry->name()->as_C_string());
+  }
+
+  TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, CHECK);
+  PackageEntryTable* package_table = module_entry->loader()->packages();
+  assert(package_table != NULL, "Missing package_table");
+
+  bool pkg_exists = false;
+  {
+    MutexLocker ml(Module_lock, THREAD);
+
+    // Check that the package does not exist in the class loader's package table.
+    if (!package_table->lookup_only(pkg_symbol)) {
+      PackageEntry* pkg = package_table->locked_create_entry_or_null(pkg_symbol, module_entry);
+      assert(pkg != NULL, "Unable to create a module's package entry");
+    } else {
+      pkg_exists = true;
+    }
+  }
+  if (pkg_exists) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              err_msg("Package %s already exists for class loader", package_name));
+  }
+}
+
+bool Modules::is_package_defined(Symbol* package, Handle h_loader, TRAPS) {
+  return get_package_entry_by_name(package, h_loader, THREAD) != NULL;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/classfile/modules.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -0,0 +1,115 @@
+/*
+* Copyright (c) 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
+* under the terms of the GNU General Public License version 2 only, as
+* published by the Free Software Foundation.
+*
+* This code is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+* version 2 for more details (a copy is included in the LICENSE file that
+* accompanied this code).
+*
+* You should have received a copy of the GNU General Public License version
+* 2 along with this work; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+*
+* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+* or visit www.oracle.com if you need additional information or have any
+* questions.
+*
+*/
+
+#ifndef SHARE_VM_CLASSFILE_MODULES_HPP
+#define SHARE_VM_CLASSFILE_MODULES_HPP
+
+#include "memory/allocation.hpp"
+#include "runtime/handles.hpp"
+
+class Symbol;
+
+class Modules : AllStatic {
+
+public:
+  // define_module defines a module containing the specified packages. It binds the
+  // module to its class loader by creating the ModuleEntry record in the
+  // ClassLoader's ModuleEntry table, creates PackageEntry records in the class
+  // loader's PackageEntry table, and, if successful, creates and returns a
+  // java.lang.reflect.Module object.  As in JVM_DefineClass the jstring format
+  // for all package names must use "/" and not "."
+  //
+  //  IllegalArgumentExceptions are thrown for the following :
+  // * Class loader already has a module with that name
+  // * Class loader has already defined types for any of the module's packages
+  // * Module_name is 'java.base'
+  // * Module_name is syntactically bad
+  // * Packages contains an illegal package name
+  // * Packages contains a duplicate package name
+  // * A package already exists in another module for this class loader
+  // * Class loader is not a subclass of java.lang.ClassLoader
+  //  NullPointerExceptions are thrown if module is null.
+  static void define_module(JNIEnv *env, jobject module, jstring version,
+                             jstring location, jobjectArray packages);
+
+  // This either does a qualified export of package in module from_module to module
+  // to_module or, if to_module is null, does an unqualified export of package.
+  // The format for the package name must use "/' not ".".
+  //
+  // Error conditions causing IlegalArgumentException to be throw :
+  // * Module from_module does not exist
+  // * Module to_module is not null and does not exist
+  // * Package is not syntactically correct
+  // * Package is not defined for from_module's class loader
+  // * Package is not in module from_module.
+  static void add_module_exports(JNIEnv *env, jobject from_module, jstring package, jobject to_module);
+
+  // add_reads_module adds module to_module to the list of modules that from_module
+  // can read.If from_module is the same as to_module then this is a no - op.
+  // An IllegalArgumentException is thrown if either from_module or to_module is null or does not exist.
+  static void add_reads_module(JNIEnv *env, jobject from_module, jobject to_module);
+
+  // can_read_module returns TRUE if module asking_module can read module target_module
+  // or if they are the same module.
+  //
+  // Throws IllegalArgumentException if:
+  // * either asking_module or target_module is not a java.lang.reflect.Module
+  static jboolean can_read_module(JNIEnv *env, jobject asking_module, jobject target_module);
+
+  // If package is valid then this returns TRUE if module from_module exports
+  // package to module to_module, if from_module and to_module are the same
+  // module, or if package is exported without qualification.
+  //
+  // IllegalArgumentException is throw if:
+  // * Either to_module or from_module does not exist
+  // * package is syntactically incorrect
+  // * package is not in from_module
+  static jboolean is_exported_to_module(JNIEnv *env, jobject from_module, jstring package, jobject to_module);
+
+  // Return the java.lang.reflect.Module object for this class object.
+  static jobject get_module(JNIEnv *env, jclass clazz);
+
+  // If package is defined by loader, return the
+  // java.lang.reflect.Module object for the module in which the package is defined.
+  // Returns NULL if package is invalid or not defined by loader.
+  static jobject get_module(Symbol* package_name, Handle h_loader, TRAPS);
+
+  // This adds package to module.
+  // It throws IllegalArgumentException if:
+  // * Module is bad
+  // * Package is not syntactically correct
+  // * Package is already defined for module's class loader.
+  static void add_module_package(JNIEnv *env, jobject module, jstring package);
+
+  // Return TRUE if package_name is syntactically valid, false otherwise.
+  static bool verify_package_name(char *package_name);
+
+  // Return TRUE iff package is defined by loader
+  static bool is_package_defined(Symbol* package_name, Handle h_loader, TRAPS);
+
+  static const char* default_version() { return "9.0"; }
+
+};
+
+#endif // SHARE_VM_CLASSFILE_MODULES_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/classfile/packageEntry.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -0,0 +1,305 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "classfile/moduleEntry.hpp"
+#include "classfile/packageEntry.hpp"
+#include "memory/resourceArea.hpp"
+#include "oops/symbol.hpp"
+#include "runtime/handles.inline.hpp"
+#include "trace/traceMacros.hpp"
+#include "utilities/events.hpp"
+#include "utilities/growableArray.hpp"
+#include "utilities/hashtable.inline.hpp"
+
+// Return true if this package is exported to m.
+bool PackageEntry::is_qexported_to(ModuleEntry* m) const {
+  assert(m != NULL, "No module to lookup in this package's qualified exports list");
+  MutexLocker m1(Module_lock);
+  if (!_is_exported || _qualified_exports == NULL) {
+    return false;
+  } else {
+    return _qualified_exports->contains(m);
+  }
+}
+
+// Add a module to the package's qualified export list.
+void PackageEntry::add_qexport(ModuleEntry* m) {
+  assert(_is_exported == true, "Adding a qualified export to a package that is not exported");
+  MutexLocker m1(Module_lock);
+  if (_qualified_exports == NULL) {
+    // Lazily create a package's qualified exports list.
+    // Initial size is 43, do not anticipate export lists to be large.
+    _qualified_exports = new (ResourceObj::C_HEAP, mtClass) GrowableArray<ModuleEntry*>(43, true);
+  }
+  _qualified_exports->append_if_missing(m);
+  m->set_pkgs_with_qexports(true);
+}
+
+// Set the package's exported state based on the value of the ModuleEntry.
+void PackageEntry::set_exported(ModuleEntry* m) {
+  if (_exported_pending_delete != NULL) {
+    // The qualified exports lists is pending safepoint deletion, a prior
+    // transition occurred from qualified to unqualified.
+    return;
+  }
+
+  if (m == NULL) {
+    // NULL indicates the package is being unqualifiedly exported
+    if (_is_exported && _qualified_exports != NULL) {
+      // Legit to transition a package from being qualifiedly exported
+      // to unqualified.  Clean up the qualified lists at the next
+      // safepoint.
+      _exported_pending_delete = _qualified_exports;
+    }
+
+    // Mark package as unqualifiedly exported
+    _is_exported = true;
+    _qualified_exports = NULL;
+
+  } else {
+    if (_is_exported && _qualified_exports == NULL) {
+      // An exception could be thrown, but choose to simply ignore.
+      // Illegal to convert an unqualified exported package to be qualifiedly exported
+      return;
+    }
+
+    // Add the exported module
+    _is_exported = true;
+    add_qexport(m);
+  }
+}
+
+// Remove dead module entries within the package's exported list.
+void PackageEntry::purge_qualified_exports() {
+  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
+  if (_qualified_exports != NULL) {
+    // Go backwards because this removes entries that are dead.
+    int len = _qualified_exports->length();
+    for (int idx = len - 1; idx >= 0; idx--) {
+      ModuleEntry* module_idx = _qualified_exports->at(idx);
+      ClassLoaderData* cld = module_idx->loader();
+      if (cld->is_unloading()) {
+        _qualified_exports->delete_at(idx);
+      }
+    }
+  }
+}
+
+void PackageEntry::delete_qualified_exports() {
+  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
+  if (_exported_pending_delete != NULL) {
+    // If a transition occurred from qualified to unqualified, the _qualified_exports
+    // field should have been NULL'ed out.
+    assert(_qualified_exports == NULL, "Package's exported pending delete, exported list should not be active");
+    delete _exported_pending_delete;
+  }
+
+  if (_qualified_exports != NULL) {
+    delete _qualified_exports;
+  }
+
+  _exported_pending_delete = NULL;
+  _qualified_exports = NULL;
+}
+
+PackageEntryTable::PackageEntryTable(int table_size)
+  : Hashtable<Symbol*, mtClass>(table_size, sizeof(PackageEntry))
+{
+}
+
+PackageEntryTable::~PackageEntryTable() {
+  assert_locked_or_safepoint(Module_lock);
+
+  // Walk through all buckets and all entries in each bucket,
+  // freeing each entry.
+  for (int i = 0; i < table_size(); ++i) {
+    for (PackageEntry* p = bucket(i); p != NULL;) {
+      PackageEntry* to_remove = p;
+      // read next before freeing.
+      p = p->next();
+
+      // Clean out the C heap allocated qualified exports list first before freeing the entry
+      to_remove->delete_qualified_exports();
+      to_remove->name()->decrement_refcount();
+
+      // Unlink from the Hashtable prior to freeing
+      unlink_entry(to_remove);
+      FREE_C_HEAP_ARRAY(char, to_remove);
+    }
+  }
+  assert(number_of_entries() == 0, "should have removed all entries");
+  assert(new_entry_free_list() == NULL, "entry present on PackageEntryTable's free list");
+  free_buckets();
+}
+
+PackageEntry* PackageEntryTable::new_entry(unsigned int hash, Symbol* name, ModuleEntry* module) {
+  assert_locked_or_safepoint(Module_lock);
+  PackageEntry* entry = (PackageEntry*) NEW_C_HEAP_ARRAY2(char, entry_size(), mtClass, CURRENT_PC);
+
+  // Initialize everything BasicHashtable would
+  entry->set_next(NULL);
+  entry->set_hash(hash);
+  entry->set_literal(name);
+
+  TRACE_INIT_PACKAGE_ID(entry);
+
+  // Initialize fields specific to a PackageEntry
+  entry->init();
+  entry->name()->increment_refcount();
+  if (module == NULL) {
+    // Indicates the unnamed module.
+    // Set the exported state to true because all packages
+    // within the unnamed module are unqualifiedly exported
+    entry->set_exported(true);
+  } else {
+    entry->set_module(module);
+  }
+
+  return entry;
+}
+
+void PackageEntryTable::add_entry(int index, PackageEntry* new_entry) {
+  assert_locked_or_safepoint(Module_lock);
+  Hashtable<Symbol*, mtClass>::add_entry(index, (HashtableEntry<Symbol*, mtClass>*)new_entry);
+}
+
+// Create package in loader's package entry table and return the entry.
+// If entry already exists, return null.  Assume Module lock was taken by caller.
+PackageEntry* PackageEntryTable::locked_create_entry_or_null(Symbol* name, ModuleEntry* module) {
+  assert_locked_or_safepoint(Module_lock);
+  // Check if package already exists.  Return NULL if it does.
+  if (lookup_only(name) != NULL) {
+    return NULL;
+  } else {
+    PackageEntry* entry = new_entry(compute_hash(name), name, module);
+    add_entry(index_for(name), entry);
+    return entry;
+  }
+}
+
+PackageEntry* PackageEntryTable::lookup(Symbol* name, ModuleEntry* module) {
+  PackageEntry* p = lookup_only(name);
+  if (p != NULL) {
+    return p;
+  } else {
+    // If not found, add to table. Grab the PackageEntryTable lock first.
+    MutexLocker ml(Module_lock);
+
+    // Since look-up was done lock-free, we need to check if another thread beat
+    // us in the race to insert the package.
+    PackageEntry* test = lookup_only(name);
+    if (test != NULL) {
+      // A race occurred and another thread introduced the package.
+      return test;
+    } else {
+      PackageEntry* entry = new_entry(compute_hash(name), name, module);
+      add_entry(index_for(name), entry);
+      return entry;
+    }
+  }
+}
+
+PackageEntry* PackageEntryTable::lookup_only(Symbol* name) {
+  int index = index_for(name);
+  for (PackageEntry* p = bucket(index); p != NULL; p = p->next()) {
+    if (p->name()->fast_compare(name) == 0) {
+      return p;
+    }
+  }
+  return NULL;
+}
+
+// Remove dead entries from all packages' exported list
+void PackageEntryTable::purge_all_package_exports() {
+  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
+  for (int i = 0; i < table_size(); i++) {
+    for (PackageEntry* entry = bucket(i);
+                       entry != NULL;
+                       entry = entry->next()) {
+      if (entry->exported_pending_delete()) {
+        // exported list is pending deletion due to a transition
+        // from qualified to unqualified
+        entry->delete_qualified_exports();
+      } else if (entry->is_qual_exported()) {
+        entry->purge_qualified_exports();
+      }
+    }
+  }
+}
+
+#ifndef PRODUCT
+void PackageEntryTable::print() {
+  tty->print_cr("Package Entry Table (table_size=%d, entries=%d)",
+                table_size(), number_of_entries());
+  for (int i = 0; i < table_size(); i++) {
+    for (PackageEntry* probe = bucket(i);
+                              probe != NULL;
+                              probe = probe->next()) {
+      probe->print();
+    }
+  }
+}
+
+void PackageEntry::print() {
+  ResourceMark rm;
+  tty->print_cr("package entry "PTR_FORMAT" name %s module %s is_exported %d next "PTR_FORMAT,
+                p2i(this), name()->as_C_string(),
+                ((module() == NULL) ? "[unnamed]" : module()->name()->as_C_string()),
+                _is_exported, p2i(next()));
+}
+#endif
+
+void PackageEntryTable::verify() {
+  int element_count = 0;
+  for (int index = 0; index < table_size(); index++) {
+    for (PackageEntry* probe = bucket(index);
+                              probe != NULL;
+                              probe = probe->next()) {
+      probe->verify();
+      element_count++;
+    }
+  }
+  guarantee(number_of_entries() == element_count,
+            "Verify of Package Entry Table failed");
+  debug_only(verify_lookup_length((double)number_of_entries() / table_size()));
+}
+
+void PackageEntry::verify() {
+  guarantee(name() != NULL, "A package entry must have a corresponding symbol name.");
+}
+
+// iteration of qualified exports
+void PackageEntry::package_exports_do(ModuleClosure* const f) {
+  assert_locked_or_safepoint(Module_lock);
+  assert(f != NULL, "invariant");
+
+  if (is_qual_exported()) {
+    int qe_len = _qualified_exports->length();
+
+    for (int i = 0; i < qe_len; ++i) {
+      f->do_module(_qualified_exports->at(i));
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/classfile/packageEntry.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_CLASSFILE_PACKAGEENTRY_HPP
+#define SHARE_VM_CLASSFILE_PACKAGEENTRY_HPP
+
+#include "classfile/moduleEntry.hpp"
+#include "oops/symbol.hpp"
+#include "utilities/growableArray.hpp"
+#include "utilities/hashtable.hpp"
+
+// A PackageEntry basically represents a Java package.  It contains:
+//   - Symbol* containing the package's name.
+//   - ModuleEntry* for this package's containing module.
+//     NULL if the package was defined within the unnamed module.
+//   - a growable array containing other module entries that this
+//     package is exported to.
+//   - a flag indicating if package is exported, either qualifiedly or
+//     unqualifiedly.
+//
+// Packages that are:
+//   - not exported:        _qualified_exports = NULL  && _is_exported is false
+//   - qualified exports:   _qualified_exports != NULL && _is_exported is true
+//   - unqualified exports: _qualified_exports = NULL  && _is_exported is true
+//
+class PackageEntry : public HashtableEntry<Symbol*, mtClass> {
+private:
+  ModuleEntry* _module;
+  bool _is_exported;
+  GrowableArray<ModuleEntry*>* _exported_pending_delete; // transitioned from qualified to unqualified, delete at safepoint
+  GrowableArray<ModuleEntry*>* _qualified_exports;
+  TRACE_DEFINE_TRACE_ID_FIELD;
+
+public:
+  void init() {
+    _module = NULL;
+    _is_exported = false;
+    _exported_pending_delete = NULL;
+    _qualified_exports = NULL;
+  }
+
+  // package name
+  Symbol*            name() const               { return literal(); }
+  void               set_name(Symbol* n)        { set_literal(n); }
+
+  // the module containing the package definition
+  ModuleEntry*       module() const             { return _module; }
+  void               set_module(ModuleEntry* m) { _module = m; }
+
+  // package's export state
+  bool               is_exported() const                 { return _is_exported; } // qualifiedly or unqualifiedly exported
+  bool               is_qual_exported() const            { return (_is_exported && (_qualified_exports != NULL)); }
+  bool               is_unqual_exported() const          { return (_is_exported && (_qualified_exports == NULL)); }
+  bool               exported_pending_delete() const     { return (_exported_pending_delete != NULL); }
+
+  void               set_exported(bool e)                { _is_exported = e; }
+  void               set_exported(ModuleEntry* m);
+
+  // returns true if the package is defined in the unnamed module
+  bool               in_unnamed_module() const  { return (_module == NULL); }
+
+  // returns true if the package specifies m as a qualified export
+  bool               is_qexported_to(ModuleEntry* m) const;
+
+  // add the module to the package's qualified exports
+  void               add_qexport(ModuleEntry* m);
+
+  PackageEntry* next() const {
+    return (PackageEntry*)HashtableEntry<Symbol*, mtClass>::next();
+  }
+
+  PackageEntry** next_addr() {
+    return (PackageEntry**)HashtableEntry<Symbol*, mtClass>::next_addr();
+  }
+
+  // iteration of qualified exports
+  void package_exports_do(ModuleClosure* const f);
+
+  TRACE_DEFINE_TRACE_ID_METHODS;
+
+  // Purge dead weak references out of exported list when any given class loader is unloaded.
+  void purge_qualified_exports();
+  void delete_qualified_exports();
+
+  void print() PRODUCT_RETURN;
+  void verify();
+};
+
+// The PackageEntryTable is a Hashtable containing a list of all packages defined
+// by a particular class loader.  Each package is represented as a PackageEntry node.
+// The PackageEntryTable's lookup is lock free.
+//
+class PackageEntryTable : public Hashtable<Symbol*, mtClass> {
+  friend class VMStructs;
+public:
+  enum Constants {
+    _packagetable_entry_size = 1009  // number of entries in package entry table
+  };
+
+private:
+  PackageEntry* new_entry(unsigned int hash, Symbol* name, ModuleEntry* module);
+  void add_entry(int index, PackageEntry* new_entry);
+
+public:
+  PackageEntryTable(int table_size);
+  ~PackageEntryTable();
+
+  int entry_size() const { return BasicHashtable<mtClass>::entry_size(); }
+
+  // Create package in loader's package entry table and return the entry.
+  // If entry already exists, return null.  Assume Module lock was taken by caller.
+  PackageEntry* locked_create_entry_or_null(Symbol* name, ModuleEntry* module);
+
+  // lookup Package with loader's package entry table, if not found add
+  PackageEntry* lookup(Symbol* name, ModuleEntry* module);
+
+  // only lookup Package within loader's package entry table
+  PackageEntry* lookup_only(Symbol* Package);
+
+  PackageEntry* bucket(int i) {
+    return (PackageEntry*)Hashtable<Symbol*, mtClass>::bucket(i);
+  }
+
+  PackageEntry** bucket_addr(int i) {
+    return (PackageEntry**)Hashtable<Symbol*, mtClass>::bucket_addr(i);
+  }
+
+  static unsigned int compute_hash(Symbol* name) {
+    return (unsigned int)(name->identity_hash());
+  }
+
+  int index_for(Symbol* name) const {
+    return hash_to_index(compute_hash(name));
+  }
+
+  // purge dead weak references out of exported list
+  void purge_all_package_exports();
+
+  void print() PRODUCT_RETURN;
+  void verify();
+};
+
+#endif // SHARE_VM_CLASSFILE_PACKAGEENTRY_HPP
--- a/src/share/vm/classfile/systemDictionary.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/systemDictionary.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -27,6 +27,7 @@
 #include "classfile/dictionary.hpp"
 #include "classfile/javaClasses.inline.hpp"
 #include "classfile/loaderConstraints.hpp"
+#include "classfile/packageEntry.hpp"
 #include "classfile/placeholders.hpp"
 #include "classfile/resolutionErrors.hpp"
 #include "classfile/stringTable.hpp"
@@ -46,6 +47,7 @@
 #include "oops/objArrayKlass.hpp"
 #include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
+#include "oops/symbol.hpp"
 #include "oops/typeArrayKlass.hpp"
 #include "prims/jvmtiEnvBase.hpp"
 #include "prims/methodHandles.hpp"
@@ -169,7 +171,7 @@
   if (class_loader.is_null()) {
     return false;
   }
-  return (class_loader->klass()->name() == vmSymbols::sun_misc_Launcher_ExtClassLoader());
+  return (class_loader->klass()->name() == vmSymbols::sun_misc_ClassLoaders_ExtClassLoader());
 }
 
 // ----------------------------------------------------------------------------
@@ -1263,22 +1265,81 @@
 
 instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) {
   instanceKlassHandle nh = instanceKlassHandle(); // null Handle
+
   if (class_loader.is_null()) {
+    int length;
+    TempNewSymbol pkg_name = NULL;
+    PackageEntry* pkg_entry = NULL;
+    bool search_only_bootloader_append = false;
+    ClassLoaderData *loader_data = class_loader_data(class_loader);
+
+    // Find the package in the boot loader's package entry table.
+    const jbyte* pkg_string = InstanceKlass::package_from_name(class_name, length);
+    if (pkg_string != NULL) {
+      pkg_name = SymbolTable::new_symbol((const char*)pkg_string, length, CHECK_(nh));
+      pkg_entry = loader_data->packages()->lookup_only(pkg_name);
+    }
+
+    // Prior to attempting to load the class, enforce the boot loader's
+    // visibility boundaries.
+    if (!Universe::is_module_initialized()) {
+      // During bootstrapping, prior to module initialization, any
+      // class attempting to be loaded must be checked against the
+      // java.base packages in the boot loader's PackageEntryTable.
+      // No class outside of java.base is allowed to be loaded during
+      // this bootstrapping window.
+      if (!DumpSharedSpaces) {
+        if (pkg_entry == NULL || pkg_entry->in_unnamed_module()) {
+          // Class is either in the unnamed package or in
+          // a named package within the unnamed module.  Either
+          // case is outside of java.base, do not attempt to
+          // load the class.
+          return nh;
+        } else {
+          // Check that the class' package is defined within java.base.
+          ModuleEntry* mod_entry = pkg_entry->module();
+          Symbol* mod_entry_name = mod_entry->name();
+          if (mod_entry_name->fast_compare(vmSymbols::java_base()) != 0) {
+            return nh;
+          }
+        }
+      }
+    } else {
+      assert(!DumpSharedSpaces, "Archive dumped after module system initialization");
+      // After the module system has been initialized, check if the class'
+      // package is in a module defined to the boot loader.
+      if (pkg_string == NULL || pkg_entry == NULL || pkg_entry->in_unnamed_module()) {
+        // Class is either in the unnamed package, in a named package
+        // within a module not defined to the boot loader or in a
+        // a named package within the unnamed module.  In all cases,
+        // limit visibility to search for the class only in the boot
+        // loader's append path.
+        search_only_bootloader_append = true;
+      }
+    }
+
+    // Prior to bootstrapping's module initialization, never load a class outside
+    // of the boot loader's module path
+    assert(Universe::is_module_initialized() || DumpSharedSpaces ||
+           !search_only_bootloader_append,
+           "Attempt to load a class outside of boot loader's module path");
 
     // Search the shared system dictionary for classes preloaded into the
     // shared spaces.
     instanceKlassHandle k;
     {
 #if INCLUDE_CDS
-      PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time());
-      k = load_shared_class(class_name, class_loader, THREAD);
+      if (!search_only_bootloader_append) {
+        PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time());
+        k = load_shared_class(class_name, class_loader, THREAD);
+      }
 #endif
     }
 
     if (k.is_null()) {
       // Use VM class loader
       PerfTraceTime vmtimer(ClassLoader::perf_sys_classload_time());
-      k = ClassLoader::load_classfile(class_name, CHECK_(nh));
+      k = ClassLoader::load_classfile(class_name, search_only_bootloader_append, CHECK_(nh));
     }
 
     // find_or_define_instance_class may return a different InstanceKlass
@@ -1605,7 +1666,7 @@
 }
 
 
-// Get the next class in the diictionary.
+// Get the next class in the dictionary.
 Klass* SystemDictionary::try_get_next_class() {
   return dictionary()->try_get_next_class();
 }
@@ -1872,6 +1933,12 @@
 
 void SystemDictionary::initialize_preloaded_classes(TRAPS) {
   assert(WK_KLASS(Object_klass) == NULL, "preloaded classes should only be initialized once");
+
+  // Define packages for module java.base from either the exploded build or the
+  // bootmodules.jimage file. This call needs to be done here, after vmSymbols::initialize()
+  // is called but before any classes are pre-loaded.
+  ClassLoader::define_javabase();
+
   // Preload commonly used klasses
   WKID scan = FIRST_WKID;
   // first do Object, then String, Class
--- a/src/share/vm/classfile/systemDictionary.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/systemDictionary.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -136,6 +136,7 @@
   do_klass(Properties_klass,                            java_util_Properties,                      Pre                 ) \
   do_klass(reflect_AccessibleObject_klass,              java_lang_reflect_AccessibleObject,        Pre                 ) \
   do_klass(reflect_Field_klass,                         java_lang_reflect_Field,                   Pre                 ) \
+  do_klass(reflect_Module_klass,                        java_lang_reflect_Module,                  Pre                 ) \
   do_klass(reflect_Parameter_klass,                     java_lang_reflect_Parameter,               Opt                 ) \
   do_klass(reflect_Method_klass,                        java_lang_reflect_Method,                  Pre                 ) \
   do_klass(reflect_Constructor_klass,                   java_lang_reflect_Constructor,             Pre                 ) \
@@ -174,7 +175,7 @@
   do_klass(URLClassLoader_klass,                        java_net_URLClassLoader,                   Pre                 ) \
   do_klass(URL_klass,                                   java_net_URL,                              Pre                 ) \
   do_klass(Jar_Manifest_klass,                          java_util_jar_Manifest,                    Pre                 ) \
-  do_klass(sun_misc_Launcher_klass,                     sun_misc_Launcher,                         Pre                 ) \
+  do_klass(sun_misc_ClassLoaders_klass,                 sun_misc_ClassLoaders,                     Pre                 ) \
   do_klass(CodeSource_klass,                            java_security_CodeSource,                  Pre                 ) \
                                                                                                                          \
   /* It's NULL in non-1.4 JDKs. */                                                                                       \
--- a/src/share/vm/classfile/vmSymbols.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/classfile/vmSymbols.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -48,7 +48,8 @@
 // Mapping function names to values. New entries should be added below.
 
 #define VM_SYMBOLS_DO(template, do_alias)                                                         \
-  /* commonly used class names */                                                                 \
+  /* commonly used class, package, module names */                                                \
+  template(java_base,                                 "java.base")                                \
   template(java_lang_System,                          "java/lang/System")                         \
   template(java_lang_Object,                          "java/lang/Object")                         \
   template(java_lang_Class,                           "java/lang/Class")                          \
@@ -85,6 +86,7 @@
   template(java_lang_reflect_Method,                  "java/lang/reflect/Method")                 \
   template(java_lang_reflect_Constructor,             "java/lang/reflect/Constructor")            \
   template(java_lang_reflect_Field,                   "java/lang/reflect/Field")                  \
+  template(java_lang_reflect_Module,                  "java/lang/reflect/Module")                 \
   template(java_lang_reflect_Parameter,               "java/lang/reflect/Parameter")              \
   template(java_lang_reflect_Array,                   "java/lang/reflect/Array")                  \
   template(java_lang_StringBuffer,                    "java/lang/StringBuffer")                   \
@@ -113,17 +115,23 @@
   template(java_util_Hashtable,                       "java/util/Hashtable")                      \
   template(java_lang_Compiler,                        "java/lang/Compiler")                       \
   template(sun_misc_Signal,                           "sun/misc/Signal")                          \
-  template(sun_misc_Launcher,                         "sun/misc/Launcher")                        \
+  template(sun_misc_ClassLoaders,                     "sun/misc/ClassLoaders")                    \
   template(java_lang_AssertionStatusDirectives,       "java/lang/AssertionStatusDirectives")      \
   template(getBootClassPathEntryForClass_name,        "getBootClassPathEntryForClass")            \
   template(sun_misc_PostVMInitHook,                   "sun/misc/PostVMInitHook")                  \
-  template(sun_misc_Launcher_ExtClassLoader,          "sun/misc/Launcher$ExtClassLoader")         \
+  template(sun_misc_ClassLoaders_ExtClassLoader,      "sun/misc/ClassLoaders$ExtClassLoader")     \
                                                                                                   \
   /* Java runtime version access */                                                               \
   template(sun_misc_Version,                          "sun/misc/Version")                         \
   template(java_runtime_name_name,                    "java_runtime_name")                        \
   template(java_runtime_version_name,                 "java_runtime_version")                     \
                                                                                                   \
+  /* system initialization */                                                                     \
+  template(initPhase1_name,                           "initPhase1")                               \
+  template(initPhase2_name,                           "initPhase2")                               \
+  template(initPhase3_name,                           "initPhase3")                               \
+  template(java_lang_reflect_module_init_signature,   "(Ljava/lang/ClassLoader;Ljava/lang/String;)V") \
+                                                                                                  \
   /* class file format tags */                                                                    \
   template(tag_source_file,                           "SourceFile")                               \
   template(tag_inner_classes,                         "InnerClasses")                             \
@@ -327,7 +335,6 @@
   template(run_finalization_name,                     "runFinalization")                          \
   template(run_finalizers_on_exit_name,               "runFinalizersOnExit")                      \
   template(dispatchUncaughtException_name,            "dispatchUncaughtException")                \
-  template(initializeSystemClass_name,                "initializeSystemClass")                    \
   template(loadClass_name,                            "loadClass")                                \
   template(loadClassInternal_name,                    "loadClassInternal")                        \
   template(get_name,                                  "get")                                      \
@@ -401,6 +408,8 @@
   template(signers_name,                              "signers_name")                             \
   template(loader_data_name,                          "loader_data")                              \
   template(dependencies_name,                         "dependencies")                             \
+  template(loader_name,                               "loader")                                   \
+  template(module_name,                               "module")                                   \
   template(input_stream_void_signature,               "(Ljava/io/InputStream;)V")                 \
   template(getFileURL_name,                           "getFileURL")                               \
   template(getFileURL_signature,                      "(Ljava/io/File;)Ljava/net/URL;")           \
@@ -502,6 +511,7 @@
   template(string_signature,                          "Ljava/lang/String;")                                       \
   template(reference_signature,                       "Ljava/lang/ref/Reference;")                                \
   template(executable_signature,                      "Ljava/lang/reflect/Executable;")                           \
+  template(module_signature,                          "Ljava/lang/reflect/Module;")                               \
   template(concurrenthashmap_signature,               "Ljava/util/concurrent/ConcurrentHashMap;")                 \
   template(String_StringBuilder_signature,            "(Ljava/lang/String;)Ljava/lang/StringBuilder;")            \
   template(int_StringBuilder_signature,               "(I)Ljava/lang/StringBuilder;")                             \
--- a/src/share/vm/interpreter/bytecodeInterpreter.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/interpreter/bytecodeInterpreter.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -2259,10 +2259,8 @@
               // Decrement counter at checkcast.
               BI_PROFILE_SUBTYPECHECK_FAILED(objKlass);
               ResourceMark rm(THREAD);
-              const char* objName = objKlass->external_name();
-              const char* klassName = klassOf->external_name();
               char* message = SharedRuntime::generate_class_cast_message(
-                objName, klassName);
+                objKlass, klassOf);
               VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message, note_classCheck_trap);
             }
             // Profile checkcast with null_seen and receiver.
--- a/src/share/vm/interpreter/interpreterRuntime.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -360,7 +360,7 @@
 
   ResourceMark rm(thread);
   char* message = SharedRuntime::generate_class_cast_message(
-    thread, obj->klass()->external_name());
+    thread, obj->klass());
 
   if (ProfileTraps) {
     note_trap(thread, Deoptimization::Reason_class_check, CHECK);
--- a/src/share/vm/interpreter/linkResolver.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/interpreter/linkResolver.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -216,18 +216,25 @@
 // Klass resolution
 
 void LinkResolver::check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS) {
-  if (!Reflection::verify_class_access(ref_klass(),
-                                       sel_klass(),
-                                       true)) {
+  Reflection::VerifyClassAccessResults vca_result =
+    Reflection::verify_class_access(ref_klass(), sel_klass(), true);
+  if (vca_result != Reflection::ACCESS_OK) {
     ResourceMark rm(THREAD);
-    Exceptions::fthrow(
-      THREAD_AND_LOCATION,
-      vmSymbols::java_lang_IllegalAccessError(),
-      "tried to access class %s from class %s",
-      sel_klass->external_name(),
-      ref_klass->external_name()
-    );
-    return;
+    char* msg = Reflection::verify_class_access_msg(ref_klass(), sel_klass(), vca_result);
+    if (msg == NULL) {
+      Exceptions::fthrow(
+        THREAD_AND_LOCATION,
+        vmSymbols::java_lang_IllegalAccessError(),
+        "failed to access class %s from class %s",
+        sel_klass->external_name(),
+        ref_klass->external_name());
+    } else {
+      // Use module specific message returned by verify_class_access_msg().
+      Exceptions::fthrow(
+        THREAD_AND_LOCATION,
+        vmSymbols::java_lang_IllegalAccessError(),
+        "%s", msg);
+    }
   }
 }
 
--- a/src/share/vm/memory/filemap.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/memory/filemap.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -224,6 +224,9 @@
             }
             ent->_filesize = -1;
           } else {
+            // This class path entry is neither a jar file nor a directory.  Set
+            // _filesize to -2 to indicate that it is not a jar file nor a directory.
+            assert(strncmp(name + strlen(name) - 7, ".jimage", 7) == 0, "expect *.jimage file");
             ent->_filesize = -2;
           }
         }
--- a/src/share/vm/memory/filemap.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/memory/filemap.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -46,6 +46,8 @@
   const char *_name;
   time_t _timestamp;          // jar timestamp,  0 if is directory or other
   long   _filesize;           // jar file size, -1 if is directory, -2 if other
+
+  // The _timestamp only gets set for jar files.
   bool is_jar() {
     return _timestamp != 0;
   }
--- a/src/share/vm/memory/universe.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/memory/universe.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -146,6 +146,7 @@
 
 int             Universe::_base_vtable_size = 0;
 bool            Universe::_bootstrapping = false;
+bool            Universe::_module_initialized = false;
 bool            Universe::_fully_initialized = false;
 
 size_t          Universe::_heap_capacity_at_last_gc;
@@ -902,6 +903,10 @@
   Universe::genesis(CATCH);
 }
 
+// Set after initialization of the module runtime, call_initModuleRuntime
+void universe_post_module_init() {
+  Universe::_module_initialized = true;
+}
 
 bool universe_post_init() {
   assert(!is_init_completed(), "Error: initialization not yet completed!");
--- a/src/share/vm/memory/universe.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/memory/universe.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -111,6 +111,7 @@
   friend jint  universe_init();
   friend void  universe2_init();
   friend bool  universe_post_init();
+  friend void  universe_post_module_init();
 
  private:
   // Known classes in the VM
@@ -201,6 +202,7 @@
 
   // Initialization
   static bool _bootstrapping;                         // true during genesis
+  static bool _module_initialized;                    // true after call_initPhase2 called
   static bool _fully_initialized;                     // true after universe_init and initialize_vtables called
 
   // the array of preallocated errors with backtraces
@@ -420,6 +422,7 @@
 
   // Testers
   static bool is_bootstrapping()                      { return _bootstrapping; }
+  static bool is_module_initialized()                 { return _module_initialized; }
   static bool is_fully_initialized()                  { return _fully_initialized; }
 
   static inline bool element_type_should_be_aligned(BasicType type);
--- a/src/share/vm/oops/arrayKlass.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/oops/arrayKlass.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -102,7 +102,7 @@
   ResourceMark rm(THREAD);
   k->initialize_supers(super_klass(), CHECK);
   k->vtable()->initialize_vtable(false, CHECK);
-  java_lang_Class::create_mirror(k, Handle(THREAD, k->class_loader()), Handle(NULL), CHECK);
+  java_lang_Class::create_mirror(k, Handle(THREAD, k->class_loader()), Handle(NULL), Handle(NULL), CHECK);
 }
 
 GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots) {
--- a/src/share/vm/oops/instanceKlass.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/oops/instanceKlass.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -237,6 +237,7 @@
   init_implementor();
   set_fields(NULL, 0);
   set_constants(NULL);
+  set_package(NULL);
   set_class_loader_data(NULL);
   set_source_file_name_index(0);
   set_source_debug_extension(NULL, 0);
@@ -2359,8 +2360,9 @@
 }
 
 void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
+  instanceKlassHandle ik(THREAD, this);
+  ik->set_package(ik->name(), loader_data, CHECK);
   Klass::restore_unshareable_info(loader_data, protection_domain, CHECK);
-  instanceKlassHandle ik(THREAD, this);
 
   Array<Method*>* methods = ik->methods();
   int num_methods = methods->length();
@@ -2563,26 +2565,103 @@
   return dest;
 }
 
-// different verisons of is_same_class_package
+const jbyte* InstanceKlass::package_from_name(Symbol* name, int& length) {
+  ResourceMark rm;
+  length = 0;
+  if (name == NULL) {
+    return NULL;
+  } else {
+    const jbyte* base_name = name->base();
+    const jbyte* last_slash = UTF8::strrchr(base_name, name->utf8_length(), '/');
+
+    if (last_slash == NULL) {
+      // No package name
+      return NULL;
+    } else {
+      // Skip over '['s
+      if (*base_name == '[') {
+        do {
+          base_name++;
+        } while (*base_name == '[');
+        if (*base_name != 'L') {
+          // Fully qualified class names should not contain a 'L'.
+          // Set length to -1 to indicate that the package name
+          // could not be obtained due to an error condition.
+          // In this situtation, is_same_class_package returns false.
+          length = -1;
+          return NULL;
+        }
+      }
+
+      // Found the package name, look it up in the symbol table.
+      length = last_slash - base_name;
+      assert(length > 0, "Bad length for package name");
+      return base_name;
+    }
+  }
+}
+
+void InstanceKlass::set_package(Symbol* name, ClassLoaderData* loader, TRAPS) {
+  int length;
+  const jbyte* base_name = package_from_name(name, length);
+
+  if (base_name != NULL && loader != NULL) {
+    TempNewSymbol pkg_name = SymbolTable::new_symbol((const char*)base_name, length, CHECK);
+
+    // Find in class loader's package entry table.
+    _package_entry = loader->packages()->lookup_only(pkg_name);
+
+    // If the package name is not found in the loader's package
+    // entry table, it is an indication that the package has not
+    // been defined. Consider it defined within the unnamed module.
+    if (_package_entry == NULL) {
+      ResourceMark rm;
+      _package_entry = loader->packages()->lookup(pkg_name, NULL);
+      // A package should have been successfully created
+      assert(_package_entry != NULL, err_msg("Package entry for class %s not found, loader %s",
+                                             name->as_C_string(), loader->loader_name()));
+    }
+
+    if (TracePackages) {
+      ResourceMark rm;
+      ModuleEntry* m = _package_entry->module();
+      tty->print_cr("[Setting package: class %s, package = %s, module = %s]",
+                    external_name(),
+                    pkg_name->as_C_string(),
+                    ((m == NULL) ? "[unnamed]" : m->name()->as_C_string()));
+    }
+  }
+}
+
+// different versions of is_same_class_package
 bool InstanceKlass::is_same_class_package(Klass* class2) {
-  Klass* class1 = this;
-  oop classloader1 = InstanceKlass::cast(class1)->class_loader();
-  Symbol* classname1 = class1->name();
+  oop classloader1 = this->class_loader();
+  PackageEntry* classpkg1 = this->package();
 
   if (class2->oop_is_objArray()) {
     class2 = ObjArrayKlass::cast(class2)->bottom_klass();
   }
+
   oop classloader2;
+  PackageEntry* classpkg2;
   if (class2->oop_is_instance()) {
     classloader2 = InstanceKlass::cast(class2)->class_loader();
+    classpkg2 = InstanceKlass::cast(class2)->package();
   } else {
     assert(class2->oop_is_typeArray(), "should be type array");
     classloader2 = NULL;
+    classpkg2 = NULL;
   }
-  Symbol* classname2 = class2->name();
-
-  return InstanceKlass::is_same_class_package(classloader1, classname1,
-                                              classloader2, classname2);
+
+  // Same package is determined by comparing class loader
+  // and package entries. Both must be the same. This rule
+  // applies even to classes that are defined in the unnamed
+  // package, they still must have the same class loader.
+  if ((classloader1 == classloader2) && (classpkg1 == classpkg2)) {
+    return true;
+  }
+
+  return false;
 }
 
 bool InstanceKlass::is_same_class_package(oop classloader2, Symbol* classname2) {
@@ -2608,43 +2687,24 @@
     // The Symbol*'s are in UTF8 encoding. Since we only need to check explicitly
     // for ASCII characters ('/', 'L', '['), we can keep them in UTF8 encoding.
     // Otherwise, we just compare jbyte values between the strings.
-    const jbyte *name1 = class_name1->base();
-    const jbyte *name2 = class_name2->base();
-
-    const jbyte *last_slash1 = UTF8::strrchr(name1, class_name1->utf8_length(), '/');
-    const jbyte *last_slash2 = UTF8::strrchr(name2, class_name2->utf8_length(), '/');
-
-    if ((last_slash1 == NULL) || (last_slash2 == NULL)) {
+    int length1;
+    int length2;
+    const jbyte *name1 = package_from_name(class_name1, length1);
+    const jbyte *name2 = package_from_name(class_name2, length2);
+
+    if ((length1 < 0) || (length2 < 0)) {
+      // error occurred parsing package name.
+      return false;
+    }
+
+    if ((name1 == NULL) || (name2 == NULL)) {
       // One of the two doesn't have a package.  Only return true
       // if the other one also doesn't have a package.
-      return last_slash1 == last_slash2;
-    } else {
-      // Skip over '['s
-      if (*name1 == '[') {
-        do {
-          name1++;
-        } while (*name1 == '[');
-        if (*name1 != 'L') {
-          // Something is terribly wrong.  Shouldn't be here.
-          return false;
-        }
-      }
-      if (*name2 == '[') {
-        do {
-          name2++;
-        } while (*name2 == '[');
-        if (*name2 != 'L') {
-          // Something is terribly wrong.  Shouldn't be here.
-          return false;
-        }
-      }
-
-      // Check that package part is identical
-      int length1 = last_slash1 - name1;
-      int length2 = last_slash2 - name2;
-
-      return UTF8::equal(name1, length1, name2, length2);
+      return name1 == name2;
     }
+
+    // Check that package part is identical
+    return UTF8::equal(name1, length1, name2, length2);
   }
 }
 
@@ -2683,7 +2743,7 @@
   instanceKlassHandle class2(THREAD, class2_oop);
 
   // must be in same package before we try anything else
-  if (!class1->is_same_class_package(class2->class_loader(), class2->name()))
+  if (!class1->is_same_class_package(class2()))
     return false;
 
   // As long as there is an outer1.getEnclosingClass,
--- a/src/share/vm/oops/instanceKlass.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/oops/instanceKlass.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -26,6 +26,8 @@
 #define SHARE_VM_OOPS_INSTANCEKLASS_HPP
 
 #include "classfile/classLoaderData.hpp"
+#include "classfile/packageEntry.hpp"
+#include "classfile/moduleEntry.hpp"
 #include "memory/referenceType.hpp"
 #include "oops/annotations.hpp"
 #include "oops/constMethod.hpp"
@@ -154,6 +156,8 @@
  protected:
   // Annotations for this class
   Annotations*    _annotations;
+  // Package this class is defined in
+  PackageEntry*   _package_entry;
   // Array classes holding elements of this class.
   Klass*          _array_klasses;
   // Constant pool for this class.
@@ -398,6 +402,11 @@
   bool is_override(methodHandle super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);
 
   // package
+  PackageEntry* package() const     { return _package_entry; }
+  ModuleEntry* module() const       { return (in_unnamed_package() ? NULL : _package_entry->module()); }
+  bool in_unnamed_package() const   { return (_package_entry == NULL); }
+  void set_package(PackageEntry* p) { _package_entry = p; }
+  void set_package(Symbol* name, ClassLoaderData* loader, TRAPS);
   bool is_same_class_package(Klass* class2);
   bool is_same_class_package(oop classloader2, Symbol* classname2);
   static bool is_same_class_package(oop class_loader1, Symbol* class_name1, oop class_loader2, Symbol* class_name2);
@@ -771,7 +780,7 @@
 
   // support for stub routines
   static ByteSize init_state_offset()  { return in_ByteSize(offset_of(InstanceKlass, _init_state)); }
-  TRACE_DEFINE_OFFSET;
+  TRACE_DEFINE_KLASS_TRACE_ID_OFFSET;
   static ByteSize init_thread_offset() { return in_ByteSize(offset_of(InstanceKlass, _init_thread)); }
 
   // subclass/subinterface checks
@@ -973,6 +982,7 @@
 
   // Naming
   const char* signature_name() const;
+  static const jbyte* package_from_name(Symbol* name, int& length);
 
   // Iterators
   int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) {
--- a/src/share/vm/oops/klass.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/oops/klass.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "classfile/javaClasses.hpp"
 #include "classfile/dictionary.hpp"
+#include "classfile/packageEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "gc_implementation/shared/markSweep.inline.hpp"
@@ -184,7 +185,7 @@
   set_subklass(NULL);
   set_next_sibling(NULL);
   set_next_link(NULL);
-  TRACE_INIT_ID(this);
+  TRACE_INIT_KLASS_ID(this);
 
   set_prototype_header(markOopDesc::prototype());
   set_biased_lock_revocation_count(0);
@@ -350,7 +351,6 @@
   return NULL;
 }
 
-
 InstanceKlass* Klass::superklass() const {
   assert(super() == NULL || super()->oop_is_instance(), "must be instance klass");
   return _super == NULL ? NULL : InstanceKlass::cast(_super);
@@ -511,7 +511,7 @@
 }
 
 void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
-  TRACE_INIT_ID(this);
+  TRACE_INIT_KLASS_ID(this);
   // If an exception happened during CDS restore, some of these fields may already be
   // set.  We leave the class on the CLD list, even if incomplete so that we don't
   // modify the CLD list outside a safepoint.
@@ -529,7 +529,15 @@
   // gotten an OOM later but keep the mirror if it was created.
   if (java_mirror() == NULL) {
     Handle loader = loader_data->class_loader();
-    java_lang_Class::create_mirror(this, loader, protection_domain, CHECK);
+    ModuleEntry* module_entry = NULL;
+    // Obtain klass' module.
+    if (oop_is_instance()) {
+      InstanceKlass* ik = (InstanceKlass*) this;
+      module_entry = ik->module();
+    }
+    // Obtain j.l.r.Module if available
+    Handle class_module(THREAD, ((module_entry == NULL) ? (oop)NULL : module_entry->module()));
+    java_lang_Class::create_mirror(this, loader, class_module, protection_domain, CHECK);
   }
 }
 
--- a/src/share/vm/oops/klass.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/oops/klass.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -142,7 +142,7 @@
   markOop  _prototype_header;   // Used when biased locking is both enabled and disabled for this type
   jint     _biased_lock_revocation_count;
 
-  TRACE_DEFINE_KLASS_TRACE_ID;
+  TRACE_DEFINE_TRACE_ID_FIELD;
 
   // Remembered sets support for the oops in the klasses.
   jbyte _modified_oops;             // Card Table Equivalent (YC/CMS support)
@@ -566,7 +566,7 @@
   jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }
   void  set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }
 
-  TRACE_DEFINE_KLASS_METHODS;
+  TRACE_DEFINE_TRACE_ID_METHODS;
 
   // garbage collection support
   void oops_do(OopClosure* cl);
--- a/src/share/vm/opto/library_call.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/opto/library_call.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -3074,7 +3074,7 @@
   Node* cls = null_check(argument(1), T_OBJECT);
   Node* kls = load_klass_from_mirror(cls, false, NULL, 0);
   kls = null_check(kls, T_OBJECT);
-  ByteSize offset = TRACE_ID_OFFSET;
+  ByteSize offset = TRACE_KLASS_TRACE_ID_OFFSET;
   Node* insp = basic_plus_adr(kls, in_bytes(offset));
   Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG, MemNode::unordered);
   Node* bits = longcon(~0x03l); // ignore bit 0 & 1
--- a/src/share/vm/precompiled/precompiled.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/precompiled/precompiled.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -57,7 +57,11 @@
 # include "classfile/classFileParser.hpp"
 # include "classfile/classFileStream.hpp"
 # include "classfile/classLoader.hpp"
+# include "classfile/imageFile.hpp"
 # include "classfile/javaClasses.hpp"
+# include "classfile/moduleEntry.hpp"
+# include "classfile/modules.hpp"
+# include "classfile/packageEntry.hpp"
 # include "classfile/symbolTable.hpp"
 # include "classfile/systemDictionary.hpp"
 # include "classfile/vmSymbols.hpp"
--- a/src/share/vm/prims/jni.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/prims/jni.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -28,6 +28,7 @@
 #include "classfile/altHashing.hpp"
 #include "classfile/classLoader.hpp"
 #include "classfile/javaClasses.hpp"
+#include "classfile/modules.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
@@ -3434,6 +3435,19 @@
   return JNI_OK;
 JNI_END
 
+
+DT_RETURN_MARK_DECL(GetModule, jobject, HOTSPOT_JNI_GETMODULE_RETURN(_ret_ref));
+
+JNI_ENTRY(jobject, jni_GetModule(JNIEnv* env, jclass clazz))
+  JNIWrapper("GetModule");
+  HOTSPOT_JNI_GETMODULE_ENTRY(env, clazz);
+  jobject res;
+  DT_RETURN_MARK(GetModule, jobject, (const jobject&)res);
+  res = Modules::get_module(env, clazz);;
+  return res;
+JNI_END
+
+
 // Structure containing all jni functions
 struct JNINativeInterface_ jni_NativeInterface = {
     NULL,
@@ -3713,7 +3727,11 @@
 
     // New 1_6 features
 
-    jni_GetObjectRefType
+    jni_GetObjectRefType,
+
+    // Module features
+
+    jni_GetModule
 };
 
 
--- a/src/share/vm/prims/jni.h	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/prims/jni.h	Fri Mar 06 14:27:49 2015 -0800
@@ -765,6 +765,11 @@
 
     jobjectRefType (JNICALL *GetObjectRefType)
         (JNIEnv* env, jobject obj);
+
+    /* Module Features */
+
+    jobject (JNICALL *GetModule)
+       (JNIEnv* env, jclass clazz);
 };
 
 /*
@@ -1857,6 +1862,12 @@
         return functions->GetObjectRefType(this, obj);
     }
 
+    /* Module Features */
+
+    jobject GetModule(jclass clazz) {
+        return functions->GetModule(this, clazz);
+    }
+
 #endif /* __cplusplus */
 };
 
--- a/src/share/vm/prims/jniCheck.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/prims/jniCheck.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -1987,7 +1987,17 @@
     return result;
 JNI_END
 
-
+JNI_ENTRY_CHECKED(jobject,
+  checked_jni_GetModule(JNIEnv *env,
+                        jclass clazz))
+    functionEnter(thr);
+    IN_VM(
+        jniCheck::validate_class(thr, clazz, false);
+    )
+    jobject result = UNCHECKED()->GetModule(env,clazz);
+    functionExit(thr);
+    return result;
+JNI_END
 
 /*
  * Structure containing all checked jni functions
@@ -2270,7 +2280,11 @@
 
     // New 1.6 Features
 
-    checked_jni_GetObjectRefType
+    checked_jni_GetObjectRefType,
+
+    // Module Features
+
+    checked_jni_GetModule
 };
 
 
--- a/src/share/vm/prims/jvm.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/prims/jvm.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -24,8 +24,12 @@
 
 #include "precompiled.hpp"
 #include "classfile/classLoader.hpp"
+#include "classfile/classLoaderData.inline.hpp"
 #include "classfile/javaAssertions.hpp"
 #include "classfile/javaClasses.inline.hpp"
+#include "classfile/moduleEntry.hpp"
+#include "classfile/modules.hpp"
+#include "classfile/packageEntry.hpp"
 #include "classfile/stringTable.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
@@ -435,6 +439,19 @@
     }
   }
 
+  // -Xoverride
+  if (Arguments::override_dir() != NULL) {
+    PUTPROP(props, "jdk.runtime.override", Arguments::override_dir());
+  }
+
+  // Additional module dependences and exports
+  if (AddModuleRequires != NULL) {
+    PUTPROP(props, "jdk.runtime.addModuleRequires", AddModuleRequires);
+  }
+  if (AddModuleExports != NULL) {
+    PUTPROP(props, "jdk.runtime.addModuleExports", AddModuleExports);
+  }
+
   return properties;
 JVM_END
 
@@ -983,6 +1000,39 @@
             (jclass) JNIHandles::make_local(env, k->java_mirror());
 JVM_END
 
+// Module support //////////////////////////////////////////////////////////////////////////////
+
+JVM_ENTRY(void, JVM_DefineModule(JNIEnv *env, jobject module, jstring version, jstring location,
+                                 jobjectArray packages))
+  JVMWrapper("JVM_DefineModule");
+  Modules::define_module(env, module, version, location, packages);
+JVM_END
+
+JVM_ENTRY(void, JVM_AddModuleExports(JNIEnv *env, jobject from_module, jstring package, jobject to_module))
+  JVMWrapper("JVM_AddModuleExports");
+  Modules::add_module_exports(env, from_module, package, to_module);
+JVM_END
+
+JVM_ENTRY (void, JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject to_module))
+  JVMWrapper("JVM_AddReadsModule");
+  Modules::add_reads_module(env, from_module, to_module);
+JVM_END
+
+JVM_ENTRY(jboolean, JVM_CanReadModule(JNIEnv *env, jobject asking_module, jobject target_module))
+  JVMWrapper("JVM_CanReadModule");
+  return Modules::can_read_module(env, asking_module, target_module);
+JVM_END
+
+JVM_ENTRY(jboolean, JVM_IsExportedToModule(JNIEnv *env, jobject from_module, jstring package, jobject to_module))
+  JVMWrapper("JVM_IsExportedToModule");
+  return Modules::is_exported_to_module(env, from_module, package, to_module);
+JVM_END
+
+JVM_ENTRY (void, JVM_AddModulePackage(JNIEnv *env, jobject module, jstring package))
+  JVMWrapper("JVM_AddModulePackage");
+  Modules::add_module_package(env, module, package);
+JVM_END
+
 
 // Reflection support //////////////////////////////////////////////////////////////////////////////
 
--- a/src/share/vm/prims/jvm.h	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/prims/jvm.h	Fri Mar 06 14:27:49 2015 -0800
@@ -390,6 +390,29 @@
                               jboolean verify);
 
 /*
+ * Module support funcions
+ */
+
+JNIEXPORT void JNICALL
+JVM_DefineModule(JNIEnv *env, jobject module, jstring version, jstring location,
+                 jobjectArray packages);
+
+JNIEXPORT void JNICALL
+JVM_AddModuleExports(JNIEnv *env, jobject from_module, jstring package, jobject to_module);
+
+JNIEXPORT void JNICALL
+JVM_AddReadsModule(JNIEnv *env, jobject from_module, jobject to_module);
+
+JNIEXPORT jboolean JNICALL
+JVM_CanReadModule(JNIEnv *env, jobject asking_module, jobject target_module);
+
+JNIEXPORT jboolean JNICALL
+JVM_IsExportedToModule(JNIEnv *env, jobject from_module, jstring package, jobject to_module);
+
+JNIEXPORT void JNICALL
+JVM_AddModulePackage(JNIEnv* env,  jobject module, jstring package);
+
+/*
  * Reflection support functions
  */
 
@@ -878,6 +901,7 @@
 #define JVM_ACC_SYNTHETIC     0x1000  /* compiler-generated class, method or field */
 #define JVM_ACC_ANNOTATION    0x2000  /* annotation type */
 #define JVM_ACC_ENUM          0x4000  /* field is declared as element of enum */
+#define JVM_ACC_MODULE        0x8000  /* module-info class file */
 
 #define JVM_ACC_PUBLIC_BIT        0
 #define JVM_ACC_PRIVATE_BIT       1
--- a/src/share/vm/prims/methodHandles.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/prims/methodHandles.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -1109,9 +1109,9 @@
     if (reference_klass != NULL && reference_klass->oop_is_instance()) {
       // Emulate LinkResolver::check_klass_accessability.
       Klass* caller = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(caller_jh));
-      if (!Reflection::verify_class_access(caller,
-                                           reference_klass,
-                                           true)) {
+      if (Reflection::verify_class_access(caller,
+                                          reference_klass,
+                                          true) != Reflection::ACCESS_OK) {
         THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), reference_klass->external_name());
       }
     }
--- a/src/share/vm/prims/whitebox.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/prims/whitebox.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -27,6 +27,8 @@
 #include <new>
 
 #include "classfile/classLoaderData.hpp"
+#include "classfile/modules.hpp"
+#include "classfile/imageFile.hpp"
 #include "classfile/stringTable.hpp"
 #include "code/codeCache.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
@@ -1088,6 +1090,32 @@
   MetadataFactory::free_array(cld, (Array<u1>*)(uintptr_t)addr);
 WB_END
 
+WB_ENTRY(void, WB_DefineModule(JNIEnv* env, jobject o, jobject module, jstring version, jstring location,
+                                jobjectArray packages))
+  Modules::define_module(env, module, version, location, packages);
+WB_END
+
+WB_ENTRY(void, WB_AddModuleExports(JNIEnv* env, jobject o, jobject from_module, jstring package, jobject to_module))
+  Modules::add_module_exports(env, from_module, package, to_module);
+WB_END
+
+WB_ENTRY(void, WB_AddReadsModule(JNIEnv* env, jobject o, jobject from_module, jobject to_module))
+  Modules::add_reads_module(env, from_module, to_module);
+WB_END
+
+WB_ENTRY(jboolean, WB_CanReadModule(JNIEnv* env, jobject o, jobject asking_module, jobject target_module))
+  return Modules::can_read_module(env, asking_module, target_module);
+WB_END
+
+WB_ENTRY(jboolean, WB_IsExportedToModule(JNIEnv* env, jobject o, jobject from_module, jstring package, jobject to_module))
+  return Modules::is_exported_to_module(env, from_module, package, to_module);
+WB_END
+
+WB_ENTRY(void, WB_AddModulePackage(JNIEnv* env, jobject o, jclass module, jstring package))
+  Modules::add_module_package(env, module, package);
+WB_END
+
+
 WB_ENTRY(jlong, WB_IncMetaspaceCapacityUntilGC(JNIEnv* env, jobject wb, jlong inc))
   if (inc < 0) {
     THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
@@ -1115,6 +1143,12 @@
   return (jlong) MetaspaceGC::capacity_until_GC();
 WB_END
 
+WB_ENTRY(jboolean, WB_ReadImageFile(JNIEnv* env, jobject wb, jstring imagefile))
+  const char* filename = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(imagefile));
+  ImageFile* image = new ImageFile(filename);
+  return image->open();
+WB_END
+
 WB_ENTRY(void, WB_AssertMatchingSafepointCalls(JNIEnv* env, jobject o, jboolean mutexSafepointValue, jboolean attemptedNoSafepointValue))
   Monitor::SafepointCheckRequired sfpt_check_required = mutexSafepointValue ?
                                            Monitor::_safepoint_check_always :
@@ -1330,6 +1364,19 @@
   {CC"getCodeBlob",        CC"(J)[Ljava/lang/Object;",(void*)&WB_GetCodeBlob        },
   {CC"getThreadStackSize", CC"()J",                   (void*)&WB_GetThreadStackSize },
   {CC"getThreadRemainingStackSize", CC"()J",          (void*)&WB_GetThreadRemainingStackSize },
+  {CC"DefineModule",       CC"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V",
+                                                      (void*)&WB_DefineModule },
+  {CC"AddModuleExports",   CC"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V",
+                                                      (void*)&WB_AddModuleExports },
+  {CC"AddReadsModule",     CC"(Ljava/lang/Object;Ljava/lang/Object;)V",
+                                                      (void*)&WB_AddReadsModule },
+  {CC"CanReadModule",      CC"(Ljava/lang/Object;Ljava/lang/Object;)Z",
+                                                      (void*)&WB_CanReadModule },
+  {CC"IsExportedToModule", CC"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Z",
+                                                      (void*)&WB_IsExportedToModule },
+  {CC"AddModulePackage",   CC"(Ljava/lang/Object;Ljava/lang/String;)V",
+                                                      (void*)&WB_AddModulePackage },
+  {CC"readImageFile",     CC"(Ljava/lang/String;)Z",  (void*)&WB_ReadImageFile },
   {CC"assertMatchingSafepointCalls", CC"(ZZ)V",       (void*)&WB_AssertMatchingSafepointCalls },
   {CC"isMonitorInflated",  CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated  },
   {CC"forceSafepoint",     CC"()V",                   (void*)&WB_ForceSafepoint     },
--- a/src/share/vm/runtime/arguments.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/arguments.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -86,6 +86,8 @@
 const char*  Arguments::_sun_java_launcher      = DEFAULT_JAVA_LAUNCHER;
 int    Arguments::_sun_java_launcher_pid        = -1;
 bool   Arguments::_sun_java_launcher_is_altjvm  = false;
+const char*  Arguments::_override_dir           = NULL;
+int    Arguments::_bootclasspath_a_index        = -1;
 
 // These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*)
 bool   Arguments::_AlwaysCompileLoopMethods     = AlwaysCompileLoopMethods;
@@ -389,7 +391,7 @@
   // Array indices for the items that make up the sysclasspath.  All except the
   // base are allocated in the C heap and freed by this class.
   enum {
-    _scp_prefix,        // from -Xbootclasspath/p:...
+    _scp_prefix,        // was -Xbootclasspath/p:...
     _scp_base,          // the default sysclasspath
     _scp_suffix,        // from -Xbootclasspath/a:...
     _scp_nitems         // the number of items, must be last.
@@ -457,6 +459,10 @@
   // Get the lengths.
   int i;
   for (i = 0; i < _scp_nitems; ++i) {
+    if (i == _scp_suffix) {
+      // Record index of boot loader's append path.
+      Arguments::set_bootclasspath_a_index((int)total_len);
+    }
     if (_items[i] != NULL) {
       lengths[i] = strlen(_items[i]);
       // Include space for the separator char (or a NULL for the last item).
@@ -2719,16 +2725,18 @@
       JavaAssertions::setSystemClassDefault(enable);
     // -bootclasspath:
     } else if (match_option(option, "-Xbootclasspath:", &tail)) {
-      scp_p->reset_path(tail);
-      *scp_assembly_required_p = true;
+        jio_fprintf(defaultStream::output_stream(),
+          "-Xbootclasspath is no longer a supported option.\n");
+        return JNI_EINVAL;
     // -bootclasspath/a:
     } else if (match_option(option, "-Xbootclasspath/a:", &tail)) {
       scp_p->add_suffix(tail);
       *scp_assembly_required_p = true;
     // -bootclasspath/p:
     } else if (match_option(option, "-Xbootclasspath/p:", &tail)) {
-      scp_p->add_prefix(tail);
-      *scp_assembly_required_p = true;
+        jio_fprintf(defaultStream::output_stream(),
+          "-Xbootclasspath/p is no longer a supported option.\n");
+        return JNI_EINVAL;
     // -Xrun
     } else if (match_option(option, "-Xrun", &tail)) {
       if (tail != NULL) {
@@ -3060,6 +3068,15 @@
       } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) {
         return JNI_EINVAL;
       }
+    // -Xoverride
+    } else if (match_option(option, "-Xoverride:", &tail)) {
+      size_t len = strlen(tail);
+      char* dir = NEW_C_HEAP_ARRAY(char, len+16, mtInternal);
+      sprintf(dir, "%s%sjava.base", tail, os::file_separator());
+      scp_p->add_prefix(dir);
+      *scp_assembly_required_p = true;
+      dir[len] = '\0';
+      set_override_dir(dir);
     // -Xdebug
     } else if (match_option(option, "-Xdebug")) {
       // note this flag has been used, then ignore
@@ -3462,6 +3479,11 @@
   if (scp_assembly_required) {
     // Assemble the bootclasspath elements into the final path.
     Arguments::set_sysclasspath(scp_p->combined_path());
+  } else {
+    // At this point in sysclasspath processing anything
+    // added would be considered in the boot loader's append path.
+    // Record this index, including +1 for the file separator character.
+    Arguments::set_bootclasspath_a_index(((int)strlen(Arguments::get_sysclasspath()))+1);
   }
 
   // This must be done after all arguments have been processed.
@@ -3624,6 +3646,11 @@
 
 void Arguments::set_shared_spaces_flags() {
   if (DumpSharedSpaces) {
+    if (Arguments::override_dir() != NULL) {
+      vm_exit_during_initialization(
+        "Cannot use -Xoverride when dumping the shared archive.", NULL);
+    }
+
     if (RequireSharedSpaces) {
       warning("cannot dump shared archive while using shared archive");
     }
--- a/src/share/vm/runtime/arguments.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/arguments.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -283,7 +283,7 @@
   // Value of the conservative maximum heap alignment needed
   static size_t  _conservative_max_heap_alignment;
 
-  static uintx _min_heap_size;
+  static uintx  _min_heap_size;
 
   // Used to store original flag values
   static uintx _min_heap_free_ratio;
@@ -312,6 +312,15 @@
   static void set_java_compiler(bool arg) { _java_compiler = arg; }
   static bool java_compiler()   { return _java_compiler; }
 
+  // Capture the index location of -Xbootclasspath\a within sysclasspath.
+  // Used when setting up the bootstrap search path in order to
+  // mark the boot loader's append path observability boundary.
+  static int _bootclasspath_a_index;
+
+  // -Xoverride flag
+  static const char* _override_dir;
+  static void set_override_dir(const char* dir) { _override_dir = dir; }
+
   // -Xdebug flag
   static bool _xdebug_mode;
   static void set_xdebug_mode(bool arg) { _xdebug_mode = arg; }
@@ -534,6 +543,13 @@
   static uintx min_heap_size()              { return _min_heap_size; }
   static void  set_min_heap_size(uintx v)   { _min_heap_size = v;  }
 
+  // -Xbootclasspath/a
+  static int  bootclasspath_a_index()              { return _bootclasspath_a_index; }
+  static void set_bootclasspath_a_index(int value) { _bootclasspath_a_index = value; }
+
+  // -Xoverride
+  static const char* override_dir()         { return _override_dir; }
+
   // Returns the original values of -XX:MinHeapFreeRatio and -XX:MaxHeapFreeRatio
   static uintx min_heap_free_ratio()        { return _min_heap_free_ratio; }
   static uintx max_heap_free_ratio()        { return _max_heap_free_ratio; }
@@ -606,7 +622,7 @@
 
 
   // Operation modi
-  static Mode mode()                { return _mode; }
+  static Mode mode()                        { return _mode; }
   static bool is_interpreter_only() { return mode() == _int; }
 
 
--- a/src/share/vm/runtime/globals.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/globals.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -1320,6 +1320,15 @@
           "Decay time (in milliseconds) to re-enable bulk rebiasing of a "  \
           "type after previous bulk rebias")                                \
                                                                             \
+  develop(bool, UseModuleBoundaries, true,                                  \
+          "Use access control to enforce module boundaries")                \
+                                                                            \
+  product(ccstr, AddModuleRequires, NULL,                                   \
+          "Additional module dependences, for example jtreg=java.xml")      \
+                                                                            \
+  product(ccstr, AddModuleExports, NULL,                                    \
+          "Additional module exports, for example java.base/sun.misc")      \
+                                                                            \
   /* tracing */                                                             \
                                                                             \
   notproduct(bool, TraceRuntimeCalls, false,                                \
@@ -1428,6 +1437,9 @@
   product(bool, TraceMonitorInflation, false,                               \
           "Trace monitor inflation in JVM")                                 \
                                                                             \
+  product(bool, TraceAccessControlErrors, false,                            \
+          "Trace access control errors")                                    \
+                                                                            \
   /* gc */                                                                  \
                                                                             \
   product(bool, UseSerialGC, false,                                         \
@@ -2342,6 +2354,12 @@
   develop(bool, TraceClassLoaderData, false,                                \
           "Trace class loader loader_data lifetime")                        \
                                                                             \
+  develop(bool, TraceModules, false,                                        \
+          "Trace module creation and lifetime")                             \
+                                                                            \
+  develop(bool, TracePackages, false,                                       \
+          "Trace package creation and lifetime")                            \
+                                                                            \
   product(uintx, InitialBootClassLoaderMetaspaceSize,                       \
           NOT_LP64(2200*K) LP64_ONLY(4*M),                                  \
           "Initial size of the boot class loader data metaspace")           \
--- a/src/share/vm/runtime/mutexLocker.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/mutexLocker.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -41,6 +41,7 @@
 Mutex*   Patching_lock                = NULL;
 Monitor* SystemDictionary_lock        = NULL;
 Mutex*   PackageTable_lock            = NULL;
+Mutex*   Module_lock                  = NULL;
 Mutex*   CompiledIC_lock              = NULL;
 Mutex*   InlineCacheBuffer_lock       = NULL;
 Mutex*   VMStatistic_lock             = NULL;
@@ -217,6 +218,7 @@
 
   def(SystemDictionary_lock        , Monitor, leaf,        true,  Monitor::_safepoint_check_always);     // lookups done by VM thread
   def(PackageTable_lock            , Mutex  , leaf,        false, Monitor::_safepoint_check_always);
+  def(Module_lock                  , Mutex  , nonleaf  ,   true,  Monitor::_safepoint_check_always);
   def(InlineCacheBuffer_lock       , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);
   def(VMStatistic_lock             , Mutex  , leaf,        false, Monitor::_safepoint_check_always);
   def(ExpandHeap_lock              , Mutex  , leaf,        true,  Monitor::_safepoint_check_always);     // Used during compilation by VM thread
--- a/src/share/vm/runtime/mutexLocker.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/mutexLocker.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -33,6 +33,7 @@
 extern Mutex*   Patching_lock;                   // a lock used to guard code patching of compiled code
 extern Monitor* SystemDictionary_lock;           // a lock on the system dictionary
 extern Mutex*   PackageTable_lock;               // a lock on the class loader package table
+extern Mutex*   Module_lock;                     // a lock on module related data structures
 extern Mutex*   CompiledIC_lock;                 // a lock used to guard compiled IC patching and access
 extern Mutex*   InlineCacheBuffer_lock;          // a lock used to guard the InlineCacheBuffer
 extern Mutex*   VMStatistic_lock;                // a lock used to guard statistics count increment
--- a/src/share/vm/runtime/os.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/os.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -1167,63 +1167,10 @@
     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);
 
-  char* sysclasspath = NULL;
   struct stat st;
 
   // modular image if bootmodules.jimage exists
@@ -1237,21 +1184,15 @@
   FREE_C_HEAP_ARRAY(char, jimage);
 
   // check if developer build with exploded modules
-  char* modules_dir = format_boot_path("%/modules", home, home_len, fileSep, pathSep);
-  if (os::stat(modules_dir, &st) == 0) {
-    if ((st.st_mode & S_IFDIR) == S_IFDIR) {
-      sysclasspath = expand_entries_to_path(modules_dir, fileSep, pathSep);
-    }
+  char* base_classes = format_boot_path("%/modules/java.base", home, home_len, fileSep, pathSep);
+  if (base_classes == NULL) return false;
+  if (os::stat(base_classes, &st) == 0) {
+    Arguments::set_sysclasspath(base_classes);
+    return true;
   }
+  FREE_C_HEAP_ARRAY(char, base_classes);
 
-  // fallback to classes
-  if (sysclasspath == NULL)
-    sysclasspath = format_boot_path("%/classes", home, home_len, fileSep, pathSep);
-
-  if (sysclasspath == NULL) return false;
-  Arguments::set_sysclasspath(sysclasspath);
-
-  return true;
+  return false;
 }
 
 /*
--- a/src/share/vm/runtime/os.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/os.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -977,7 +977,6 @@
                                 char pathSep);
   static bool set_boot_path(char fileSep, char pathSep);
   static char** split_path(const char* path, int* n);
-
 };
 
 // Note that "PAUSE" is almost always used with synchronization
--- a/src/share/vm/runtime/reflection.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/reflection.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -24,6 +24,8 @@
 
 #include "precompiled.hpp"
 #include "classfile/javaClasses.hpp"
+#include "classfile/moduleEntry.hpp"
+#include "classfile/packageEntry.hpp"
 #include "classfile/stringTable.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/verifier.hpp"
@@ -411,23 +413,192 @@
 }
 
 
-bool Reflection::verify_class_access(Klass* current_class, Klass* new_class, bool classloader_only) {
+
+/*
+    Type Accessibility check for public types: Callee Type T is accessible to Caller Type S if:
+
+                        Callee T in             Callee T in package PT,
+                        unnamed module          runtime module MT
+ ------------------------------------------------------------------------------------------------
+
+ Caller S in package         YES                  If same classloader/package (PS == PT): YES
+ PS, runtime module MS                            If same runtime module: (MS == MT): YES
+
+                                                  Else if (MS can read MT (Establish readability) &&
+                                                    MT exports PT to MS or to all modules): YES
+
+ ------------------------------------------------------------------------------------------------
+ Caller S in unnamed         YES                   Readability exists because unnamed module
+ module                                                "reads" all modules
+                                                   if (MT exports PT to all modules): YES
+
+ ------------------------------------------------------------------------------------------------
+*/
+Reflection::VerifyClassAccessResults Reflection::verify_class_access(
+  Klass* current_class, Klass* new_class, bool classloader_only) {
+
   // Verify that current_class can access new_class.  If the classloader_only
   // flag is set, we automatically allow any accesses in which current_class
   // doesn't have a classloader.
   if ((current_class == NULL) ||
       (current_class == new_class) ||
-      (new_class->is_public()) ||
       is_same_class_package(current_class, new_class)) {
-    return true;
+    return ACCESS_OK;
   }
   // Allow all accesses from sun/reflect/MagicAccessorImpl subclasses to
   // succeed trivially.
   if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
-    return true;
+    return ACCESS_OK;
   }
 
-  return can_relax_access_check_for(current_class, new_class, classloader_only);
+  // module boundaries
+  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 (!UseModuleBoundaries || DumpSharedSpaces) {
+      return ACCESS_OK;
+    }
+
+    // Find the module entry for current_class, the accessor
+    ModuleEntry* module_from = InstanceKlass::cast(current_class)->module();
+
+    // Find the module entry for new_class, the accessee
+    ModuleEntry* module_to = NULL;
+    if (new_class->oop_is_objArray()) {
+      new_class = ObjArrayKlass::cast(new_class)->bottom_klass();
+    }
+    if (current_class->oop_is_instance()) {
+      module_to = InstanceKlass::cast(new_class)->module();
+    }
+
+    // both in same module or unnamed module.
+    if (module_from == module_to)
+      return ACCESS_OK;
+
+    // Acceptable access to a type in the unamed module.
+    if (module_to == NULL)
+      return ACCESS_OK;
+
+    // Establish readability, check if module_from is allowed to read module_to.
+    if (module_from != NULL && !module_from->can_read(module_to)) {
+      if (TraceAccessControlErrors) {
+        ResourceMark rm;
+        tty->print_cr("Type in module %s (%s) cannot access type in module %s (%s), not readable",
+          module_from->name()->as_C_string(), current_class->external_name(),
+          module_to->name()->as_C_string(), new_class->external_name());
+      }
+      return MODULE_NOT_READABLE;
+    }
+
+    PackageEntry* package_to = InstanceKlass::cast(new_class)->package();
+    assert(package_to != NULL, "can not obtain new_class' package");
+
+    // Once readability is established, if module_to exports T unqualifiedly,
+    // (to all modules), than whether module_from is in the unnamed module
+    // or not does not matter, access is allowed.
+    if (package_to->is_unqual_exported()) {
+      return ACCESS_OK;
+    }
+
+    if (module_from != NULL) {
+      // Check the case where module_from, the requester, is in a named module.
+      // Access is allowed if both 1 & 2 hold:
+      //   1. Readability, module_from can read module_to (established above).
+      //   2. Either module_to exports T to module_from qualifiedly.
+      //      or
+      //      module_to exports T unqualifiedly to all modules (checked above).
+      bool okay = package_to->is_qexported_to(module_from);
+      if (!okay) {
+        if (TraceAccessControlErrors) {
+          ResourceMark rm;
+          tty->print_cr("Type in module %s (%s) cannot access type in module %s (%s), not exported",
+            module_from->name()->as_C_string(), current_class->external_name(),
+            module_to->name()->as_C_string(), new_class->external_name());
+        }
+        return TYPE_NOT_EXPORTED;
+      }
+      return ACCESS_OK;
+    } else {
+      // Check the case where module_from, the requester, is in the unnamed module.
+      // Access is allowed if both 1 & 2 hold:
+      //   1. Readability, unnamed module can read all modules.
+      //   2. module_to exports T unqualifiedly to all modules (checked above).
+      if (TraceAccessControlErrors) {
+        ResourceMark rm;
+        tty->print_cr("Type in the unnamed module (%s) cannot access type in module %s (%s), not unqualifiedly exported",
+          current_class->external_name(), module_to->name()->as_C_string(), new_class->external_name());
+      }
+      return TYPE_NOT_UNQ_EXPORTED;
+    }
+  }
+
+  if (can_relax_access_check_for(current_class, new_class, classloader_only)) {
+    return ACCESS_OK;
+  }
+  return OTHER_PROBLEM;
+}
+
+// Return an error message specific to the specified Klass*'s and result.
+// This function must be called from within a block containing a ResourceMark.
+char* Reflection::verify_class_access_msg(Klass* current_class,
+                                          Klass* new_class,
+                                          VerifyClassAccessResults result) {
+  assert(result != ACCESS_OK, "must be failure result");
+  char * msg = NULL;
+  if (result != OTHER_PROBLEM && new_class != NULL && current_class != NULL) {
+    ModuleEntry* module_to = InstanceKlass::cast(new_class)->module();
+    if (module_to != NULL) {
+      const char * new_class_name = new_class->external_name();
+      const char * current_class_name = current_class->external_name();
+      char * module_to_name = module_to->name()->as_C_string();
+      size_t len = 120 + strlen(current_class_name) + strlen(new_class_name) +
+        strlen(module_to_name);
+
+      if (result == TYPE_NOT_UNQ_EXPORTED) {
+        if (InstanceKlass::cast(new_class)->package() != NULL) {
+          const char * package_name =
+            InstanceKlass::cast(new_class)->package()->name()->as_klass_external_name();
+          len = len + strlen(package_name);
+          msg = NEW_RESOURCE_ARRAY(char, len);
+          jio_snprintf(msg, len - 1,
+            "class %s (in module: unnamed) cannot access class %s (in module: %s), %s is not exported to the unnamed module",
+            current_class_name, new_class_name, module_to_name, package_name);
+        }
+
+      } else {
+        ModuleEntry* module_from = InstanceKlass::cast(current_class)->module();
+        if (module_from != NULL) {
+          char * module_from_name = module_from->name()->as_C_string();
+          len = len + 2 * strlen(module_from_name);
+
+          if (result == MODULE_NOT_READABLE) {
+            len = len + strlen(module_to_name);
+            msg = NEW_RESOURCE_ARRAY(char, len);
+            jio_snprintf(msg, len - 1,
+              "class %s (in module: %s) cannot access class %s (in module: %s), %s cannot read %s",
+              current_class_name, module_from_name, new_class_name,
+              module_to_name, module_from_name, module_to_name);
+
+          } else if (result == TYPE_NOT_EXPORTED) {
+            if (InstanceKlass::cast(new_class)->package() != NULL) {
+              const char * package_name =
+                InstanceKlass::cast(new_class)->package()->name()->as_klass_external_name();
+              len = len + strlen(package_name);
+              msg = NEW_RESOURCE_ARRAY(char, len);
+              jio_snprintf(msg, len - 1,
+                "class %s (in module: %s) cannot access class %s (in module: %s), %s is not exported to %s",
+                current_class_name, module_from_name, new_class_name,
+                module_to_name, package_name, module_from_name);
+            }
+
+          } else {
+            ShouldNotReachHere();
+          }
+        }  // module_from != NULL
+      }
+    }  // module_to != NULL
+  }  // result != OTHER_PROBLEM...
+  return msg;
 }
 
 static bool under_host_klass(InstanceKlass* ik, Klass* host_klass) {
--- a/src/share/vm/runtime/reflection.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/reflection.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -63,6 +63,15 @@
     MAX_DIM           = 255
   };
 
+  // Results returned by verify_class_access()
+  enum VerifyClassAccessResults {
+    ACCESS_OK = 0,
+    MODULE_NOT_READABLE = 1,
+    TYPE_NOT_EXPORTED = 2,
+    TYPE_NOT_UNQ_EXPORTED = 3,
+    OTHER_PROBLEM = 4
+  };
+
   // Boxing. Returns boxed value of appropriate type. Throws IllegalArgumentException.
   static oop box(jvalue* v, BasicType type, TRAPS);
   // Unboxing. Returns type code and sets value.
@@ -83,7 +92,15 @@
   static arrayOop reflect_new_multi_array(oop element_mirror, typeArrayOop dimensions, TRAPS);
 
   // Verification
-  static bool     verify_class_access(Klass* current_class, Klass* new_class, bool classloader_only);
+  static VerifyClassAccessResults verify_class_access(Klass* current_class,
+                                                      Klass* new_class,
+                                                      bool classloader_only);
+
+  // Return an error message specific to the specified Klass*'s and result.
+  // This function must be called from within a block containing a ResourceMark.
+  static char*    verify_class_access_msg(Klass* current_class,
+                                          Klass* new_class,
+                                          VerifyClassAccessResults result);
 
   static bool     verify_field_access(Klass* current_class,
                                       Klass* resolved_class,
--- a/src/share/vm/runtime/sharedRuntime.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/sharedRuntime.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -37,6 +37,8 @@
 #include "interpreter/interpreterRuntime.hpp"
 #include "memory/gcLocker.inline.hpp"
 #include "memory/universe.inline.hpp"
+#include "oops/klass.hpp"
+#include "oops/objArrayKlass.hpp"
 #include "oops/oop.inline.hpp"
 #include "prims/forte.hpp"
 #include "prims/jvmtiExport.hpp"
@@ -1760,28 +1762,57 @@
 }
 JRT_END
 
+// The caller of generate_class_cast_message() (or one of its callers)
+// must use a ResourceMark in order to correctly free the result.
 char* SharedRuntime::generate_class_cast_message(
-    JavaThread* thread, const char* objName) {
+    JavaThread* thread, Klass* caster_klass) {
 
   // Get target class name from the checkcast instruction
   vframeStream vfst(thread, true);
   assert(!vfst.at_end(), "Java frame must exist");
   Bytecode_checkcast cc(vfst.method(), vfst.method()->bcp_from(vfst.bci()));
-  Klass* targetKlass = vfst.method()->constants()->klass_at(
+  Klass* target_klass = vfst.method()->constants()->klass_at(
     cc.index(), thread);
-  return generate_class_cast_message(objName, targetKlass->external_name());
+  return generate_class_cast_message(caster_klass, target_klass);
 }
 
 char* SharedRuntime::generate_class_cast_message(
-    const char* objName, const char* targetKlassName, const char* desc) {
-  size_t msglen = strlen(objName) + strlen(desc) + strlen(targetKlassName) + 1;
+    Klass* caster_klass, Klass* target_klass) {
+
+  const char* caster_klass_name = caster_klass->external_name();
+  Klass* c_klass = caster_klass->oop_is_objArray() ?
+    ObjArrayKlass::cast(caster_klass)->bottom_klass() : caster_klass;
+  ModuleEntry* caster_module;
+  if (c_klass->oop_is_instance()) {
+    caster_module = InstanceKlass::cast(c_klass)->module();
+  } else {
+    caster_module = NULL;
+  }
+  const char* caster_module_name = caster_module == NULL ? "unnamed" :
+    caster_module->name()->as_C_string();
+
+  const char* target_klass_name = target_klass->external_name();
+  Klass* t_klass = target_klass->oop_is_objArray() ?
+    ObjArrayKlass::cast(target_klass)->bottom_klass() : target_klass;
+  ModuleEntry* target_module;
+  if (t_klass->oop_is_instance()) {
+    target_module = InstanceKlass::cast(t_klass)->module();
+  } else {
+    target_module = NULL;
+  }
+  const char* target_module_name = target_module == NULL ? "unnamed" :
+    target_module->name()->as_C_string();
+
+  size_t msglen = strlen(caster_klass_name) + strlen(caster_module_name) +
+     strlen(target_klass_name) + strlen(target_module_name) + 50;
 
   char* message = NEW_RESOURCE_ARRAY(char, msglen);
   if (NULL == message) {
     // Shouldn't happen, but don't cause even more problems if it does
-    message = const_cast<char*>(objName);
+    message = const_cast<char*>(caster_klass_name);
   } else {
-    jio_snprintf(message, msglen, "%s%s%s", objName, desc, targetKlassName);
+    jio_snprintf(message, msglen, "%s (in module: %s) cannot be cast to %s (in module: %s)",
+      caster_klass_name, caster_module_name, target_klass_name, target_module_name);
   }
   return message;
 }
--- a/src/share/vm/runtime/sharedRuntime.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/sharedRuntime.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -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
@@ -274,22 +274,21 @@
   // Fill in the "X cannot be cast to a Y" message for ClassCastException
   //
   // @param thr the current thread
-  // @param name the name of the class of the object attempted to be cast
+  // @param caster_klass the class of the object we are casting
   // @return the dynamically allocated exception message (must be freed
   // by the caller using a resource mark)
   //
   // BCP must refer to the current 'checkcast' opcode for the frame
   // on top of the stack.
-  // The caller (or one of it's callers) must use a ResourceMark
+  // The caller (or one of its callers) must use a ResourceMark
   // in order to correctly free the result.
   //
-  static char* generate_class_cast_message(JavaThread* thr, const char* name);
+  static char* generate_class_cast_message(JavaThread* thr, Klass* caster_klass);
 
   // Fill in the "X cannot be cast to a Y" message for ClassCastException
   //
-  // @param name the name of the class of the object attempted to be cast
-  // @param klass the name of the target klass attempt
-  // @param gripe the specific kind of problem being reported
+  // @param caster_klass the class of the object we are casting
+  // @param target_klass the target klass attempt
   // @return the dynamically allocated exception message (must be freed
   // by the caller using a resource mark)
   //
@@ -298,8 +297,7 @@
   // The caller (or one of it's callers) must use a ResourceMark
   // in order to correctly free the result.
   //
-  static char* generate_class_cast_message(const char* name, const char* klass,
-                                           const char* gripe = " cannot be cast to ");
+  static char* generate_class_cast_message(Klass* caster_klass, Klass* target_klass);
 
   // Resolves a call site- may patch in the destination of the call into the
   // compiled code.
--- a/src/share/vm/runtime/thread.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/thread.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "classfile/classLoader.hpp"
 #include "classfile/javaClasses.hpp"
+#include "classfile/moduleEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "code/codeCache.hpp"
@@ -105,6 +106,9 @@
 #include "runtime/rtmLocking.hpp"
 #endif
 
+// Initialization after module runtime initialization
+void universe_post_module_init();  // must happen after call_initPhase2
+
 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
 
 #ifdef DTRACE_ENABLED
@@ -982,15 +986,6 @@
   return thread_oop();
 }
 
-static void call_initializeSystemClass(TRAPS) {
-  Klass* k =  SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
-  instanceKlassHandle klass (THREAD, k);
-
-  JavaValue result(T_VOID);
-  JavaCalls::call_static(&result, klass, vmSymbols::initializeSystemClass_name(),
-                         vmSymbols::void_method_signature(), CHECK);
-}
-
 char java_runtime_name[128] = "";
 char java_runtime_version[128] = "";
 
@@ -3211,6 +3206,33 @@
   // If CompilerThreads ever become non-JavaThreads, add them here
 }
 
+static void call_initPhase1(TRAPS) {
+  Klass* k =  SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
+  instanceKlassHandle klass (THREAD, k);
+
+  JavaValue result(T_VOID);
+  JavaCalls::call_static(&result, klass, vmSymbols::initPhase1_name(),
+                                         vmSymbols::void_method_signature(), CHECK);
+}
+
+static void call_initPhase2(TRAPS) {
+  Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
+  instanceKlassHandle klass (THREAD, k);
+
+  JavaValue result(T_VOID);
+  JavaCalls::call_static(&result, klass, vmSymbols::initPhase2_name(),
+                                         vmSymbols::void_method_signature(), CHECK);
+  universe_post_module_init();
+}
+
+static void call_initPhase3(TRAPS) {
+  Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
+  instanceKlassHandle klass (THREAD, k);
+
+  JavaValue result(T_VOID);
+  JavaCalls::call_static(&result, klass, vmSymbols::initPhase3_name(),
+                                         vmSymbols::void_method_signature(), CHECK);
+}
 
 void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
   TraceTime timer("Initialize java.lang classes", TraceStartupTime);
@@ -3237,10 +3259,13 @@
   // The VM creates & returns objects of this class. Make sure it's initialized.
   initialize_class(vmSymbols::java_lang_Class(), CHECK);
 
+  // The VM creates objects of this class.
+  initialize_class(vmSymbols::java_lang_reflect_Module(), CHECK);
+
   // The VM preresolves methods to these classes. Make sure that they get initialized
   initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK);
   initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK);
-  call_initializeSystemClass(CHECK);
+  call_initPhase1(CHECK);
 
   // get the Java runtime name after java.lang.System is initialized
   JDK_Version::set_runtime_name(get_java_runtime_name(THREAD));
@@ -3437,6 +3462,10 @@
 
   initialize_java_lang_classes(main_thread, CHECK_JNI_ERR);
 
+  // Create and patch the java.lang.reflect.Module entry for module java.base
+  // into existing classes.
+  ModuleEntryTable::patch_javabase_entries(CHECK_JNI_ERR);
+
   // We need this for ClassDataSharing - the initial vm.info property is set
   // with the default value of CDS "sharing" which may be reset through
   // command line options.
@@ -3462,12 +3491,9 @@
   Management::record_vm_init_completed();
 #endif // INCLUDE_MANAGEMENT
 
-  // Compute system loader. Note that this has to occur after set_init_completed, since
-  // valid exceptions may be thrown in the process.
   // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and
   // set_init_completed has just been called, causing exceptions not to be shortcut
   // anymore. We call vm_exit_during_initialization directly instead.
-  SystemDictionary::compute_java_system_loader(CHECK_JNI_ERR);
 
 #if INCLUDE_ALL_GCS
   // Support for ConcurrentMarkSweep. This should be cleaned up
@@ -3504,13 +3530,6 @@
     create_vm_init_libraries();
   }
 
-  // Notify JVMTI agents that VM initialization is complete - nop if no agents.
-  JvmtiExport::post_vm_initialized();
-
-  if (TRACE_START() != JNI_OK) {
-    vm_exit_during_initialization("Failed to start tracing backend.");
-  }
-
   if (CleanChunkPoolAsync) {
     Chunk::start_chunk_pool_cleaner_task();
   }
@@ -3526,6 +3545,53 @@
   // (see SystemDictionary::find_method_handle_intrinsic).
   initialize_jsr292_core_classes(CHECK_JNI_ERR);
 
+  // The system initialization in the library has three phases
+  // Phase 1: java.lang.System class initialization
+  //     java.lang.System is a primordial class loaded and initialized
+  //     by the VM early during startup.  java.lang.System.<clinit>
+  //     only does registerNatives and keep the rest of the class
+  //     initialization work later until thread initialization completes.
+  //
+  //     System.initPhase1 initializes the system properties, the static
+  //     fields in, out, and err. Setup java signal handlers, OS-specific
+  //     system settings, and set thread group of the main thread.
+  //
+  //     see initialize_java_lang_classes
+  //
+  // Phase 2. Module system initialization
+  //     This will initialize the module system.  Only java.base classes
+  //     can be loaded until phase 2 completes.
+  //
+  //     Call System.initPhase2 after the compiler initialization and jsr292
+  //     classes get initialized because module initialization runs a lot of java
+  //     code, that for performance reasons, should be compiled.  Also, this will
+  //     enable the startup code to use lambda and other language features in this
+  //     phase and onward.
+  //
+  //     After phase 2, The VM will begin search classes from -Xbootclasspath/a.
+  //
+  // Phase 3. final setup - set security manager, system class loader and TCCL
+  //
+  //     This will instantiate and set the security manager, set the system class
+  //     loader as well as the thread context class loader.  The security manager
+  //     and system class loader may be a custom class loaded from -Xbootclasspath/a,
+  //     other modules or the application's classpath.
+
+  call_initPhase2(CHECK_JNI_ERR);
+
+  // Final system initialization including security manager and system class loader.
+  call_initPhase3(CHECK_JNI_ERR);
+
+  // cache the system class loader
+  SystemDictionary::compute_java_system_loader(CHECK_JNI_ERR);
+
+  if (TRACE_START() != JNI_OK) {
+    vm_exit_during_initialization("Failed to start tracing backend.");
+  }
+
+  // Notify JVMTI agents that VM initialization is complete - nop if no agents.
+  JvmtiExport::post_vm_initialized();
+
 #if INCLUDE_MANAGEMENT
   Management::initialize(THREAD);
 
--- a/src/share/vm/runtime/vmStructs.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/runtime/vmStructs.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -1275,6 +1275,7 @@
   static_field(java_lang_Class,                _array_klass_offset,                           int)                                   \
   static_field(java_lang_Class,                _oop_size_offset,                              int)                                   \
   static_field(java_lang_Class,                _static_oop_field_count_offset,                int)                                   \
+  static_field(java_lang_Class,                _module_offset,                                int)                                   \
                                                                                                                                      \
   /************************/                                                                                                         \
   /* Miscellaneous fields */                                                                                                         \
--- a/src/share/vm/trace/traceDataTypes.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/trace/traceDataTypes.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -58,12 +58,11 @@
 
 typedef enum ReservedEvent ReservedEvent;
 
-typedef u8 classid;
-typedef u8 stacktraceid;
-typedef u8 methodid;
-typedef u8 fieldid;
+typedef u8 traceid;
 
+class ModuleEntry;
+class PackageEntry;
 class TraceUnicodeString;
+class Symbol;
 
 #endif // SHARE_VM_TRACE_TRACEDATATYPES_HPP
-
--- a/src/share/vm/trace/traceMacros.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/trace/traceMacros.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -28,16 +28,18 @@
 #define EVENT_THREAD_EXIT(thread)
 #define EVENT_THREAD_DESTRUCT(thread)
 
-#define TRACE_INIT_ID(k)
+#define TRACE_INIT_KLASS_ID(k)
+#define TRACE_INIT_MODULE_ID(m)
+#define TRACE_INIT_PACKAGE_ID(p)
 #define TRACE_DATA TraceThreadData
 
 #define TRACE_START() JNI_OK
 #define TRACE_INITIALIZE() JNI_OK
 
-#define TRACE_DEFINE_KLASS_METHODS typedef int ___IGNORED_hs_trace_type1
-#define TRACE_DEFINE_KLASS_TRACE_ID typedef int ___IGNORED_hs_trace_type2
-#define TRACE_DEFINE_OFFSET typedef int ___IGNORED_hs_trace_type3
-#define TRACE_ID_OFFSET in_ByteSize(0); ShouldNotReachHere()
+#define TRACE_DEFINE_TRACE_ID_METHODS typedef int ___IGNORED_hs_trace_type1
+#define TRACE_DEFINE_TRACE_ID_FIELD typedef int ___IGNORED_hs_trace_type2
+#define TRACE_DEFINE_KLASS_TRACE_ID_OFFSET typedef int ___IGNORED_hs_trace_type3
+#define TRACE_KLASS_TRACE_ID_OFFSET in_ByteSize(0); ShouldNotReachHere()
 #define TRACE_TEMPLATES(template)
 #define TRACE_INTRINSICS(do_intrinsic, do_class, do_name, do_signature, do_alias)
 
--- a/src/share/vm/trace/traceTypes.xsl	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/trace/traceTypes.xsl	Fri Mar 06 14:27:49 2015 -0800
@@ -32,7 +32,6 @@
 #ifndef TRACEFILES_TRACETYPES_HPP
 #define TRACEFILES_TRACETYPES_HPP
 
-#include "oops/symbol.hpp"
 #include "trace/traceDataTypes.hpp"
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/ticks.hpp"
--- a/src/share/vm/trace/tracetypes.xml	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/trace/tracetypes.xml	Fri Mar 06 14:27:49 2015 -0800
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
- Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2012, 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
@@ -89,6 +89,7 @@
                   type="U8" builtin_type="CLASS">
       <value type="CLASS" field="loaderClass" label="ClassLoader"/>
       <value type="SYMBOL" field="name" label="Name"/>
+      <value type="PACKAGE" field="package" label="Package"/>
       <value type="SHORT" field="modifiers" label="Access modifiers"/>
     </content_type>
 
@@ -176,6 +177,20 @@
       <value type="UTF8" field="type" label="type" />
     </content_type>
 
+    <content_type id="Module" hr_name="Module"
+              type="U8" jvm_type="MODULE">
+      <value type="SYMBOL" field="name" label="Name"/>
+      <value type="SYMBOL" field="version" label="Version"/>
+      <value type="SYMBOL" field="location" label="Location"/>
+      <value type="CLASS" field="classLoader" label="ClassLoader"/>
+    </content_type>
+
+    <content_type id="Package" hr_name="Package"
+              type="U8" jvm_type="PACKAGE">
+      <value type="SYMBOL" field="name" label="Name"/>
+      <value type="MODULE" field="module" label="Module"/>
+      <value type="BOOLEAN" field="exported" label="Exported"/>
+    </content_type>
   </content_types>
 
 
@@ -292,6 +307,12 @@
     <primary_type symbol="CLASS" datatype="U8" contenttype="CLASS"
                   type="Klass *" sizeop="sizeof(u8)"/>
 
+    <primary_type symbol="MODULE" datatype="U8" contenttype="MODULE"
+                  type="const ModuleEntry *" sizeop="sizeof(u8)"/>
+
+    <primary_type symbol="PACKAGE" datatype="U8" contenttype="PACKAGE"
+              type="const PackageEntry *" sizeop="sizeof(u8)"/>
+
     <!-- A Method *. The method is marked as "used" and will eventually be
          written into the recording constant pool. -->
     <primary_type symbol="METHOD" datatype="U8" contenttype="METHOD"
--- a/src/share/vm/utilities/dtrace_disabled.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/utilities/dtrace_disabled.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -1084,6 +1084,12 @@
 #define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN(arg0)
 #define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN_ENABLED()  0
 
+/* Modules */
+#define HOTSPOT_JNI_GETMODULE_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_GETMODULE_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETMODULE_RETURN(arg0)
+#define HOTSPOT_JNI_GETMODULE_RETURN_ENABLED()
+
 #else /* !defined(DTRACE_ENABLED) */
 #error This file should only be included when dtrace is not enabled
 #endif /* !defined(DTRACE_ENABLED) */
--- a/src/share/vm/utilities/hashtable.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/utilities/hashtable.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -151,7 +151,7 @@
   void copy_table(char** top, char* end);
 
   // Bucket handling
-  int hash_to_index(unsigned int full_hash) {
+  int hash_to_index(unsigned int full_hash) const {
     int h = full_hash % _table_size;
     assert(h >= 0 && h < _table_size, "Illegal hash value");
     return h;
--- a/src/share/vm/utilities/utf8.cpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/utilities/utf8.cpp	Fri Mar 06 14:27:49 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -306,6 +306,68 @@
                  + ((str[4] & 0x0f) << 6)  + (str[5] & 0x3f);
 }
 
+bool UTF8::is_legal_utf8(const unsigned char* buffer, int length,
+                         bool version_leq_47) {
+  int i = 0;
+  int count = length >> 2;
+  for (int k=0; k<count; k++) {
+    unsigned char b0 = buffer[i];
+    unsigned char b1 = buffer[i+1];
+    unsigned char b2 = buffer[i+2];
+    unsigned char b3 = buffer[i+3];
+    // For an unsigned char v,
+    // (v | v - 1) is < 128 (highest bit 0) for 0 < v < 128;
+    // (v | v - 1) is >= 128 (highest bit 1) for v == 0 or v >= 128.
+    unsigned char res = b0 | b0 - 1 |
+                        b1 | b1 - 1 |
+                        b2 | b2 - 1 |
+                        b3 | b3 - 1;
+    if (res >= 128) break;
+    i += 4;
+  }
+  for(; i < length; i++) {
+    unsigned short c;
+    // no embedded zeros
+    if (buffer[i] == 0) return false;
+    if(buffer[i] < 128) {
+      continue;
+    }
+    if ((i + 5) < length) { // see if it's legal supplementary character
+      if (UTF8::is_supplementary_character(&buffer[i])) {
+        c = UTF8::get_supplementary_character(&buffer[i]);
+        i += 5;
+        continue;
+      }
+    }
+    switch (buffer[i] >> 4) {
+      default: break;
+      case 0x8: case 0x9: case 0xA: case 0xB: case 0xF:
+        return false;
+      case 0xC: case 0xD:  // 110xxxxx  10xxxxxx
+        c = (buffer[i] & 0x1F) << 6;
+        i++;
+        if ((i < length) && ((buffer[i] & 0xC0) == 0x80)) {
+          c += buffer[i] & 0x3F;
+          if (version_leq_47 || c == 0 || c >= 0x80) {
+            break;
+          }
+        }
+        return false;
+      case 0xE:  // 1110xxxx 10xxxxxx 10xxxxxx
+        c = (buffer[i] & 0xF) << 12;
+        i += 2;
+        if ((i < length) && ((buffer[i-1] & 0xC0) == 0x80) && ((buffer[i] & 0xC0) == 0x80)) {
+          c += ((buffer[i-1] & 0x3F) << 6) + (buffer[i] & 0x3F);
+          if (version_leq_47 || c >= 0x800) {
+            break;
+          }
+        }
+        return false;
+    }  // end of switch
+  } // end of for
+  return true;
+}
+
 
 //-------------------------------------------------------------------------------------
 
--- a/src/share/vm/utilities/utf8.hpp	Thu Mar 05 15:21:35 2015 -0800
+++ b/src/share/vm/utilities/utf8.hpp	Fri Mar 06 14:27:49 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -65,6 +65,9 @@
   static bool   equal(const jbyte* base1, int length1, const jbyte* base2,int length2);
   static bool   is_supplementary_character(const unsigned char* str);
   static jint   get_supplementary_character(const unsigned char* str);
+
+  static bool   is_legal_utf8(const unsigned char* buffer, int length,
+                              bool version_leq_47);
 };
 
 
--- a/test/compiler/c1/6932496/Test6932496.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/c1/6932496/Test6932496.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @test
  * @bug 6932496
  * @summary incorrect deopt of jsr subroutine on 64 bit c1
- * @run main/othervm -Xcomp -XX:CompileOnly=Test.test Test6932496
+ * @run main/othervm -Xcomp -XX:CompileOnly=Test.test -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm Test6932496
  */
 import java.lang.reflect.Method;
 import java.nio.file.Files;
--- a/test/compiler/c2/5057225/Test5057225.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/c2/5057225/Test5057225.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 5057225
  * @summary Remove useless I2L conversions
- *
+ * @ignore 8072369
  * @run main/othervm -Xcomp -XX:CompileOnly=Test5057225.doload Test5057225
  */
 
--- a/test/compiler/c2/6800154/Test6800154.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/c2/6800154/Test6800154.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 6800154
  * @summary Add comments to long_by_long_mulhi() for better understandability
- *
+ * @ignore 8072369
  * @run main/othervm -Xcomp -XX:CompileOnly=Test6800154.divcomp Test6800154
  */
 
--- a/test/compiler/c2/6805724/Test6805724.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/c2/6805724/Test6805724.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 6805724
  * @summary ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
- *
+ * @ignore 8072369
  * @run main/othervm -Xcomp -XX:CompileOnly=Test6805724.fcomp Test6805724
  */
 
--- a/test/compiler/c2/6852078/Test6852078.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/c2/6852078/Test6852078.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,7 +27,7 @@
  * @bug 6852078
  * @summary Disable SuperWord optimization for unsafe read/write
  *
- * @run main Test6852078
+ * @run main/othervm -XX:AddModuleExports=java.corba/com.sun.corba.se.impl.encoding,java.corba/com.sun.jndi.toolkit.corba Test6852078
  */
 
 import java.util.*;
--- a/test/compiler/c2/6968348/Test6968348.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/c2/6968348/Test6968348.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,7 +27,7 @@
  * @bug 6968348
  * @summary Byteswapped memory access can point to wrong location after JIT
  *
- * @run main Test6968348
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc Test6968348
  */
 
 import sun.misc.Unsafe;
--- a/test/compiler/c2/7190310/Test7190310_unsafe.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/c2/7190310/Test7190310_unsafe.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @test
  * @bug 7190310
  * @summary Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
- * @run main/othervm -Xbatch Test7190310_unsafe
+ * @run main/othervm -Xbatch -XX:AddModuleExports=java.base/sun.misc Test7190310_unsafe
  */
 
 import java.lang.ref.*;
--- a/test/compiler/c2/8004867/TestIntUnsafeCAS.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/c2/8004867/TestIntUnsafeCAS.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,8 +27,8 @@
  * @bug 8004867
  * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
  *
- * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeCAS
- * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeCAS
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill -XX:AddModuleExports=java.base/sun.misc TestIntUnsafeCAS
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill -XX:AddModuleExports=java.base/sun.misc TestIntUnsafeCAS
  */
 
 import sun.misc.Unsafe;
--- a/test/compiler/c2/8004867/TestIntUnsafeOrdered.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/c2/8004867/TestIntUnsafeOrdered.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,8 +27,8 @@
  * @bug 8004867
  * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
  *
- * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeOrdered
- * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeOrdered
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill -XX:AddModuleExports=java.base/sun.misc TestIntUnsafeOrdered
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill -XX:AddModuleExports=java.base/sun.misc TestIntUnsafeOrdered
  */
 
 import sun.misc.Unsafe;
--- a/test/compiler/c2/8004867/TestIntUnsafeVolatile.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/c2/8004867/TestIntUnsafeVolatile.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,8 +27,8 @@
  * @bug 8004867
  * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
  *
- * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeVolatile
- * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeVolatile
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill -XX:AddModuleExports=java.base/sun.misc TestIntUnsafeVolatile
+ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill -XX:AddModuleExports=java.base/sun.misc TestIntUnsafeVolatile
  */
 
 import sun.misc.Unsafe;
--- a/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java	Fri Mar 06 14:27:49 2015 -0800
@@ -38,7 +38,7 @@
  * @run main ClassFileInstaller TestAnonymousClassUnloading
  *                              sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-BackgroundCompilation TestAnonymousClassUnloading
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-BackgroundCompilation -XX:AddModuleExports=java.base/sun.misc TestAnonymousClassUnloading
  */
 public class TestAnonymousClassUnloading {
     private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
--- a/test/compiler/codegen/6823354/Test6823354.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/codegen/6823354/Test6823354.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 6823354
  * @summary These methods can be instrinsified by using bit scan, bit test, and population count instructions.
- *
+ * @ignore 8072369
  * @run main/othervm -Xcomp -XX:CompileOnly=Test6823354.lzcomp,Test6823354.tzcomp,.dolzcomp,.dotzcomp Test6823354
  */
 
--- a/test/compiler/codegen/6896617/Test6896617.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/codegen/6896617/Test6896617.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @bug 6896617
  * @summary Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() with SSE instructions on x86
  * @library /testlibrary
- * @run main/othervm/timeout=1200 -Xbatch -Xmx256m Test6896617
+ * @run main/othervm/timeout=1200 -Xbatch -Xmx256m -XX:AddModuleExports=java.base/sun.nio.cs Test6896617
  *
  */
 
--- a/test/compiler/codegen/8011901/Test8011901.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/codegen/8011901/Test8011901.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8011901
  * @summary instruct xaddL_no_res shouldn't allow 64 bit constants.
- * @run main/othervm -XX:-BackgroundCompilation Test8011901
+ * @run main/othervm -XX:-BackgroundCompilation -XX:AddModuleExports=java.base/sun.misc Test8011901
  *
  */
 
--- a/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java	Fri Mar 06 14:27:49 2015 -0800
@@ -32,6 +32,7 @@
  * @bug 8050079
  * @summary Compiles a monomorphic call to finalizeObject() on a modified java.lang.Object to test C1 CHA.
  * @library /testlibrary
+ * @ignore 8072370
  * @compile -XDignore.symbol.file java/lang/Object.java TestMonomorphicObjectCall.java
  * @run main TestMonomorphicObjectCall
  */
--- a/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8038048
  * @summary assert(null_obj->escape_state() == PointsToNode::NoEscape,etc)
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+DoEscapeAnalysis -XX:-TieredCompilation -Xbatch TestUnsafePutAddressNullObjMustNotEscape
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+DoEscapeAnalysis -XX:-TieredCompilation -Xbatch -XX:AddModuleExports=java.base/sun.misc TestUnsafePutAddressNullObjMustNotEscape
  * @author Richard Reingruber richard DOT reingruber AT sap DOT com
  */
 
--- a/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 6653795
  * @summary C2 intrinsic for Unsafe.getAddress performs pointer sign extension on 32-bit systems
- * @run main UnsafeGetAddressTest
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc UnsafeGetAddressTest
  *
  */
 
--- a/test/compiler/jsr292/CreatesInterfaceDotEqualsCallInfo.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/jsr292/CreatesInterfaceDotEqualsCallInfo.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,8 +26,8 @@
  * @test
  * @bug 8026124
  * @summary Javascript file provoked assertion failure in linkResolver.cpp
- *
- * @run main/othervm CreatesInterfaceDotEqualsCallInfo
+ * @ignore 8072479
+ * @run main/othervm -XX:AddModuleExports=jdk.scripting.nashorn/jdk.nashorn.tools CreatesInterfaceDotEqualsCallInfo
  */
 
 public class CreatesInterfaceDotEqualsCallInfo {
--- a/test/compiler/jsr292/VMAnonymousClasses.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/jsr292/VMAnonymousClasses.java	Fri Mar 06 14:27:49 2015 -0800
@@ -24,7 +24,7 @@
 /**
  * @test
  * @bug 8058828
- * @run main/bootclasspath -Xbatch VMAnonymousClasses
+ * @run main/bootclasspath -Xbatch -XX:AddModuleExports=java.base/sun.misc,java.base/jdk.internal.org.objectweb.asm VMAnonymousClasses
  */
 
 import jdk.internal.org.objectweb.asm.ClassWriter;
--- a/test/compiler/jsr292/methodHandleExceptions/TestAMEnotNPE.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/jsr292/methodHandleExceptions/TestAMEnotNPE.java	Fri Mar 06 14:27:49 2015 -0800
@@ -37,9 +37,9 @@
  *
  * @compile -XDignore.symbol.file TestAMEnotNPE.java ByteClassLoader.java p/C.java p/Dok.java p/E.java p/F.java p/I.java p/Tdirect.java p/Treflect.java
  *
- * @run main/othervm TestAMEnotNPE
- * @run main/othervm -Xint TestAMEnotNPE
- * @run main/othervm -Xcomp TestAMEnotNPE
+ * @run main/othervm -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm TestAMEnotNPE
+ * @run main/othervm -Xint -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm TestAMEnotNPE
+ * @run main/othervm -Xcomp -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm TestAMEnotNPE
  */
 public class TestAMEnotNPE implements Opcodes {
 
--- a/test/compiler/osr/TestOSRWithNonEmptyStack.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/osr/TestOSRWithNonEmptyStack.java	Fri Mar 06 14:27:49 2015 -0800
@@ -34,7 +34,7 @@
  * @bug 8051344
  * @summary Force OSR compilation with non-empty stack at the OSR entry point.
  * @compile -XDignore.symbol.file TestOSRWithNonEmptyStack.java
- * @run main/othervm -XX:CompileOnly=TestCase.test TestOSRWithNonEmptyStack
+ * @run main/othervm -XX:CompileOnly=TestCase.test -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm TestOSRWithNonEmptyStack
  */
 public class TestOSRWithNonEmptyStack extends ClassLoader {
     private static final int CLASS_FILE_VERSION = 52;
--- a/test/compiler/runtime/8010927/Test8010927.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/runtime/8010927/Test8010927.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @build Test8010927
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. -Xmx64m -XX:NewSize=20971520 -XX:MaxNewSize=32m -XX:-UseTLAB -XX:-UseAdaptiveSizePolicy Test8010927
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. -Xmx64m -XX:NewSize=20971520 -XX:MaxNewSize=32m -XX:-UseTLAB -XX:-UseAdaptiveSizePolicy -XX:AddModuleExports=java.base/sun.misc Test8010927
  */
 
 import sun.hotspot.WhiteBox;
--- a/test/compiler/uncommontrap/TestUnstableIfTrap.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/uncommontrap/TestUnstableIfTrap.java	Fri Mar 06 14:27:49 2015 -0800
@@ -48,21 +48,25 @@
  *                   -XX:+WhiteBoxAPI -XX:+LogCompilation
  *                   -XX:CompileCommand=compileonly,UnstableIfExecutable.test
  *                   -XX:LogFile=always_taken_not_fired.xml
+ *                   -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm
  *                   TestUnstableIfTrap ALWAYS_TAKEN false
  * @run main/othervm -Xbatch -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:+LogCompilation
  *                   -XX:CompileCommand=compileonly,UnstableIfExecutable.test
  *                   -XX:LogFile=always_taken_fired.xml
+ *                   -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm
  *                   TestUnstableIfTrap ALWAYS_TAKEN true
  * @run main/othervm -Xbatch -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:+LogCompilation
  *                   -XX:CompileCommand=compileonly,UnstableIfExecutable.test
  *                   -XX:LogFile=never_taken_not_fired.xml
+ *                   -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm
  *                   TestUnstableIfTrap NEVER_TAKEN false
  * @run main/othervm -Xbatch -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:+LogCompilation
  *                   -XX:CompileCommand=compileonly,UnstableIfExecutable.test
  *                   -XX:LogFile=never_taken_fired.xml
+ *                   -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm
  *                   TestUnstableIfTrap NEVER_TAKEN true
  * @run main uncommontrap.Verifier always_taken_not_fired.xml
  *                                 always_taken_fired.xml
--- a/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8016474
  * @summary The bug only happens with C1 and G1 using a different ObjectAlignmentInBytes than KlassAlignmentInBytes (which is 8)
- * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32 GetUnsafeObjectG1PreBarrier
+ * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32 -XX:AddModuleExports=java.base/sun.misc GetUnsafeObjectG1PreBarrier
  */
 
 import java.lang.reflect.Field;
--- a/test/compiler/unsafe/UnsafeRaw.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/compiler/unsafe/UnsafeRaw.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @bug 8058744
  * @summary Invalid pattern-matching of address computations in raw unsafe
  * @library /testlibrary
- * @run main/othervm -Xbatch UnsafeRaw
+ * @run main/othervm -Xbatch -XX:AddModuleExports=java.base/sun.misc UnsafeRaw
  */
 
 import com.oracle.java.testlibrary.Utils;
--- a/test/gc/TestGCLogRotationViaJcmd.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/TestGCLogRotationViaJcmd.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @bug 7090324
  * @summary test for gc log rotation via jcmd
  * @library /testlibrary
- * @run main/othervm -Xloggc:test.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=3 TestGCLogRotationViaJcmd
+ * @run main/othervm -Xloggc:test.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=3 -XX:AddModuleExports=java.management/sun.management TestGCLogRotationViaJcmd
  *
  */
 import com.oracle.java.testlibrary.*;
--- a/test/gc/TestSmallHeap.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/TestSmallHeap.java	Fri Mar 06 14:27:49 2015 -0800
@@ -30,10 +30,10 @@
  * @library /testlibrary /../../test/lib
  * @build TestSmallHeap
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseParallelGC TestSmallHeap
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseSerialGC TestSmallHeap
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseG1GC TestSmallHeap
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseConcMarkSweepGC TestSmallHeap
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseParallelGC -XX:AddModuleExports=java.management/sun.management TestSmallHeap
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseSerialGC -XX:AddModuleExports=java.management/sun.management TestSmallHeap
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseG1GC -XX:AddModuleExports=java.management/sun.management TestSmallHeap
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseConcMarkSweepGC -XX:AddModuleExports=java.management/sun.management TestSmallHeap
  */
 
 /* Note: It would be nice to verify the minimal supported heap size (2m) here,
--- a/test/gc/arguments/TestG1HeapRegionSize.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/arguments/TestG1HeapRegionSize.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,10 +26,10 @@
  * @key gc
  * @bug 8021879
  * @summary Verify that the flag G1HeapRegionSize is updated properly
- * @run main/othervm -Xmx64m TestG1HeapRegionSize 1048576
- * @run main/othervm -XX:G1HeapRegionSize=2m -Xmx64m TestG1HeapRegionSize 2097152
- * @run main/othervm -XX:G1HeapRegionSize=3m -Xmx64m TestG1HeapRegionSize 2097152
- * @run main/othervm -XX:G1HeapRegionSize=64m -Xmx256m TestG1HeapRegionSize 33554432
+ * @run main/othervm -Xmx64m -XX:AddModuleExports=java.management/sun.management TestG1HeapRegionSize 1048576
+ * @run main/othervm -XX:G1HeapRegionSize=2m -Xmx64m -XX:AddModuleExports=java.management/sun.management TestG1HeapRegionSize 2097152
+ * @run main/othervm -XX:G1HeapRegionSize=3m -Xmx64m -XX:AddModuleExports=java.management/sun.management TestG1HeapRegionSize 2097152
+ * @run main/othervm -XX:G1HeapRegionSize=64m -Xmx256m -XX:AddModuleExports=java.management/sun.management TestG1HeapRegionSize 33554432
  */
 
 import sun.management.ManagementFactoryHelper;
--- a/test/gc/arguments/TestUseCompressedOopsErgo.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/arguments/TestUseCompressedOopsErgo.java	Fri Mar 06 14:27:49 2015 -0800
@@ -30,11 +30,11 @@
  * @build TestUseCompressedOopsErgo TestUseCompressedOopsErgoTools
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm TestUseCompressedOopsErgo -XX:+UseG1GC
- * @run main/othervm TestUseCompressedOopsErgo -XX:+UseParallelGC
- * @run main/othervm TestUseCompressedOopsErgo -XX:+UseParallelGC -XX:-UseParallelOldGC
- * @run main/othervm TestUseCompressedOopsErgo -XX:+UseConcMarkSweepGC
- * @run main/othervm TestUseCompressedOopsErgo -XX:+UseSerialGC
+ * @run main/othervm -XX:AddModuleExports=java.management/sun.management TestUseCompressedOopsErgo -XX:+UseG1GC
+ * @run main/othervm -XX:AddModuleExports=java.management/sun.management TestUseCompressedOopsErgo -XX:+UseParallelGC
+ * @run main/othervm -XX:AddModuleExports=java.management/sun.management TestUseCompressedOopsErgo -XX:+UseParallelGC -XX:-UseParallelOldGC
+ * @run main/othervm -XX:AddModuleExports=java.management/sun.management TestUseCompressedOopsErgo -XX:+UseConcMarkSweepGC
+ * @run main/othervm -XX:AddModuleExports=java.management/sun.management TestUseCompressedOopsErgo -XX:+UseSerialGC
  */
 
 public class TestUseCompressedOopsErgo {
--- a/test/gc/g1/TestHumongousShrinkHeap.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestHumongousShrinkHeap.java	Fri Mar 06 14:27:49 2015 -0800
@@ -30,7 +30,7 @@
  * @library /testlibrary
  * @run main/othervm -XX:-ExplicitGCInvokesConcurrent -XX:MinHeapFreeRatio=10
  * -XX:MaxHeapFreeRatio=12 -XX:+UseG1GC -XX:G1HeapRegionSize=1M -verbose:gc
- * TestHumongousShrinkHeap
+ * -XX:AddModuleExports=java.management/sun.management TestHumongousShrinkHeap
  */
 
 import java.lang.management.ManagementFactory;
--- a/test/gc/g1/TestShrinkAuxiliaryData00.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestShrinkAuxiliaryData00.java	Fri Mar 06 14:27:49 2015 -0800
@@ -28,7 +28,7 @@
  * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
  * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData00
- * @run driver/timeout=720 TestShrinkAuxiliaryData00
+ * @run main/othervm/timeout=720 -XX:AddModuleExports=java.base/sun.misc TestShrinkAuxiliaryData00
  */
 public class TestShrinkAuxiliaryData00 {
 
--- a/test/gc/g1/TestShrinkAuxiliaryData05.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestShrinkAuxiliaryData05.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData05
- * @run driver/timeout=720 TestShrinkAuxiliaryData05
+ * @run main/othervm/timeout=720 -XX:AddModuleExports=java.base/sun.misc TestShrinkAuxiliaryData05
  */
 public class TestShrinkAuxiliaryData05 {
 
--- a/test/gc/g1/TestShrinkAuxiliaryData10.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestShrinkAuxiliaryData10.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData10
- * @run driver/timeout=720 TestShrinkAuxiliaryData10
+ * @run main/othervm/timeout=720 -XX:AddModuleExports=java.base/sun.misc TestShrinkAuxiliaryData10
  */
 public class TestShrinkAuxiliaryData10 {
 
--- a/test/gc/g1/TestShrinkAuxiliaryData15.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestShrinkAuxiliaryData15.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData15
- * @run driver/timeout=720 TestShrinkAuxiliaryData15
+ * @run main/othervm/timeout=720 -XX:AddModuleExports=java.base/sun.misc TestShrinkAuxiliaryData15
  */
 public class TestShrinkAuxiliaryData15 {
 
--- a/test/gc/g1/TestShrinkAuxiliaryData20.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestShrinkAuxiliaryData20.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData20
- * @run driver/timeout=720 TestShrinkAuxiliaryData20
+ * @run main/othervm/timeout=720 -XX:AddModuleExports=java.base/sun.misc TestShrinkAuxiliaryData20
  */
 public class TestShrinkAuxiliaryData20 {
 
--- a/test/gc/g1/TestShrinkAuxiliaryData25.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestShrinkAuxiliaryData25.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData25
- * @run driver/timeout=720 TestShrinkAuxiliaryData25
+ * @run main/othervm/timeout=720 -XX:AddModuleExports=java.base/sun.misc TestShrinkAuxiliaryData25
  */
 public class TestShrinkAuxiliaryData25 {
 
--- a/test/gc/g1/TestShrinkAuxiliaryData30.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestShrinkAuxiliaryData30.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @requires vm.gc=="G1" | vm.gc=="null"
  * @library /testlibrary /../../test/lib
  * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData30
- * @run driver/timeout=720 TestShrinkAuxiliaryData30
+ * @run main/othervm/timeout=720 -XX:AddModuleExports=java.base/sun.misc TestShrinkAuxiliaryData30
  */
 public class TestShrinkAuxiliaryData30 {
 
--- a/test/gc/g1/TestShrinkDefragmentedHeap.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestShrinkDefragmentedHeap.java	Fri Mar 06 14:27:49 2015 -0800
@@ -61,6 +61,7 @@
                 "-XX:G1HeapRegionSize=" + REGION_SIZE,
                 "-XX:-ExplicitGCInvokesConcurrent",
                 "-verbose:gc",
+                "-XX:AddModuleExports=java.management/sun.management",
                 GCTest.class.getName()
         );
 
--- a/test/gc/g1/TestStringDeduplicationAgeThreshold.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestStringDeduplicationAgeThreshold.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,6 +27,7 @@
  * @bug 8029075
  * @key gc
  * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc TestStringDeduplicationAgeThreshold
  */
 
 public class TestStringDeduplicationAgeThreshold {
--- a/test/gc/g1/TestStringDeduplicationFullGC.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestStringDeduplicationFullGC.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,6 +27,7 @@
  * @bug 8029075
  * @key gc
  * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc TestStringDeduplicationFullGC
  */
 
 public class TestStringDeduplicationFullGC {
--- a/test/gc/g1/TestStringDeduplicationInterned.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestStringDeduplicationInterned.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,6 +27,7 @@
  * @bug 8029075
  * @key gc
  * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc TestStringDeduplicationInterned
  */
 
 public class TestStringDeduplicationInterned {
--- a/test/gc/g1/TestStringDeduplicationPrintOptions.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestStringDeduplicationPrintOptions.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,6 +27,7 @@
  * @bug 8029075
  * @key gc
  * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc TestStringDeduplicationPrintOptions
  */
 
 public class TestStringDeduplicationPrintOptions {
--- a/test/gc/g1/TestStringDeduplicationTableRehash.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestStringDeduplicationTableRehash.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,6 +27,7 @@
  * @bug 8029075
  * @key gc
  * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc TestStringDeduplicationTableRehash
  */
 
 public class TestStringDeduplicationTableRehash {
--- a/test/gc/g1/TestStringDeduplicationTableResize.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestStringDeduplicationTableResize.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,6 +27,7 @@
  * @bug 8029075
  * @key gc
  * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc TestStringDeduplicationTableResize
  */
 
 public class TestStringDeduplicationTableResize {
--- a/test/gc/g1/TestStringDeduplicationTools.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestStringDeduplicationTools.java	Fri Mar 06 14:27:49 2015 -0800
@@ -189,7 +189,8 @@
             "-Xmx" + Xmx + "m",
             "-XX:+UseG1GC",
             "-XX:+UnlockDiagnosticVMOptions",
-            "-XX:+VerifyAfterGC" // Always verify after GC
+            "-XX:+VerifyAfterGC", // Always verify after GC
+            "-XX:AddModuleExports=java.base/sun.misc"
         };
 
         ArrayList<String> args = new ArrayList<String>();
--- a/test/gc/g1/TestStringDeduplicationYoungGC.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestStringDeduplicationYoungGC.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,6 +27,7 @@
  * @bug 8029075
  * @key gc
  * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc TestStringDeduplicationYoungGC
  */
 
 public class TestStringDeduplicationYoungGC {
--- a/test/gc/g1/TestSummarizeRSetStats.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestSummarizeRSetStats.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,7 +27,7 @@
  * @library /testlibrary
  * @build TestSummarizeRSetStatsTools TestSummarizeRSetStats
  * @summary Verify output of -XX:+G1SummarizeRSetStats
- * @run main TestSummarizeRSetStats
+ * @run main/othervm -XX:AddModuleExports=java.management/sun.management TestSummarizeRSetStats
  *
  * Test the output of G1SummarizeRSetStats in conjunction with G1SummarizeRSetStatsPeriod.
  */
--- a/test/gc/g1/TestSummarizeRSetStatsPerRegion.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestSummarizeRSetStatsPerRegion.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,7 +27,7 @@
  * @library /testlibrary
  * @build TestSummarizeRSetStatsTools TestSummarizeRSetStatsPerRegion
  * @summary Verify output of -XX:+G1SummarizeRSetStats in regards to per-region type output
- * @run main TestSummarizeRSetStatsPerRegion
+ * @run main/othervm -XX:AddModuleExports=java.management/sun.management TestSummarizeRSetStatsPerRegion
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/gc/g1/TestSummarizeRSetStatsThreads.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/g1/TestSummarizeRSetStatsThreads.java	Fri Mar 06 14:27:49 2015 -0800
@@ -28,6 +28,7 @@
  * refinement threads do not crash the VM.
  * @key gc
  * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.management/sun.management TestSummarizeRSetStatsThreads
  */
 
 import java.util.regex.Matcher;
--- a/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @bug 8004924
  * @summary Checks that jmap -heap contains the flag CompressedClassSpaceSize
  * @library /testlibrary
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:CompressedClassSpaceSize=50m CompressedClassSpaceSizeInJmapHeap
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:CompressedClassSpaceSize=50m -XX:AddModuleExports=java.management/sun.management CompressedClassSpaceSizeInJmapHeap
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/gc/metaspace/TestMetaspacePerfCounters.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/metaspace/TestMetaspacePerfCounters.java	Fri Mar 06 14:27:49 2015 -0800
@@ -34,13 +34,13 @@
  * @summary Tests that performance counters for metaspace and compressed class
  *          space exists and works.
  *
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC TestMetaspacePerfCounters
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC -XX:AddModuleExports=java.management/sun.management,jdk.jvmstat/sun.jvmstat.monitor TestMetaspacePerfCounters
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:AddModuleExports=java.management/sun.management,jdk.jvmstat/sun.jvmstat.monitor TestMetaspacePerfCounters
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC -XX:AddModuleExports=java.management/sun.management,jdk.jvmstat/sun.jvmstat.monitor TestMetaspacePerfCounters
  *
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC TestMetaspacePerfCounters
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC -XX:AddModuleExports=java.management/sun.management,jdk.jvmstat/sun.jvmstat.monitor TestMetaspacePerfCounters
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:AddModuleExports=java.management/sun.management,jdk.jvmstat/sun.jvmstat.monitor TestMetaspacePerfCounters
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC -XX:AddModuleExports=java.management/sun.management,jdk.jvmstat/sun.jvmstat.monitor TestMetaspacePerfCounters
  */
 public class TestMetaspacePerfCounters {
     public static Class fooClass = null;
--- a/test/gc/metaspace/TestPerfCountersAndMemoryPools.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/metaspace/TestPerfCountersAndMemoryPools.java	Fri Mar 06 14:27:49 2015 -0800
@@ -33,8 +33,8 @@
  * @requires vm.gc=="Serial" | vm.gc=="null"
  * @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace
  *          report the same data.
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
- * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint -XX:AddModuleExports=java.management/sun.management,jdk.jvmstat/sun.jvmstat.monitor TestPerfCountersAndMemoryPools
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint -XX:AddModuleExports=java.management/sun.management,jdk.jvmstat/sun.jvmstat.monitor TestPerfCountersAndMemoryPools
  */
 public class TestPerfCountersAndMemoryPools {
     public static void main(String[] args) throws Exception {
--- a/test/gc/survivorAlignment/TestAllocationInEden.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/survivorAlignment/TestAllocationInEden.java	Fri Mar 06 14:27:49 2015 -0800
@@ -36,6 +36,7 @@
  *                   -XX:SurvivorAlignmentInBytes=32 -XX:-UseTLAB
  *                   -XX:OldSize=128m -XX:MaxHeapSize=192m
  *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestAllocationInEden 10m 9 EDEN
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
@@ -43,6 +44,7 @@
  *                   -XX:SurvivorAlignmentInBytes=32 -XX:-UseTLAB
  *                   -XX:OldSize=128m -XX:MaxHeapSize=192m
  *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestAllocationInEden 10m 47 EDEN
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
@@ -50,6 +52,7 @@
  *                   -XX:SurvivorAlignmentInBytes=64 -XX:-UseTLAB
  *                   -XX:OldSize=128m  -XX:MaxHeapSize=192m
  *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestAllocationInEden 10m 9 EDEN
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
@@ -57,6 +60,7 @@
  *                   -XX:SurvivorAlignmentInBytes=64 -XX:-UseTLAB
  *                   -XX:OldSize=128m  -XX:MaxHeapSize=192m
  *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestAllocationInEden 10m 87 EDEN
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
@@ -64,6 +68,7 @@
  *                   -XX:SurvivorAlignmentInBytes=128 -XX:-UseTLAB
  *                   -XX:OldSize=128m -XX:MaxHeapSize=192m
  *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestAllocationInEden 10m 9 EDEN
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
@@ -71,6 +76,7 @@
  *                   -XX:SurvivorAlignmentInBytes=128 -XX:-UseTLAB
  *                   -XX:OldSize=128m -XX:MaxHeapSize=192m
  *                   -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestAllocationInEden 10m 147 EDEN
  */
 public class TestAllocationInEden {
--- a/test/gc/survivorAlignment/TestPromotionFromEdenToTenured.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/survivorAlignment/TestPromotionFromEdenToTenured.java	Fri Mar 06 14:27:49 2015 -0800
@@ -37,6 +37,7 @@
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromEdenToTenured 10m 9 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
@@ -44,6 +45,7 @@
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromEdenToTenured 10m 47 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
@@ -51,6 +53,7 @@
  *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromEdenToTenured 10m 9 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
@@ -58,6 +61,7 @@
  *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromEdenToTenured 10m 87 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
@@ -65,6 +69,7 @@
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromEdenToTenured 10m 9 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
@@ -72,6 +77,7 @@
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromEdenToTenured 10m 147 TENURED
  */
 public class TestPromotionFromEdenToTenured {
--- a/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java	Fri Mar 06 14:27:49 2015 -0800
@@ -37,6 +37,7 @@
  *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
@@ -44,6 +45,7 @@
  *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromSurvivorToTenuredAfterFullGC 20m 47
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
@@ -52,6 +54,7 @@
  *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
@@ -59,6 +62,7 @@
  *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromSurvivorToTenuredAfterFullGC 20m 87
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
@@ -67,6 +71,7 @@
  *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                    TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9
  *                    TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
@@ -75,6 +80,7 @@
  *                   -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromSurvivorToTenuredAfterFullGC 20m 147
  *                   TENURED
  */
--- a/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java	Fri Mar 06 14:27:49 2015 -0800
@@ -38,6 +38,7 @@
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
@@ -46,6 +47,7 @@
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 47
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
@@ -54,6 +56,7 @@
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
@@ -62,6 +65,7 @@
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 87
  *                   TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
@@ -70,6 +74,7 @@
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                    TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
  *                    TENURED
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
@@ -78,6 +83,7 @@
  *                   -XX:-ExplicitGCInvokesConcurrent
  *                   -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 147
  *                   TENURED
  */
--- a/test/gc/survivorAlignment/TestPromotionToSurvivor.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/gc/survivorAlignment/TestPromotionToSurvivor.java	Fri Mar 06 14:27:49 2015 -0800
@@ -36,36 +36,42 @@
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32 -XX:OldSize=128m
  *                   -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionToSurvivor 10m 9 SURVIVOR
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=32 -XX:OldSize=128m
  *                   -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionToSurvivor 20m 47 SURVIVOR
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64 -XX:OldSize=128m
  *                   -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionToSurvivor 8m 9 SURVIVOR
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=64 -XX:OldSize=128m
  *                   -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionToSurvivor 20m 87 SURVIVOR
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128 -XX:OldSize=128m
  *                   -XX:MaxHeapSize=384m  -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionToSurvivor 10m 9 SURVIVOR
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  *                   -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
  *                   -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
  *                   -XX:SurvivorAlignmentInBytes=128 -XX:OldSize=128m
  *                   -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
+ *                   -XX:AddModuleExports=java.base/sun.misc
  *                   TestPromotionToSurvivor 20m 147 SURVIVOR
  */
 public class TestPromotionToSurvivor {
--- a/test/runtime/8003720/Test8003720.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/8003720/Test8003720.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,7 +27,7 @@
  * @bug 8003720
  * @summary Method in interpreter stack frame can be deallocated
  * @compile -XDignore.symbol.file Victim.java
- * @run main/othervm -Xverify:all -Xint Test8003720
+ * @run main/othervm -Xverify:all -Xint -XX:AddModuleExports=java.base/sun.misc,java.base/jdk.internal.org.objectweb.asm Test8003720
  */
 
 // Attempts to make the JVM unload a class while still executing one of its methods.
--- a/test/runtime/8026365/InvokeSpecialAnonTest.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/8026365/InvokeSpecialAnonTest.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @library /testlibrary
  * @compile -XDignore.symbol.file InvokeSpecialAnonTest.java
  * @run main ClassFileInstaller InvokeSpecialAnonTest AnonTester
- * @run main/othervm -Xbootclasspath/a:. -Xverify:all InvokeSpecialAnonTest
+ * @run main/othervm -Xbootclasspath/a:. -Xverify:all -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm,java.base/sun.misc InvokeSpecialAnonTest
  */
 import jdk.internal.org.objectweb.asm.*;
 import java.lang.reflect.Constructor;
--- a/test/runtime/BadObjectClass/BootstrapRedefine.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/BadObjectClass/BootstrapRedefine.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,6 +26,7 @@
  * @bug 6583051
  * @summary Give error if java.lang.Object has been incompatibly overridden on the bootpath
  * @library /testlibrary
+ * @ignore 8072370
  * @compile Object.java
  * @run main BootstrapRedefine
  */
--- a/test/runtime/ClassFile/UnsupportedClassFileVersion.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/ClassFile/UnsupportedClassFileVersion.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @library /testlibrary
  * @compile -XDignore.symbol.file UnsupportedClassFileVersion.java
- * @run main UnsupportedClassFileVersion
+ * @run main/othervm -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm UnsupportedClassFileVersion
  */
 
 import java.io.File;
@@ -38,7 +38,7 @@
 public class UnsupportedClassFileVersion implements Opcodes {
     public static void main(String... args) throws Exception {
         writeClassFile();
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".",  "ClassFile");
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".", "ClassFile");
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         output.shouldContain("ClassFile has been compiled by a more recent version of the " +
                             "Java Runtime (class file version 99.0), this version of " +
--- a/test/runtime/InternalApi/ThreadCpuTimesDeadlock.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/InternalApi/ThreadCpuTimesDeadlock.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,7 +27,7 @@
  * @bug 7196045
  * @bug 8014294
  * @summary Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
- * @run main/othervm -XX:+UsePerfData -Xmx32m ThreadCpuTimesDeadlock
+ * @run main/othervm -XX:+UsePerfData -Xmx32m -XX:AddModuleExports=java.management/sun.management ThreadCpuTimesDeadlock
  */
 
 import java.lang.management.ManagementFactory;
--- a/test/runtime/NMT/BaselineWithParameter.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/BaselineWithParameter.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,7 +27,7 @@
  * @key nmt jcmd regression
  * @summary Regression test for invoking a jcmd with baseline=false, result was that the target VM crashed
  * @library /testlibrary
- * @run main/othervm -XX:NativeMemoryTracking=detail BaselineWithParameter
+ * @run main/othervm -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management BaselineWithParameter
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/NMT/JcmdBaselineDetail.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/JcmdBaselineDetail.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @key nmt jcmd
  * @summary Verify that jcmd correctly reports that baseline succeeds with NMT enabled with detailed tracking.
  * @library /testlibrary
- * @run main/othervm -XX:NativeMemoryTracking=detail JcmdBaselineDetail
+ * @run main/othervm -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management JcmdBaselineDetail
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/NMT/JcmdScale.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/JcmdScale.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @key nmt jcmd
  * @summary Test the NMT scale parameter
  * @library /testlibrary
- * @run main/othervm -XX:NativeMemoryTracking=summary JcmdScale
+ * @run main/othervm -XX:NativeMemoryTracking=summary -XX:AddModuleExports=java.management/sun.management JcmdScale
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/NMT/JcmdScaleDetail.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/JcmdScaleDetail.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @key nmt jcmd
  * @summary Test the NMT scale parameter with detail tracking level
  * @library /testlibrary
- * @run main/othervm -XX:NativeMemoryTracking=detail JcmdScaleDetail
+ * @run main/othervm -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management JcmdScaleDetail
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/NMT/JcmdSummaryDiff.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/JcmdSummaryDiff.java	Fri Mar 06 14:27:49 2015 -0800
@@ -28,7 +28,7 @@
  * @library /testlibrary /../../test/lib
  * @build JcmdSummaryDiff
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=summary JcmdSummaryDiff
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=summary -XX:AddModuleExports=java.management/sun.management JcmdSummaryDiff
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/NMT/JcmdWithNMTDisabled.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/JcmdWithNMTDisabled.java	Fri Mar 06 14:27:49 2015 -0800
@@ -45,12 +45,12 @@
       String testjdkPath = System.getProperty("test.jdk");
 
       // First run without enabling NMT
-      pb = ProcessTools.createJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "JcmdWithNMTDisabled");
+      pb = ProcessTools.createJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "-XX:AddModuleExports=java.management/sun.management", "JcmdWithNMTDisabled");
       output = new OutputAnalyzer(pb.start());
       output.shouldHaveExitValue(0);
 
       // Then run with explicitly disabling NMT, should not be any difference
-      pb = ProcessTools.createJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "-XX:NativeMemoryTracking=off", "JcmdWithNMTDisabled");
+      pb = ProcessTools.createJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "-XX:NativeMemoryTracking=off", "-XX:AddModuleExports=java.management/sun.management", "JcmdWithNMTDisabled");
       output = new OutputAnalyzer(pb.start());
       output.shouldHaveExitValue(0);
 
--- a/test/runtime/NMT/MallocRoundingReportTest.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/MallocRoundingReportTest.java	Fri Mar 06 14:27:49 2015 -0800
@@ -28,7 +28,7 @@
  * @library /testlibrary /../../test/lib
  * @build MallocRoundingReportTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocRoundingReportTest
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management MallocRoundingReportTest
  *
  */
 
--- a/test/runtime/NMT/MallocTestType.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/MallocTestType.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @build MallocTestType
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTestType
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management MallocTestType
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/NMT/MallocTrackingVerify.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/MallocTrackingVerify.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @library /testlibrary /../../test/lib
  * @build MallocTrackingVerify
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTrackingVerify
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management MallocTrackingVerify
  *
  */
 
--- a/test/runtime/NMT/ReleaseNoCommit.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/ReleaseNoCommit.java	Fri Mar 06 14:27:49 2015 -0800
@@ -28,7 +28,7 @@
  * @library /testlibrary /../../test/lib
  * @build ReleaseNoCommit
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=summary ReleaseNoCommit
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=summary -XX:AddModuleExports=java.management/sun.management ReleaseNoCommit
  */
 
 import com.oracle.java.testlibrary.JDKToolFinder;
--- a/test/runtime/NMT/ShutdownTwice.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/ShutdownTwice.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @key nmt jcmd
  * @summary Run shutdown twice
  * @library /testlibrary
- * @run main/othervm -XX:NativeMemoryTracking=detail ShutdownTwice
+ * @run main/othervm -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management ShutdownTwice
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/NMT/SummaryAfterShutdown.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/SummaryAfterShutdown.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @key nmt jcmd
  * @summary Verify that jcmd correctly reports that NMT is not enabled after a shutdown
  * @library /testlibrary
- * @run main/othervm -XX:NativeMemoryTracking=detail SummaryAfterShutdown
+ * @run main/othervm -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management SummaryAfterShutdown
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/NMT/SummarySanityCheck.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/SummarySanityCheck.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @build SummarySanityCheck
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+WhiteBoxAPI SummarySanityCheck
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+WhiteBoxAPI -XX:AddModuleExports=java.management/sun.management SummarySanityCheck
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/NMT/ThreadedMallocTestType.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/ThreadedMallocTestType.java	Fri Mar 06 14:27:49 2015 -0800
@@ -28,7 +28,7 @@
  * @build ThreadedMallocTestType
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedMallocTestType
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management ThreadedMallocTestType
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/NMT/ThreadedVirtualAllocTestType.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/ThreadedVirtualAllocTestType.java	Fri Mar 06 14:27:49 2015 -0800
@@ -28,7 +28,7 @@
  * @build ThreadedVirtualAllocTestType
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedVirtualAllocTestType
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management ThreadedVirtualAllocTestType
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java	Fri Mar 06 14:27:49 2015 -0800
@@ -28,7 +28,7 @@
  * @library /testlibrary /../../test/lib
  * @build VirtualAllocCommitUncommitRecommit
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocCommitUncommitRecommit
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management VirtualAllocCommitUncommitRecommit
  *
  */
 
--- a/test/runtime/NMT/VirtualAllocTestType.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/NMT/VirtualAllocTestType.java	Fri Mar 06 14:27:49 2015 -0800
@@ -29,7 +29,7 @@
  * @build VirtualAllocTestType
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocTestType
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail -XX:AddModuleExports=java.management/sun.management VirtualAllocTestType
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/RedefineTests/RedefineAnnotations.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/RedefineTests/RedefineAnnotations.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,8 +25,8 @@
  * @test
  * @library /testlibrary
  * @summary Test that type annotations are retained after a retransform
- * @run main RedefineAnnotations buildagent
- * @run main/othervm -javaagent:redefineagent.jar RedefineAnnotations
+ * @run main/othervm -XX:AddModuleExports=jdk.dev/sun.tools.jar RedefineAnnotations buildagent
+ * @run main/othervm -javaagent:redefineagent.jar -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm RedefineAnnotations
  */
 
 import static com.oracle.java.testlibrary.Asserts.assertTrue;
--- a/test/runtime/RedefineTests/RedefineFinalizer.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/RedefineTests/RedefineFinalizer.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,7 +27,7 @@
  * @summary Don't assert if we redefine finalize method
  * @library /testlibrary
  * @build RedefineClassHelper
- * @run main RedefineClassHelper
+ * @run main/othervm -XX:AddModuleExports=jdk.dev/sun.tools.jar RedefineClassHelper
  * @run main/othervm -javaagent:redefineagent.jar RedefineFinalizer
  */
 
--- a/test/runtime/RedefineTests/RedefineRunningMethods.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/RedefineTests/RedefineRunningMethods.java	Fri Mar 06 14:27:49 2015 -0800
@@ -27,7 +27,7 @@
  * @summary Redefine EMCP and non-EMCP methods that are running in an infinite loop
  * @library /testlibrary
  * @build RedefineClassHelper
- * @run main RedefineClassHelper
+ * @run main/othervm -XX:AddModuleExports=jdk.dev/sun.tools.jar RedefineClassHelper
  * @run main/othervm -javaagent:redefineagent.jar -XX:TraceRedefineClasses=0x600 RedefineRunningMethods
  */
 public class RedefineRunningMethods {
--- a/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @bug 8059510
  * @summary Test jcmd VM.symboltable and VM.stringtable options
  * @library /testlibrary
- * @run main/othervm -XX:+UnlockDiagnosticVMOptions DumpSymbolAndStringTable
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:AddModuleExports=java.management/sun.management DumpSymbolAndStringTable
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java	Fri Mar 06 14:27:49 2015 -0800
@@ -56,24 +56,6 @@
       output.shouldNotContain("Usage:");           // Should not print JVM help message
       output.shouldHaveExitValue(0);               // Should report success in error code.
 
-      // (2) With an invalid archive (boot class path has been prepended)
-      pb = ProcessTools.createJavaProcessBuilder(
-          "-Xbootclasspath/p:foo.jar",
-          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
-          "-XX:+PrintSharedArchiveAndExit", "-version");
-      output = new OutputAnalyzer(pb.start());
-      output.shouldContain("archive is invalid");
-      output.shouldNotContain("java version");     // Should not print JVM version
-      output.shouldHaveExitValue(1);               // Should report failure in error code.
-
-      pb = ProcessTools.createJavaProcessBuilder(
-          "-Xbootclasspath/p:foo.jar",
-          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
-          "-XX:+PrintSharedArchiveAndExit");
-      output = new OutputAnalyzer(pb.start());
-      output.shouldContain("archive is invalid");
-      output.shouldNotContain("Usage:");           // Should not print JVM help message
-      output.shouldHaveExitValue(1);               // Should report failure in error code.
     } catch (RuntimeException e) {
       e.printStackTrace();
       output.shouldContain("Unable to use shared archive");
--- a/test/runtime/SharedArchiveFile/SharedArchiveFile.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/SharedArchiveFile/SharedArchiveFile.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,6 +26,7 @@
  * @bug 8014138
  * @summary Testing new -XX:SharedArchiveFile=<file-name> option
  * @library /testlibrary
+ * @run main/othervm -XX:AddModuleExports=java.management/sun.management SharedArchiveFile
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/StackGuardPages/testme.sh	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/StackGuardPages/testme.sh	Fri Mar 06 14:27:49 2015 -0800
@@ -3,6 +3,7 @@
 #
 # @test testme.sh
 # @summary Stack guard pages should be installed correctly and removed when thread is detached
+# @ignore 8072481
 # @run shell testme.sh
 #
 
--- a/test/runtime/Thread/ThreadPriorities.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Thread/ThreadPriorities.java	Fri Mar 06 14:27:49 2015 -0800
@@ -28,7 +28,7 @@
  *      whether jstack reports correct priorities for them.
  *
  * @library /testlibrary
- * @run main ThreadPriorities
+ * @run main/othervm -XX:AddModuleExports=java.management/sun.management ThreadPriorities
  */
 
 import java.util.ArrayList;
--- a/test/runtime/Unsafe/AllocateInstance.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/AllocateInstance.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verifies the behaviour of Unsafe.allocateInstance
  * @library /testlibrary
- * @run main AllocateInstance
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc AllocateInstance
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/Unsafe/AllocateMemory.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/AllocateMemory.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verifies behaviour of Unsafe.allocateMemory
  * @library /testlibrary
- * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m AllocateMemory
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m -XX:AddModuleExports=java.base/sun.misc AllocateMemory
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/Unsafe/CopyMemory.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/CopyMemory.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verifies behaviour of Unsafe.copyMemory
  * @library /testlibrary
- * @run main CopyMemory
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc CopyMemory
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/Unsafe/DefineClass.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/DefineClass.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verifies the behaviour of Unsafe.defineClass
  * @library /testlibrary
- * @run main DefineClass
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc DefineClass
  */
 
 import java.security.ProtectionDomain;
--- a/test/runtime/Unsafe/FieldOffset.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/FieldOffset.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verifies the behaviour of Unsafe.fieldOffset
  * @library /testlibrary
- * @run main FieldOffset
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc FieldOffset
  */
 
 import java.lang.reflect.Field;
--- a/test/runtime/Unsafe/GetField.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetField.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verifies behaviour of Unsafe.getField
  * @library /testlibrary
- * @run main GetField
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetField
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/Unsafe/GetPutAddress.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetPutAddress.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * Verify behaviour of Unsafe.get/putAddress and Unsafe.addressSize
  * @library /testlibrary
- * @run main GetPutAddress
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetPutAddress
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/Unsafe/GetPutBoolean.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetPutBoolean.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verify behaviour of Unsafe.get/putBoolean
  * @library /testlibrary
- * @run main GetPutBoolean
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetPutBoolean
  */
 
 import java.lang.reflect.Field;
--- a/test/runtime/Unsafe/GetPutByte.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetPutByte.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verify behaviour of Unsafe.get/putByte
  * @library /testlibrary
- * @run main GetPutByte
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetPutByte
  */
 
 import java.lang.reflect.Field;
--- a/test/runtime/Unsafe/GetPutChar.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetPutChar.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verify behaviour of Unsafe.get/putChar
  * @library /testlibrary
- * @run main GetPutChar
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetPutChar
  */
 
 import java.lang.reflect.Field;
--- a/test/runtime/Unsafe/GetPutDouble.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetPutDouble.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verify behaviour of Unsafe.get/putDouble
  * @library /testlibrary
- * @run main GetPutDouble
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetPutDouble
  */
 
 import java.lang.reflect.Field;
--- a/test/runtime/Unsafe/GetPutFloat.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetPutFloat.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verify behaviour of Unsafe.get/putFloat
  * @library /testlibrary
- * @run main GetPutFloat
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetPutFloat
  */
 
 import java.lang.reflect.Field;
--- a/test/runtime/Unsafe/GetPutInt.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetPutInt.java	Fri Mar 06 14:27:49 2015 -0800
@@ -24,7 +24,7 @@
 /*
  * @test
  * @library /testlibrary
- * @run main GetPutInt
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetPutInt
  */
 
 import java.lang.reflect.Field;
--- a/test/runtime/Unsafe/GetPutLong.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetPutLong.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verify behaviour of Unsafe.get/putLong
  * @library /testlibrary
- * @run main GetPutLong
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetPutLong
  */
 
 import java.lang.reflect.Field;
--- a/test/runtime/Unsafe/GetPutObject.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetPutObject.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verify behaviour of Unsafe.get/putObject
  * @library /testlibrary
- * @run main GetPutObject
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetPutObject
  */
 
 import java.lang.reflect.Field;
--- a/test/runtime/Unsafe/GetPutShort.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetPutShort.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verify behaviour of Unsafe.get/putShort
  * @library /testlibrary
- * @run main GetPutShort
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetPutShort
  */
 
 import java.lang.reflect.Field;
--- a/test/runtime/Unsafe/GetUnsafe.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/GetUnsafe.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verifies that getUnsafe() actually throws SecurityException when unsafeAccess is prohibited.
  * @library /testlibrary
- * @run main GetUnsafe
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc GetUnsafe
  */
 
 import sun.misc.Unsafe;
--- a/test/runtime/Unsafe/PageSize.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/PageSize.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Make sure pageSize() returns a value that is a power of two
  * @library /testlibrary
- * @run main PageSize
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc PageSize
  */
 
 import java.lang.reflect.Field;
--- a/test/runtime/Unsafe/RangeCheck.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/RangeCheck.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,6 +26,7 @@
  * @bug 8001071
  * @summary Add simple range check into VM implemenation of Unsafe access methods
  * @library /testlibrary
+ * @run main RangeCheck
  */
 
 import com.oracle.java.testlibrary.*;
@@ -44,6 +45,7 @@
                 "-Xmx32m",
                 "-XX:-TransmitErrorReport",
                 "-XX:-InlineUnsafeOps", // The compiler intrinsics doesn't have the assert
+                "-XX:AddModuleExports=java.base/sun.misc",
                 DummyClassWithMainRangeCheck.class.getName());
 
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
--- a/test/runtime/Unsafe/Reallocate.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/Reallocate.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8058897
  * @library /testlibrary
- * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m Reallocate
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m -XX:AddModuleExports=java.base/sun.misc Reallocate
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/Unsafe/SetMemory.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/SetMemory.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verifies that setMemory works correctly
  * @library /testlibrary
- * @run main SetMemory
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc SetMemory
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/Unsafe/ThrowException.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/Unsafe/ThrowException.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @summary Verify that throwException() can throw an exception
  * @library /testlibrary
- * @run main ThrowException
+ * @run main/othervm -XX:AddModuleExports=java.base/sun.misc ThrowException
  */
 
 import com.oracle.java.testlibrary.*;
--- a/test/runtime/contended/Basic.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/contended/Basic.java	Fri Mar 06 14:27:49 2015 -0800
@@ -43,7 +43,7 @@
  * @bug     8003985
  * @summary Support Contended Annotation - JEP 142
  *
- * @run main/othervm -XX:-RestrictContended Basic
+ * @run main/othervm -XX:-RestrictContended -XX:AddModuleExports=java.base/sun.misc Basic
  */
 public class Basic {
 
--- a/test/runtime/contended/DefaultValue.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/contended/DefaultValue.java	Fri Mar 06 14:27:49 2015 -0800
@@ -43,7 +43,7 @@
  * @bug     8014509
  * @summary \@Contended: explicit default value behaves differently from the implicit value
  *
- * @run main/othervm -XX:-RestrictContended DefaultValue
+ * @run main/othervm -XX:-RestrictContended -XX:AddModuleExports=java.base/sun.misc DefaultValue
  */
 public class DefaultValue {
 
--- a/test/runtime/contended/Inheritance1.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/contended/Inheritance1.java	Fri Mar 06 14:27:49 2015 -0800
@@ -43,7 +43,7 @@
  * @bug     8012939
  * @summary \@Contended doesn't work correctly with inheritance
  *
- * @run main/othervm -XX:-RestrictContended Inheritance1
+ * @run main/othervm -XX:-RestrictContended -XX:AddModuleExports=java.base/sun.misc Inheritance1
  */
 public class Inheritance1 {
 
--- a/test/runtime/finalStatic/FinalStatic.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/finalStatic/FinalStatic.java	Fri Mar 06 14:27:49 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8028553
  * @summary Test that VerifyError is not thrown when 'overriding' a static method.
- * @run main FinalStatic
+ * @run main/othervm -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm FinalStatic
  */
 
 import java.lang.reflect.*;
--- a/test/runtime/lambda-features/TestConcreteClassWithAbstractMethod.java	Thu Mar 05 15:21:35 2015 -0800
+++ b/test/runtime/lambda-features/TestConcreteClassWithAbstractMethod.java	Fri Mar 06 14:27:49 2015 -0800
@@ -26,7 +26,7 @@
  * @test
  * @bug 8032010
  * @summary method lookup on an abstract method in a concrete class should be successful
- * @run main TestConcreteClassWithAbstractMethod
+ * @run main/othervm -XX:AddModuleExports=java.base/jdk.internal.org.objectweb.asm TestConcreteClassWithAbstractMethod
  */
 
 import jdk.internal.org.objectweb.asm.ClassWriter;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/modules/AccessCheckExp.java	Fri Mar 06 14:27:49 2015 -0800
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @compile p2/c2.java
+ * @compile p1/c1.java
+ * @build AccessCheckExp
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:AddModuleExports=java.base/sun.misc -Dsun.reflect.useHotSpotAccessCheck=true AccessCheckExp
+ *
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:AddModuleExports=java.base/sun.misc -Dsun.reflect.useHotSpotAccessCheck=false AccessCheckExp
+ */
+
+import java.lang.reflect.Module;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class AccessCheckExp {
+
+    // Test that if module1 can read module2, but package p2 in module2 is not
+    // exported then class p1.c1 in module1 can not read p2.c2 in module2.
+    public static void main(String args[]) throws Throwable {
+        Object m1, m2;
+
+        // Get the java.lang.reflect.Module object for module java.base.
+        Class jlObject = Class.forName("java.lang.Object");
+        Object jlObject_jlrM = jlObject.getModule();
+        assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null");
+
+        // Get the class loader for AccessCheckExp and assume it's also used to
+        // load classes p1.c1 and p2.c2.
+        ClassLoader this_cldr = AccessCheckExp.class.getClassLoader();
+
+        // Define a module for p1.
+        m1 = ModuleHelper.ModuleObject("module1", this_cldr, new String[] { "p1" });
+        assertNotNull(m1, "Module should not be null");
+        ModuleHelper.DefineModule(m1, "9.0", "m1/here", new String[] { "p1" });
+        ModuleHelper.AddReadsModule(m1, jlObject_jlrM);
+
+        // Define a module for p2.
+        m2 = ModuleHelper.ModuleObject("module2", this_cldr, new String[] { "p2" });
+        assertNotNull(m2, "Module should not be null");
+        ModuleHelper.DefineModule(m2, "9.0", "m2/there", new String[] { "p2" });
+        ModuleHelper.AddReadsModule(m2, jlObject_jlrM);
+
+        // Make package p1 in m1 visible to everyone.
+        ModuleHelper.AddModuleExports(m1, "p1", null);
+
+        // p1.c1's ctor tries to call a method in p2.c2, but p2.c2 is not
+        // exported.  So should get IllegalAccessError.
+        ModuleHelper.AddReadsModule(m1, m2);
+
+        Class p1_c1_class = Class.forName("p1.c1");
+        try {
+            p1_c1_class.newInstance();
+            throw new RuntimeException("Failed to get IAE (p2 in m2 is not exported");
+        } catch (IllegalAccessError f) {
+            System.out.println(f.getMessage());
+            if (!f.getMessage().contains("not exported")) {
+                throw new RuntimeException("Wrong message: " + f.getMessage());
+            }
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/modules/AccessCheckRead.java	Fri Mar 06 14:27:49 2015 -0800
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See