8177530: Module system implementation refresh (4/2017)

Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Reviewed-by: lfoltan, sspitsyn
This commit is contained in:
Alan Bateman 2017-04-07 08:04:46 +00:00
parent 4ffa7d7bfc
commit a3ab143c64
90 changed files with 477 additions and 464 deletions

View file

@ -28,6 +28,7 @@ import java.util.Formatter;
import java.util.Iterator; import java.util.Iterator;
import java.util.ServiceConfigurationError; import java.util.ServiceConfigurationError;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import java.util.Set;
/** /**
* A mechanism for accessing service providers via JVMCI. * A mechanism for accessing service providers via JVMCI.
@ -108,7 +109,7 @@ public final class Services {
Object jvmci = invoke(getModule, Services.class); Object jvmci = invoke(getModule, Services.class);
Object requestorModule = invoke(getModule, requestor); Object requestorModule = invoke(getModule, requestor);
if (jvmci != requestorModule) { if (jvmci != requestorModule) {
String[] packages = invoke(getPackages, jvmci); Set<String> packages = invoke(getPackages, jvmci);
for (String pkg : packages) { for (String pkg : packages) {
// Export all JVMCI packages dynamically instead // Export all JVMCI packages dynamically instead
// of requiring a long list of --add-exports // of requiring a long list of --add-exports

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -58,22 +58,22 @@ public final class ModuleAPI {
public static final ModuleAPI addExports; public static final ModuleAPI addExports;
/** /**
* {@code java.lang.reflect.Module.getResourceAsStream(String)}. * {@code java.lang.Module.getResourceAsStream(String)}.
*/ */
public static final ModuleAPI getResourceAsStream; public static final ModuleAPI getResourceAsStream;
/** /**
* {@code java.lang.reflect.Module.canRead(Module)}. * {@code java.lang.Module.canRead(Module)}.
*/ */
public static final ModuleAPI canRead; public static final ModuleAPI canRead;
/** /**
* {@code java.lang.reflect.Module.isExported(String)}. * {@code java.lang.Module.isExported(String)}.
*/ */
public static final ModuleAPI isExported; public static final ModuleAPI isExported;
/** /**
* {@code java.lang.reflect.Module.isExported(String, Module)}. * {@code java.lang.Module.isExported(String, Module)}.
*/ */
public static final ModuleAPI isExportedTo; public static final ModuleAPI isExportedTo;

View file

@ -29,14 +29,14 @@ package org.graalvm.compiler.test;
public class ExportingClassLoader extends ClassLoader { public class ExportingClassLoader extends ClassLoader {
public ExportingClassLoader() { public ExportingClassLoader() {
if (!GraalTest.Java8OrEarlier) { if (!GraalTest.Java8OrEarlier) {
JLRModule.fromClass(getClass()).exportAllPackagesTo(JLRModule.getUnnamedModuleFor(this)); JLModule.fromClass(getClass()).exportAllPackagesTo(JLModule.getUnnamedModuleFor(this));
} }
} }
public ExportingClassLoader(ClassLoader parent) { public ExportingClassLoader(ClassLoader parent) {
super(parent); super(parent);
if (!GraalTest.Java8OrEarlier) { if (!GraalTest.Java8OrEarlier) {
JLRModule.fromClass(getClass()).exportAllPackagesTo(JLRModule.getUnnamedModuleFor(this)); JLModule.fromClass(getClass()).exportAllPackagesTo(JLModule.getUnnamedModuleFor(this));
} }
} }
} }

View file

@ -23,22 +23,23 @@
package org.graalvm.compiler.test; package org.graalvm.compiler.test;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Set;
/** /**
* Facade for the {@code java.lang.reflect.Module} class introduced in JDK9 that allows tests to be * Facade for the {@code java.lang.Module} class introduced in JDK9 that allows tests to be
* developed against JDK8 but use module logic if deployed on JDK9. * developed against JDK8 but use module logic if deployed on JDK9.
*/ */
public class JLRModule { public class JLModule {
static { static {
if (GraalTest.Java8OrEarlier) { if (GraalTest.Java8OrEarlier) {
throw new AssertionError("Use of " + JLRModule.class + " only allowed if " + GraalTest.class.getName() + ".JDK8OrEarlier is false"); throw new AssertionError("Use of " + JLModule.class + " only allowed if " + GraalTest.class.getName() + ".JDK8OrEarlier is false");
} }
} }
private final Object realModule; private final Object realModule;
public JLRModule(Object module) { public JLModule(Object module) {
this.realModule = module; this.realModule = module;
} }
@ -51,7 +52,7 @@ public class JLRModule {
private static final Method addExportsMethod; private static final Method addExportsMethod;
static { static {
try { try {
moduleClass = Class.forName("java.lang.reflect.Module"); moduleClass = Class.forName("java.lang.Module");
getModuleMethod = Class.class.getMethod("getModule"); getModuleMethod = Class.class.getMethod("getModule");
getUnnamedModuleMethod = ClassLoader.class.getMethod("getUnnamedModule"); getUnnamedModuleMethod = ClassLoader.class.getMethod("getUnnamedModule");
getPackagesMethod = moduleClass.getMethod("getPackages"); getPackagesMethod = moduleClass.getMethod("getPackages");
@ -63,17 +64,17 @@ public class JLRModule {
} }
} }
public static JLRModule fromClass(Class<?> cls) { public static JLModule fromClass(Class<?> cls) {
try { try {
return new JLRModule(getModuleMethod.invoke(cls)); return new JLModule(getModuleMethod.invoke(cls));
} catch (Exception e) { } catch (Exception e) {
throw new AssertionError(e); throw new AssertionError(e);
} }
} }
public static JLRModule getUnnamedModuleFor(ClassLoader cl) { public static JLModule getUnnamedModuleFor(ClassLoader cl) {
try { try {
return new JLRModule(getUnnamedModuleMethod.invoke(cl)); return new JLModule(getUnnamedModuleMethod.invoke(cl));
} catch (Exception e) { } catch (Exception e) {
throw new AssertionError(e); throw new AssertionError(e);
} }
@ -82,7 +83,7 @@ public class JLRModule {
/** /**
* Exports all packages in this module to a given module. * Exports all packages in this module to a given module.
*/ */
public void exportAllPackagesTo(JLRModule module) { public void exportAllPackagesTo(JLModule module) {
if (this != module) { if (this != module) {
for (String pkg : getPackages()) { for (String pkg : getPackages()) {
// Export all JVMCI packages dynamically instead // Export all JVMCI packages dynamically instead
@ -95,9 +96,9 @@ public class JLRModule {
} }
} }
public String[] getPackages() { public Set<String> getPackages() {
try { try {
return (String[]) getPackagesMethod.invoke(realModule); return (Set<String>) getPackagesMethod.invoke(realModule);
} catch (Exception e) { } catch (Exception e) {
throw new AssertionError(e); throw new AssertionError(e);
} }
@ -111,7 +112,7 @@ public class JLRModule {
} }
} }
public boolean isExported(String pn, JLRModule other) { public boolean isExported(String pn, JLModule other) {
try { try {
return (Boolean) isExported2Method.invoke(realModule, pn, other.realModule); return (Boolean) isExported2Method.invoke(realModule, pn, other.realModule);
} catch (Exception e) { } catch (Exception e) {
@ -119,7 +120,7 @@ public class JLRModule {
} }
} }
public void addExports(String pn, JLRModule other) { public void addExports(String pn, JLModule other) {
try { try {
addExportsMethod.invoke(realModule, pn, other.realModule); addExportsMethod.invoke(realModule, pn, other.realModule);
} catch (Exception e) { } catch (Exception e) {

View file

@ -5406,7 +5406,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa
ModuleEntry* module_entry = ik->module(); ModuleEntry* module_entry = ik->module();
assert(module_entry != NULL, "module_entry should always be set"); assert(module_entry != NULL, "module_entry should always be set");
// Obtain java.lang.reflect.Module // Obtain java.lang.Module
Handle module_handle(THREAD, JNIHandles::resolve(module_entry->module())); Handle module_handle(THREAD, JNIHandles::resolve(module_entry->module()));
// Allocate mirror and initialize static fields // Allocate mirror and initialize static fields

View file

@ -773,13 +773,13 @@ void java_lang_Class::initialize_mirror_fields(KlassHandle k,
InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK); InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK);
} }
// Set the java.lang.reflect.Module module field in the java_lang_Class mirror // Set the java.lang.Module module field in the java_lang_Class mirror
void java_lang_Class::set_mirror_module_field(KlassHandle k, Handle mirror, Handle module, TRAPS) { void java_lang_Class::set_mirror_module_field(KlassHandle k, Handle mirror, Handle module, TRAPS) {
if (module.is_null()) { if (module.is_null()) {
// During startup, the module may be NULL only if java.base has not been defined yet. // During startup, the module may be NULL only if java.base has not been defined yet.
// Put the class on the fixup_module_list to patch later when the java.lang.reflect.Module // Put the class on the fixup_module_list to patch later when the java.lang.Module
// for java.base is known. // for java.base is known.
assert(!Universe::is_module_initialized(), "Incorrect java.lang.reflect.Module pre module system initialization"); assert(!Universe::is_module_initialized(), "Incorrect java.lang.Module pre module system initialization");
bool javabase_was_defined = false; bool javabase_was_defined = false;
{ {
@ -810,7 +810,7 @@ void java_lang_Class::set_mirror_module_field(KlassHandle k, Handle mirror, Hand
assert(Universe::is_module_initialized() || assert(Universe::is_module_initialized() ||
(ModuleEntryTable::javabase_defined() && (ModuleEntryTable::javabase_defined() &&
(module() == JNIHandles::resolve(ModuleEntryTable::javabase_moduleEntry()->module()))), (module() == JNIHandles::resolve(ModuleEntryTable::javabase_moduleEntry()->module()))),
"Incorrect java.lang.reflect.Module specification while creating mirror"); "Incorrect java.lang.Module specification while creating mirror");
set_module(mirror(), module()); set_module(mirror(), module());
} }
} }
@ -2804,28 +2804,28 @@ void java_lang_reflect_Parameter::set_executable(oop param, oop value) {
} }
int java_lang_reflect_Module::loader_offset; int java_lang_Module::loader_offset;
int java_lang_reflect_Module::name_offset; int java_lang_Module::name_offset;
int java_lang_reflect_Module::_module_entry_offset = -1; int java_lang_Module::_module_entry_offset = -1;
Handle java_lang_reflect_Module::create(Handle loader, Handle module_name, TRAPS) { Handle java_lang_Module::create(Handle loader, Handle module_name, TRAPS) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
Symbol* name = vmSymbols::java_lang_reflect_Module(); Symbol* name = vmSymbols::java_lang_Module();
Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
instanceKlassHandle klass (THREAD, k); instanceKlassHandle klass (THREAD, k);
Handle jlrmh = klass->allocate_instance_handle(CHECK_NH); Handle jlmh = klass->allocate_instance_handle(CHECK_NH);
JavaValue result(T_VOID); JavaValue result(T_VOID);
JavaCalls::call_special(&result, jlrmh, KlassHandle(THREAD, klass()), JavaCalls::call_special(&result, jlmh, KlassHandle(THREAD, klass()),
vmSymbols::object_initializer_name(), vmSymbols::object_initializer_name(),
vmSymbols::java_lang_reflect_module_init_signature(), vmSymbols::java_lang_module_init_signature(),
loader, module_name, CHECK_NH); loader, module_name, CHECK_NH);
return jlrmh; return jlmh;
} }
void java_lang_reflect_Module::compute_offsets() { void java_lang_Module::compute_offsets() {
Klass* k = SystemDictionary::reflect_Module_klass(); Klass* k = SystemDictionary::Module_klass();
if(NULL != k) { if(NULL != k) {
compute_offset(loader_offset, k, vmSymbols::loader_name(), vmSymbols::classloader_signature()); compute_offset(loader_offset, k, vmSymbols::loader_name(), vmSymbols::classloader_signature());
compute_offset(name_offset, k, vmSymbols::name_name(), vmSymbols::string_signature()); compute_offset(name_offset, k, vmSymbols::name_name(), vmSymbols::string_signature());
@ -2834,27 +2834,27 @@ void java_lang_reflect_Module::compute_offsets() {
} }
oop java_lang_reflect_Module::loader(oop module) { oop java_lang_Module::loader(oop module) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
return module->obj_field(loader_offset); return module->obj_field(loader_offset);
} }
void java_lang_reflect_Module::set_loader(oop module, oop value) { void java_lang_Module::set_loader(oop module, oop value) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
module->obj_field_put(loader_offset, value); module->obj_field_put(loader_offset, value);
} }
oop java_lang_reflect_Module::name(oop module) { oop java_lang_Module::name(oop module) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
return module->obj_field(name_offset); return module->obj_field(name_offset);
} }
void java_lang_reflect_Module::set_name(oop module, oop value) { void java_lang_Module::set_name(oop module, oop value) {
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
module->obj_field_put(name_offset, value); module->obj_field_put(name_offset, value);
} }
ModuleEntry* java_lang_reflect_Module::module_entry(oop module, TRAPS) { ModuleEntry* java_lang_Module::module_entry(oop module, TRAPS) {
assert(_module_entry_offset != -1, "Uninitialized module_entry_offset"); assert(_module_entry_offset != -1, "Uninitialized module_entry_offset");
assert(module != NULL, "module can't be null"); assert(module != NULL, "module can't be null");
assert(module->is_oop(), "module must be oop"); assert(module->is_oop(), "module must be oop");
@ -2863,7 +2863,7 @@ ModuleEntry* java_lang_reflect_Module::module_entry(oop module, TRAPS) {
if (module_entry == NULL) { if (module_entry == NULL) {
// If the inject field containing the ModuleEntry* is null then return the // If the inject field containing the ModuleEntry* is null then return the
// class loader's unnamed module. // class loader's unnamed module.
oop loader = java_lang_reflect_Module::loader(module); oop loader = java_lang_Module::loader(module);
Handle h_loader = Handle(THREAD, loader); Handle h_loader = Handle(THREAD, loader);
ClassLoaderData* loader_cld = SystemDictionary::register_loader(h_loader, CHECK_NULL); ClassLoaderData* loader_cld = SystemDictionary::register_loader(h_loader, CHECK_NULL);
return loader_cld->modules()->unnamed_module(); return loader_cld->modules()->unnamed_module();
@ -2871,7 +2871,7 @@ ModuleEntry* java_lang_reflect_Module::module_entry(oop module, TRAPS) {
return module_entry; return module_entry;
} }
void java_lang_reflect_Module::set_module_entry(oop module, ModuleEntry* module_entry) { void java_lang_Module::set_module_entry(oop module, ModuleEntry* module_entry) {
assert(_module_entry_offset != -1, "Uninitialized module_entry_offset"); assert(_module_entry_offset != -1, "Uninitialized module_entry_offset");
assert(module != NULL, "module can't be null"); assert(module != NULL, "module can't be null");
assert(module->is_oop(), "module must be oop"); assert(module->is_oop(), "module must be oop");
@ -3877,7 +3877,7 @@ void JavaClasses::compute_offsets() {
reflect_ConstantPool::compute_offsets(); reflect_ConstantPool::compute_offsets();
reflect_UnsafeStaticFieldAccessorImpl::compute_offsets(); reflect_UnsafeStaticFieldAccessorImpl::compute_offsets();
java_lang_reflect_Parameter::compute_offsets(); java_lang_reflect_Parameter::compute_offsets();
java_lang_reflect_Module::compute_offsets(); java_lang_Module::compute_offsets();
java_lang_StackFrameInfo::compute_offsets(); java_lang_StackFrameInfo::compute_offsets();
java_lang_LiveStackFrameInfo::compute_offsets(); java_lang_LiveStackFrameInfo::compute_offsets();

View file

@ -755,9 +755,9 @@ class java_lang_reflect_Parameter {
}; };
#define MODULE_INJECTED_FIELDS(macro) \ #define MODULE_INJECTED_FIELDS(macro) \
macro(java_lang_reflect_Module, module_entry, intptr_signature, false) macro(java_lang_Module, module_entry, intptr_signature, false)
class java_lang_reflect_Module { class java_lang_Module {
private: private:
static int loader_offset; static int loader_offset;
static int name_offset; static int name_offset;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -162,8 +162,8 @@ inline bool java_lang_invoke_DirectMethodHandle::is_instance(oop obj) {
return obj != NULL && is_subclass(obj->klass()); return obj != NULL && is_subclass(obj->klass());
} }
inline bool java_lang_reflect_Module::is_instance(oop obj) { inline bool java_lang_Module::is_instance(oop obj) {
return obj != NULL && obj->klass() == SystemDictionary::reflect_Module_klass(); return obj != NULL && obj->klass() == SystemDictionary::Module_klass();
} }
inline int Backtrace::merge_bci_and_version(int bci, int version) { inline int Backtrace::merge_bci_and_version(int bci, int version) {

View file

@ -266,19 +266,19 @@ void ModuleEntryTable::create_unnamed_module(ClassLoaderData* loader_data) {
// Each ModuleEntryTable has exactly one unnamed module // Each ModuleEntryTable has exactly one unnamed module
if (loader_data->is_the_null_class_loader_data()) { if (loader_data->is_the_null_class_loader_data()) {
// For the boot loader, the java.lang.reflect.Module for the unnamed module // For the boot loader, the java.lang.Module for the unnamed module
// is not known until a call to JVM_SetBootLoaderUnnamedModule is made. At // is not known until a call to JVM_SetBootLoaderUnnamedModule is made. At
// this point initially create the ModuleEntry for the unnamed module. // this point initially create the ModuleEntry for the unnamed module.
_unnamed_module = new_entry(0, Handle(NULL), NULL, NULL, NULL, loader_data); _unnamed_module = new_entry(0, Handle(NULL), NULL, NULL, NULL, loader_data);
} else { } else {
// For all other class loaders the java.lang.reflect.Module for their // For all other class loaders the java.lang.Module for their
// corresponding unnamed module can be found in the java.lang.ClassLoader object. // corresponding unnamed module can be found in the java.lang.ClassLoader object.
oop module = java_lang_ClassLoader::unnamedModule(loader_data->class_loader()); oop module = java_lang_ClassLoader::unnamedModule(loader_data->class_loader());
_unnamed_module = new_entry(0, Handle(module), NULL, NULL, NULL, loader_data); _unnamed_module = new_entry(0, Handle(module), NULL, NULL, NULL, loader_data);
// Store pointer to the ModuleEntry in the unnamed module's java.lang.reflect.Module // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module
// object. // object.
java_lang_reflect_Module::set_module_entry(module, _unnamed_module); java_lang_Module::set_module_entry(module, _unnamed_module);
} }
// Add to bucket 0, no name to hash on // Add to bucket 0, no name to hash on
@ -388,27 +388,27 @@ void ModuleEntryTable::finalize_javabase(Handle module_handle, Symbol* version,
fatal("Unable to finalize module definition for " JAVA_BASE_NAME); fatal("Unable to finalize module definition for " JAVA_BASE_NAME);
} }
// Set java.lang.reflect.Module, version and location for java.base // Set java.lang.Module, version and location for java.base
ModuleEntry* jb_module = javabase_moduleEntry(); ModuleEntry* jb_module = javabase_moduleEntry();
assert(jb_module != NULL, JAVA_BASE_NAME " ModuleEntry not defined"); assert(jb_module != NULL, JAVA_BASE_NAME " ModuleEntry not defined");
jb_module->set_version(version); jb_module->set_version(version);
jb_module->set_location(location); jb_module->set_location(location);
// Once java.base's ModuleEntry _module field is set with the known // Once java.base's ModuleEntry _module field is set with the known
// java.lang.reflect.Module, java.base is considered "defined" to the VM. // java.lang.Module, java.base is considered "defined" to the VM.
jb_module->set_module(boot_loader_data->add_handle(module_handle)); jb_module->set_module(boot_loader_data->add_handle(module_handle));
// Store pointer to the ModuleEntry for java.base in the java.lang.reflect.Module object. // Store pointer to the ModuleEntry for java.base in the java.lang.Module object.
java_lang_reflect_Module::set_module_entry(module_handle(), jb_module); java_lang_Module::set_module_entry(module_handle(), jb_module);
} }
// Within java.lang.Class instances there is a java.lang.reflect.Module field // Within java.lang.Class instances there is a java.lang.Module field that must
// that must be set with the defining module. During startup, prior to java.base's // be set with the defining module. During startup, prior to java.base's definition,
// definition, classes needing their module field set are added to the fixup_module_list. // classes needing their module field set are added to the fixup_module_list.
// Their module field is set once java.base's java.lang.reflect.Module is known to the VM. // Their module field is set once java.base's java.lang.Module is known to the VM.
void ModuleEntryTable::patch_javabase_entries(Handle module_handle) { void ModuleEntryTable::patch_javabase_entries(Handle module_handle) {
if (module_handle.is_null()) { if (module_handle.is_null()) {
fatal("Unable to patch the module field of classes loaded prior to " fatal("Unable to patch the module field of classes loaded prior to "
JAVA_BASE_NAME "'s definition, invalid java.lang.reflect.Module"); JAVA_BASE_NAME "'s definition, invalid java.lang.Module");
} }
// Do the fixups for the basic primitive types // Do the fixups for the basic primitive types

View file

@ -45,7 +45,7 @@ class ModuleClosure;
// A ModuleEntry describes a module that has been defined by a call to JVM_DefineModule. // A ModuleEntry describes a module that has been defined by a call to JVM_DefineModule.
// It contains: // It contains:
// - Symbol* containing the module's name. // - Symbol* containing the module's name.
// - pointer to the java.lang.reflect.Module for this module. // - pointer to the java.lang.Module for this module.
// - pointer to the java.security.ProtectionDomain shared by classes defined to this module. // - pointer to the java.security.ProtectionDomain shared by classes defined to this module.
// - ClassLoaderData*, class loader of this module. // - ClassLoaderData*, class loader of this module.
// - a growable array containg other module entries that this module can read. // - a growable array containg other module entries that this module can read.
@ -55,7 +55,7 @@ class ModuleClosure;
// data structure. // data structure.
class ModuleEntry : public HashtableEntry<Symbol*, mtModule> { class ModuleEntry : public HashtableEntry<Symbol*, mtModule> {
private: private:
jobject _module; // java.lang.reflect.Module jobject _module; // java.lang.Module
jobject _pd; // java.security.ProtectionDomain, cached jobject _pd; // java.security.ProtectionDomain, cached
// for shared classes from this module // for shared classes from this module
ClassLoaderData* _loader_data; ClassLoaderData* _loader_data;

View file

@ -62,7 +62,7 @@ bool Modules::verify_package_name(const char* package_name) {
} }
static char* get_module_name(oop module, TRAPS) { static char* get_module_name(oop module, TRAPS) {
oop name_oop = java_lang_reflect_Module::name(module); oop name_oop = java_lang_Module::name(module);
if (name_oop == NULL) { if (name_oop == NULL) {
THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(), "Null module name"); THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(), "Null module name");
} }
@ -98,11 +98,11 @@ static PackageEntryTable* get_package_entry_table(Handle h_loader, TRAPS) {
static ModuleEntry* get_module_entry(jobject module, TRAPS) { static ModuleEntry* get_module_entry(jobject module, TRAPS) {
Handle module_h(THREAD, JNIHandles::resolve(module)); Handle module_h(THREAD, JNIHandles::resolve(module));
if (!java_lang_reflect_Module::is_instance(module_h())) { if (!java_lang_Module::is_instance(module_h())) {
THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(),
"module is not an instance of type java.lang.reflect.Module"); "module is not an instance of type java.lang.Module");
} }
return java_lang_reflect_Module::module_entry(module_h(), CHECK_NULL); return java_lang_Module::module_entry(module_h(), CHECK_NULL);
} }
static PackageEntry* get_package_entry(ModuleEntry* module_entry, const char* package_name, TRAPS) { static PackageEntry* get_package_entry(ModuleEntry* module_entry, const char* package_name, TRAPS) {
@ -181,7 +181,7 @@ static void define_javabase_module(jobject module, jstring version,
} }
// Validate java_base's loader is the boot loader. // Validate java_base's loader is the boot loader.
oop loader = java_lang_reflect_Module::loader(module_handle()); oop loader = java_lang_Module::loader(module_handle());
if (loader != NULL) { if (loader != NULL) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"Class loader must be the boot class loader"); "Class loader must be the boot class loader");
@ -234,7 +234,7 @@ static void define_javabase_module(jobject module, jstring version,
// Only the thread that actually defined the base module will get here, // Only the thread that actually defined the base module will get here,
// so no locking is needed. // so no locking is needed.
// Patch any previously loaded class's module field with java.base's java.lang.reflect.Module. // Patch any previously loaded class's module field with java.base's java.lang.Module.
ModuleEntryTable::patch_javabase_entries(module_handle); ModuleEntryTable::patch_javabase_entries(module_handle);
log_debug(modules)("define_javabase_module(): Definition of module: " log_debug(modules)("define_javabase_module(): Definition of module: "
@ -284,9 +284,9 @@ void Modules::define_module(jobject module, jstring version,
} }
Handle module_handle(THREAD, JNIHandles::resolve(module)); Handle module_handle(THREAD, JNIHandles::resolve(module));
if (!java_lang_reflect_Module::is_instance(module_handle())) { if (!java_lang_Module::is_instance(module_handle())) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"module is not an instance of type java.lang.reflect.Module"); "module is not an instance of type java.lang.Module");
} }
char* module_name = get_module_name(module_handle(), CHECK); char* module_name = get_module_name(module_handle(), CHECK);
@ -303,7 +303,7 @@ void Modules::define_module(jobject module, jstring version,
const char* module_version = get_module_version(version); const char* module_version = get_module_version(version);
oop loader = java_lang_reflect_Module::loader(module_handle()); oop loader = java_lang_Module::loader(module_handle());
// Make sure loader is not the jdk.internal.reflect.DelegatingClassLoader. // Make sure loader is not the jdk.internal.reflect.DelegatingClassLoader.
if (loader != java_lang_ClassLoader::non_reflection_class_loader(loader)) { if (loader != java_lang_ClassLoader::non_reflection_class_loader(loader)) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
@ -424,8 +424,8 @@ void Modules::define_module(jobject module, jstring version,
pkg_list->at(y)->decrement_refcount(); pkg_list->at(y)->decrement_refcount();
} }
// Store pointer to ModuleEntry record in java.lang.reflect.Module object. // Store pointer to ModuleEntry record in java.lang.Module object.
java_lang_reflect_Module::set_module_entry(module_handle(), module_entry); java_lang_Module::set_module_entry(module_handle(), module_entry);
} }
} }
} // Release the lock } // Release the lock
@ -467,20 +467,20 @@ void Modules::set_bootloader_unnamed_module(jobject module, TRAPS) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null module object"); THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null module object");
} }
Handle module_handle(THREAD, JNIHandles::resolve(module)); Handle module_handle(THREAD, JNIHandles::resolve(module));
if (!java_lang_reflect_Module::is_instance(module_handle())) { if (!java_lang_Module::is_instance(module_handle())) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"module is not an instance of type java.lang.reflect.Module"); "module is not an instance of type java.lang.Module");
} }
// Ensure that this is an unnamed module // Ensure that this is an unnamed module
oop name = java_lang_reflect_Module::name(module_handle()); oop name = java_lang_Module::name(module_handle());
if (name != NULL) { if (name != NULL) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"boot loader's unnamed module's java.lang.reflect.Module has a name"); "boot loader's unnamed module's java.lang.Module has a name");
} }
// Validate java_base's loader is the boot loader. // Validate java_base's loader is the boot loader.
oop loader = java_lang_reflect_Module::loader(module_handle()); oop loader = java_lang_Module::loader(module_handle());
if (loader != NULL) { if (loader != NULL) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"Class loader must be the boot class loader"); "Class loader must be the boot class loader");
@ -492,12 +492,12 @@ void Modules::set_bootloader_unnamed_module(jobject module, TRAPS) {
// Ensure the boot loader's PackageEntryTable has been created // Ensure the boot loader's PackageEntryTable has been created
ModuleEntryTable* module_table = get_module_entry_table(h_loader, CHECK); ModuleEntryTable* module_table = get_module_entry_table(h_loader, CHECK);
// Set java.lang.reflect.Module for the boot loader's unnamed module // Set java.lang.Module for the boot loader's unnamed module
ModuleEntry* unnamed_module = module_table->unnamed_module(); ModuleEntry* unnamed_module = module_table->unnamed_module();
assert(unnamed_module != NULL, "boot loader's unnamed ModuleEntry not defined"); assert(unnamed_module != NULL, "boot loader's unnamed ModuleEntry not defined");
unnamed_module->set_module(ClassLoaderData::the_null_class_loader_data()->add_handle(module_handle)); unnamed_module->set_module(ClassLoaderData::the_null_class_loader_data()->add_handle(module_handle));
// Store pointer to the ModuleEntry in the unnamed module's java.lang.reflect.Module object. // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
java_lang_reflect_Module::set_module_entry(module_handle(), unnamed_module); java_lang_Module::set_module_entry(module_handle(), unnamed_module);
} }
void Modules::add_module_exports(jobject from_module, const char* package_name, jobject to_module, TRAPS) { void Modules::add_module_exports(jobject from_module, const char* package_name, jobject to_module, TRAPS) {
@ -627,13 +627,13 @@ jobject Modules::get_module(jclass clazz, TRAPS) {
oop module = java_lang_Class::module(mirror); oop module = java_lang_Class::module(mirror);
assert(module != NULL, "java.lang.Class module field not set"); assert(module != NULL, "java.lang.Class module field not set");
assert(java_lang_reflect_Module::is_instance(module), "module is not an instance of type java.lang.reflect.Module"); assert(java_lang_Module::is_instance(module), "module is not an instance of type java.lang.Module");
if (log_is_enabled(Debug, modules)) { if (log_is_enabled(Debug, modules)) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
outputStream* logst = Log(modules)::debug_stream(); outputStream* logst = Log(modules)::debug_stream();
Klass* klass = java_lang_Class::as_Klass(mirror); Klass* klass = java_lang_Class::as_Klass(mirror);
oop module_name = java_lang_reflect_Module::name(module); oop module_name = java_lang_Module::name(module);
if (module_name != NULL) { if (module_name != NULL) {
logst->print("get_module(): module "); logst->print("get_module(): module ");
java_lang_String::print(module_name, tty); java_lang_String::print(module_name, tty);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -55,12 +55,12 @@ public:
jstring location, const char* const* packages, jstring location, const char* const* packages,
jsize num_packages, TRAPS); jsize num_packages, TRAPS);
// Provides the java.lang.reflect.Module for the unnamed module defined // Provides the java.lang.Module for the unnamed module defined
// to the boot loader. // to the boot loader.
// //
// IllegalArgumentExceptions are thrown for the following : // IllegalArgumentExceptions are thrown for the following :
// * Module has a name // * Module has a name
// * Module is not a subclass of java.lang.reflect.Module // * Module is not a subclass of java.lang.Module
// * Module's class loader is not the boot loader // * Module's class loader is not the boot loader
// NullPointerExceptions are thrown if module is null. // NullPointerExceptions are thrown if module is null.
static void set_bootloader_unnamed_module(jobject module, TRAPS); static void set_bootloader_unnamed_module(jobject module, TRAPS);
@ -96,10 +96,10 @@ public:
// module does not exist. // module does not exist.
static void add_reads_module(jobject from_module, jobject to_module, TRAPS); static void add_reads_module(jobject from_module, jobject to_module, TRAPS);
// Return the java.lang.reflect.Module object for this class object. // Return the java.lang.Module object for this class object.
static jobject get_module(jclass clazz, TRAPS); static jobject get_module(jclass clazz, TRAPS);
// Return the java.lang.reflect.Module object for this class loader and package. // Return the java.lang.Module object for this class loader and package.
// Returns NULL if the class loader has not loaded any classes in the package. // Returns NULL if the class loader has not loaded any classes in the package.
// The package should contain /'s, not .'s, as in java/lang, not java.lang. // The package should contain /'s, not .'s, as in java/lang, not java.lang.
// NullPointerException is thrown if package is null. // NullPointerException is thrown if package is null.
@ -109,7 +109,7 @@ public:
static jobject get_named_module(Handle h_loader, const char* package, TRAPS); static jobject get_named_module(Handle h_loader, const char* package, TRAPS);
// If package is defined by loader, return the // If package is defined by loader, return the
// java.lang.reflect.Module object for the module in which the package is defined. // java.lang.Module object for the module in which the package is defined.
// Returns NULL if package is invalid or not defined by loader. // Returns NULL if package is invalid or not defined by loader.
static jobject get_module(Symbol* package_name, Handle h_loader, TRAPS); static jobject get_module(Symbol* package_name, Handle h_loader, TRAPS);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -133,9 +133,9 @@ class SymbolPropertyTable;
do_klass(Thread_klass, java_lang_Thread, Pre ) \ do_klass(Thread_klass, java_lang_Thread, Pre ) \
do_klass(ThreadGroup_klass, java_lang_ThreadGroup, Pre ) \ do_klass(ThreadGroup_klass, java_lang_ThreadGroup, Pre ) \
do_klass(Properties_klass, java_util_Properties, Pre ) \ do_klass(Properties_klass, java_util_Properties, Pre ) \
do_klass(Module_klass, java_lang_Module, Pre ) \
do_klass(reflect_AccessibleObject_klass, java_lang_reflect_AccessibleObject, Pre ) \ do_klass(reflect_AccessibleObject_klass, java_lang_reflect_AccessibleObject, Pre ) \
do_klass(reflect_Field_klass, java_lang_reflect_Field, 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_Parameter_klass, java_lang_reflect_Parameter, Opt ) \
do_klass(reflect_Method_klass, java_lang_reflect_Method, Pre ) \ do_klass(reflect_Method_klass, java_lang_reflect_Method, Pre ) \
do_klass(reflect_Constructor_klass, java_lang_reflect_Constructor, Pre ) \ do_klass(reflect_Constructor_klass, java_lang_reflect_Constructor, Pre ) \

View file

@ -56,6 +56,7 @@
template(java_lang_Object, "java/lang/Object") \ template(java_lang_Object, "java/lang/Object") \
template(java_lang_Class, "java/lang/Class") \ template(java_lang_Class, "java/lang/Class") \
template(java_lang_Package, "java/lang/Package") \ template(java_lang_Package, "java/lang/Package") \
template(java_lang_Module, "java/lang/Module") \
template(java_lang_String, "java/lang/String") \ template(java_lang_String, "java/lang/String") \
template(java_lang_StringLatin1, "java/lang/StringLatin1") \ template(java_lang_StringLatin1, "java/lang/StringLatin1") \
template(java_lang_StringUTF16, "java/lang/StringUTF16") \ template(java_lang_StringUTF16, "java/lang/StringUTF16") \
@ -90,7 +91,6 @@
template(java_lang_reflect_Method, "java/lang/reflect/Method") \ template(java_lang_reflect_Method, "java/lang/reflect/Method") \
template(java_lang_reflect_Constructor, "java/lang/reflect/Constructor") \ template(java_lang_reflect_Constructor, "java/lang/reflect/Constructor") \
template(java_lang_reflect_Field, "java/lang/reflect/Field") \ 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_Parameter, "java/lang/reflect/Parameter") \
template(java_lang_reflect_Array, "java/lang/reflect/Array") \ template(java_lang_reflect_Array, "java/lang/reflect/Array") \
template(java_lang_StringBuffer, "java/lang/StringBuffer") \ template(java_lang_StringBuffer, "java/lang/StringBuffer") \
@ -136,7 +136,7 @@
template(initPhase1_name, "initPhase1") \ template(initPhase1_name, "initPhase1") \
template(initPhase2_name, "initPhase2") \ template(initPhase2_name, "initPhase2") \
template(initPhase3_name, "initPhase3") \ template(initPhase3_name, "initPhase3") \
template(java_lang_reflect_module_init_signature, "(Ljava/lang/ClassLoader;Ljava/lang/String;)V") \ template(java_lang_module_init_signature, "(Ljava/lang/ClassLoader;Ljava/lang/String;)V") \
\ \
/* class file format tags */ \ /* class file format tags */ \
template(tag_source_file, "SourceFile") \ template(tag_source_file, "SourceFile") \
@ -450,7 +450,7 @@
template(getModule_name, "getModule") \ template(getModule_name, "getModule") \
template(input_stream_void_signature, "(Ljava/io/InputStream;)V") \ template(input_stream_void_signature, "(Ljava/io/InputStream;)V") \
template(definePackage_name, "definePackage") \ template(definePackage_name, "definePackage") \
template(definePackage_signature, "(Ljava/lang/String;Ljava/lang/reflect/Module;)Ljava/lang/Package;") \ template(definePackage_signature, "(Ljava/lang/String;Ljava/lang/Module;)Ljava/lang/Package;") \
template(defineOrCheckPackage_name, "defineOrCheckPackage") \ template(defineOrCheckPackage_name, "defineOrCheckPackage") \
template(defineOrCheckPackage_signature, "(Ljava/lang/String;Ljava/util/jar/Manifest;Ljava/net/URL;)Ljava/lang/Package;") \ template(defineOrCheckPackage_signature, "(Ljava/lang/String;Ljava/util/jar/Manifest;Ljava/net/URL;)Ljava/lang/Package;") \
template(fileToEncodedURL_name, "fileToEncodedURL") \ template(fileToEncodedURL_name, "fileToEncodedURL") \
@ -532,7 +532,7 @@
template(void_class_signature, "()Ljava/lang/Class;") \ template(void_class_signature, "()Ljava/lang/Class;") \
template(void_class_array_signature, "()[Ljava/lang/Class;") \ template(void_class_array_signature, "()[Ljava/lang/Class;") \
template(void_string_signature, "()Ljava/lang/String;") \ template(void_string_signature, "()Ljava/lang/String;") \
template(void_module_signature, "()Ljava/lang/reflect/Module;") \ template(void_module_signature, "()Ljava/lang/Module;") \
template(object_array_object_signature, "([Ljava/lang/Object;)Ljava/lang/Object;") \ template(object_array_object_signature, "([Ljava/lang/Object;)Ljava/lang/Object;") \
template(object_object_array_object_signature, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;")\ template(object_object_array_object_signature, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;")\
template(exception_void_signature, "(Ljava/lang/Exception;)V") \ template(exception_void_signature, "(Ljava/lang/Exception;)V") \
@ -552,7 +552,7 @@
template(reference_signature, "Ljava/lang/ref/Reference;") \ template(reference_signature, "Ljava/lang/ref/Reference;") \
template(sun_misc_Cleaner_signature, "Lsun/misc/Cleaner;") \ template(sun_misc_Cleaner_signature, "Lsun/misc/Cleaner;") \
template(executable_signature, "Ljava/lang/reflect/Executable;") \ template(executable_signature, "Ljava/lang/reflect/Executable;") \
template(module_signature, "Ljava/lang/reflect/Module;") \ template(module_signature, "Ljava/lang/Module;") \
template(concurrenthashmap_signature, "Ljava/util/concurrent/ConcurrentHashMap;") \ template(concurrenthashmap_signature, "Ljava/util/concurrent/ConcurrentHashMap;") \
template(String_StringBuilder_signature, "(Ljava/lang/String;)Ljava/lang/StringBuilder;") \ template(String_StringBuilder_signature, "(Ljava/lang/String;)Ljava/lang/StringBuilder;") \
template(int_StringBuilder_signature, "(I)Ljava/lang/StringBuilder;") \ template(int_StringBuilder_signature, "(I)Ljava/lang/StringBuilder;") \
@ -642,16 +642,16 @@
template(jdk_internal_module_Modules, "jdk/internal/module/Modules") \ template(jdk_internal_module_Modules, "jdk/internal/module/Modules") \
template(jdk_internal_vm_VMSupport, "jdk/internal/vm/VMSupport") \ template(jdk_internal_vm_VMSupport, "jdk/internal/vm/VMSupport") \
template(addReads_name, "addReads") \ template(addReads_name, "addReads") \
template(addReads_signature, "(Ljava/lang/reflect/Module;Ljava/lang/reflect/Module;)V") \ template(addReads_signature, "(Ljava/lang/Module;Ljava/lang/Module;)V") \
template(addExports_name, "addExports") \ template(addExports_name, "addExports") \
template(addOpens_name, "addOpens") \ template(addOpens_name, "addOpens") \
template(addExports_signature, "(Ljava/lang/reflect/Module;Ljava/lang/String;Ljava/lang/reflect/Module;)V") \ template(addExports_signature, "(Ljava/lang/Module;Ljava/lang/String;Ljava/lang/Module;)V") \
template(addUses_name, "addUses") \ template(addUses_name, "addUses") \
template(addUses_signature, "(Ljava/lang/reflect/Module;Ljava/lang/Class;)V") \ template(addUses_signature, "(Ljava/lang/Module;Ljava/lang/Class;)V") \
template(addProvides_name, "addProvides") \ template(addProvides_name, "addProvides") \
template(addProvides_signature, "(Ljava/lang/reflect/Module;Ljava/lang/Class;Ljava/lang/Class;)V") \ template(addProvides_signature, "(Ljava/lang/Module;Ljava/lang/Class;Ljava/lang/Class;)V") \
template(transformedByAgent_name, "transformedByAgent") \ template(transformedByAgent_name, "transformedByAgent") \
template(transformedByAgent_signature, "(Ljava/lang/reflect/Module;)V") \ template(transformedByAgent_signature, "(Ljava/lang/Module;)V") \
template(appendToClassPathForInstrumentation_name, "appendToClassPathForInstrumentation") \ template(appendToClassPathForInstrumentation_name, "appendToClassPathForInstrumentation") \
do_alias(appendToClassPathForInstrumentation_signature, string_void_signature) \ do_alias(appendToClassPathForInstrumentation_signature, string_void_signature) \
template(serializePropertiesToByteArray_name, "serializePropertiesToByteArray") \ template(serializePropertiesToByteArray_name, "serializePropertiesToByteArray") \

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -532,7 +532,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec
} else { } else {
module_entry = ModuleEntryTable::javabase_moduleEntry(); module_entry = ModuleEntryTable::javabase_moduleEntry();
} }
// Obtain java.lang.reflect.Module, if available // Obtain java.lang.Module, if available
Handle module_handle(THREAD, ((module_entry != NULL) ? JNIHandles::resolve(module_entry->module()) : (oop)NULL)); Handle module_handle(THREAD, ((module_entry != NULL) ? JNIHandles::resolve(module_entry->module()) : (oop)NULL));
java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, CHECK); java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, CHECK);
} }

View file

@ -6516,7 +6516,7 @@ class C2 extends C1 implements I2 {
<function id="GetNamedModule" num="40" since="9"> <function id="GetNamedModule" num="40" since="9">
<synopsis>Get Named Module</synopsis> <synopsis>Get Named Module</synopsis>
<description> <description>
Return the <code>java.lang.reflect.Module</code> object for a named Return the <code>java.lang.Module</code> object for a named
module defined to a class loader that contains a given package. module defined to a class loader that contains a given package.
The module is returned via <code>module_ptr</code>. The module is returned via <code>module_ptr</code>.
<p/> <p/>
@ -6554,7 +6554,7 @@ class C2 extends C1 implements I2 {
<param id="module_ptr"> <param id="module_ptr">
<outptr><jobject/></outptr> <outptr><jobject/></outptr>
<description> <description>
On return, points to a <code>java.lang.reflect.Module</code> object On return, points to a <code>java.lang.Module</code> object
or points to <code>NULL</code>. or points to <code>NULL</code>.
</description> </description>
</param> </param>
@ -6599,6 +6599,10 @@ class C2 extends C1 implements I2 {
<error id="JVMTI_ERROR_INVALID_MODULE"> <error id="JVMTI_ERROR_INVALID_MODULE">
If <paramlink id="to_module"></paramlink> is not a module object. If <paramlink id="to_module"></paramlink> is not a module object.
</error> </error>
<error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
if the module cannot be modified.
See <functionlink id="IsModifiableModule"/>.
</error>
</errors> </errors>
</function> </function>
@ -6633,7 +6637,7 @@ class C2 extends C1 implements I2 {
<description> <description>
The module the package is exported to. The module the package is exported to.
If the <code>to_module</code> is not a subclass of If the <code>to_module</code> is not a subclass of
<code>java.lang.reflect.Module</code> this function returns <code>java.lang.Module</code> this function returns
<errorlink id="JVMTI_ERROR_INVALID_MODULE"></errorlink>. <errorlink id="JVMTI_ERROR_INVALID_MODULE"></errorlink>.
</description> </description>
</param> </param>
@ -6649,6 +6653,10 @@ class C2 extends C1 implements I2 {
If the package <paramlink id="pkg_name"></paramlink> If the package <paramlink id="pkg_name"></paramlink>
does not belong to the module. does not belong to the module.
</error> </error>
<error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
if the module cannot be modified.
See <functionlink id="IsModifiableModule"/>.
</error>
</errors> </errors>
</function> </function>
@ -6684,7 +6692,7 @@ class C2 extends C1 implements I2 {
<description> <description>
The module with the package to open. The module with the package to open.
If the <code>to_module</code> is not a subclass of If the <code>to_module</code> is not a subclass of
<code>java.lang.reflect.Module</code> this function returns <code>java.lang.Module</code> this function returns
<errorlink id="JVMTI_ERROR_INVALID_MODULE"></errorlink>. <errorlink id="JVMTI_ERROR_INVALID_MODULE"></errorlink>.
</description> </description>
</param> </param>
@ -6700,6 +6708,10 @@ class C2 extends C1 implements I2 {
If the package <paramlink id="pkg_name"></paramlink> If the package <paramlink id="pkg_name"></paramlink>
does not belong to the module. does not belong to the module.
</error> </error>
<error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
if the module cannot be modified.
See <functionlink id="IsModifiableModule"/>.
</error>
</errors> </errors>
</function> </function>
@ -6737,6 +6749,10 @@ class C2 extends C1 implements I2 {
<error id="JVMTI_ERROR_INVALID_CLASS"> <error id="JVMTI_ERROR_INVALID_CLASS">
If <paramlink id="service"></paramlink> is not a class object. If <paramlink id="service"></paramlink> is not a class object.
</error> </error>
<error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
if the module cannot be modified.
See <functionlink id="IsModifiableModule"/>.
</error>
</errors> </errors>
</function> </function>
@ -6783,6 +6799,44 @@ class C2 extends C1 implements I2 {
<error id="JVMTI_ERROR_INVALID_CLASS"> <error id="JVMTI_ERROR_INVALID_CLASS">
If <paramlink id="impl_class"></paramlink> is not a class object. If <paramlink id="impl_class"></paramlink> is not a class object.
</error> </error>
<error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
if the module cannot be modified.
See <functionlink id="IsModifiableModule"/>.
</error>
</errors>
</function>
<function id="IsModifiableModule" num="99" since="9">
<synopsis>Is Modifiable Module</synopsis>
<description>
Determines whether a module is modifiable.
If a module is modifiable then this module can be updated with
<functionlink id="AddModuleReads"/>, <functionlink id="AddModuleExports"/>,
<functionlink id="AddModuleOpens"/>, <functionlink id="AddModuleUses"/>,
and <functionlink id="AddModuleProvides"/>. If a module is not modifiable
then the module can not be updated with these functions.
</description>
<origin>new</origin>
<capabilities>
</capabilities>
<parameters>
<param id="module">
<ptrtype><jobject/></ptrtype>
<description>
The module to query.
</description>
</param>
<param id="is_modifiable_module_ptr">
<outptr><jboolean/></outptr>
<description>
On return, points to the boolean result of this function.
</description>
</param>
</parameters>
<errors>
<error id="JVMTI_ERROR_INVALID_MODULE">
If <paramlink id="module"></paramlink> is not a module object.
</error>
</errors> </errors>
</function> </function>
@ -7803,6 +7857,10 @@ class C2 extends C1 implements I2 {
A method in the new class version has different modifiers A method in the new class version has different modifiers
than its counterpart in the old class version. than its counterpart in the old class version.
</error> </error>
<error id="JVMTI_ERROR_UNMODIFIABLE_MODULE">
A module cannot be modified.
See <functionlink id="IsModifiableModule"/>.
</error>
</errors> </errors>
</function> </function>
@ -11567,6 +11625,9 @@ myInit() {
<errorid id="JVMTI_ERROR_UNMODIFIABLE_CLASS" num="79"> <errorid id="JVMTI_ERROR_UNMODIFIABLE_CLASS" num="79">
The class cannot be modified. The class cannot be modified.
</errorid> </errorid>
<errorid id="JVMTI_ERROR_UNMODIFIABLE_MODULE" num="80">
The module cannot be modified.
</errorid>
<errorid id="JVMTI_ERROR_NOT_AVAILABLE" num="98"> <errorid id="JVMTI_ERROR_NOT_AVAILABLE" num="98">
The functionality is not available in this virtual machine. The functionality is not available in this virtual machine.
</errorid> </errorid>
@ -14736,6 +14797,7 @@ typedef void (JNICALL *jvmtiEventVMInit)
- Add new functions: - Add new functions:
- GetAllModules - GetAllModules
- AddModuleReads, AddModuleExports, AddModuleOpens, AddModuleUses, AddModuleProvides - AddModuleReads, AddModuleExports, AddModuleOpens, AddModuleUses, AddModuleProvides
- IsModifiableModule
Clarified can_redefine_any_classes, can_retransform_any_classes and IsModifiableClass API to Clarified can_redefine_any_classes, can_retransform_any_classes and IsModifiableClass API to
disallow some implementation defined classes. disallow some implementation defined classes.
</change> </change>

View file

@ -235,12 +235,12 @@ JvmtiEnv::AddModuleReads(jobject module, jobject to_module) {
// check module // check module
Handle h_module(THREAD, JNIHandles::resolve(module)); Handle h_module(THREAD, JNIHandles::resolve(module));
if (!java_lang_reflect_Module::is_instance(h_module())) { if (!java_lang_Module::is_instance(h_module())) {
return JVMTI_ERROR_INVALID_MODULE; return JVMTI_ERROR_INVALID_MODULE;
} }
// check to_module // check to_module
Handle h_to_module(THREAD, JNIHandles::resolve(to_module)); Handle h_to_module(THREAD, JNIHandles::resolve(to_module));
if (!java_lang_reflect_Module::is_instance(h_to_module())) { if (!java_lang_Module::is_instance(h_to_module())) {
return JVMTI_ERROR_INVALID_MODULE; return JVMTI_ERROR_INVALID_MODULE;
} }
return JvmtiExport::add_module_reads(h_module, h_to_module, THREAD); return JvmtiExport::add_module_reads(h_module, h_to_module, THREAD);
@ -257,12 +257,12 @@ JvmtiEnv::AddModuleExports(jobject module, const char* pkg_name, jobject to_modu
// check module // check module
Handle h_module(THREAD, JNIHandles::resolve(module)); Handle h_module(THREAD, JNIHandles::resolve(module));
if (!java_lang_reflect_Module::is_instance(h_module())) { if (!java_lang_Module::is_instance(h_module())) {
return JVMTI_ERROR_INVALID_MODULE; return JVMTI_ERROR_INVALID_MODULE;
} }
// check to_module // check to_module
Handle h_to_module(THREAD, JNIHandles::resolve(to_module)); Handle h_to_module(THREAD, JNIHandles::resolve(to_module));
if (!java_lang_reflect_Module::is_instance(h_to_module())) { if (!java_lang_Module::is_instance(h_to_module())) {
return JVMTI_ERROR_INVALID_MODULE; return JVMTI_ERROR_INVALID_MODULE;
} }
return JvmtiExport::add_module_exports(h_module, h_pkg, h_to_module, THREAD); return JvmtiExport::add_module_exports(h_module, h_pkg, h_to_module, THREAD);
@ -279,12 +279,12 @@ JvmtiEnv::AddModuleOpens(jobject module, const char* pkg_name, jobject to_module
// check module // check module
Handle h_module(THREAD, JNIHandles::resolve(module)); Handle h_module(THREAD, JNIHandles::resolve(module));
if (!java_lang_reflect_Module::is_instance(h_module())) { if (!java_lang_Module::is_instance(h_module())) {
return JVMTI_ERROR_INVALID_MODULE; return JVMTI_ERROR_INVALID_MODULE;
} }
// check to_module // check to_module
Handle h_to_module(THREAD, JNIHandles::resolve(to_module)); Handle h_to_module(THREAD, JNIHandles::resolve(to_module));
if (!java_lang_reflect_Module::is_instance(h_to_module())) { if (!java_lang_Module::is_instance(h_to_module())) {
return JVMTI_ERROR_INVALID_MODULE; return JVMTI_ERROR_INVALID_MODULE;
} }
return JvmtiExport::add_module_opens(h_module, h_pkg, h_to_module, THREAD); return JvmtiExport::add_module_opens(h_module, h_pkg, h_to_module, THREAD);
@ -299,7 +299,7 @@ JvmtiEnv::AddModuleUses(jobject module, jclass service) {
// check module // check module
Handle h_module(THREAD, JNIHandles::resolve(module)); Handle h_module(THREAD, JNIHandles::resolve(module));
if (!java_lang_reflect_Module::is_instance(h_module())) { if (!java_lang_Module::is_instance(h_module())) {
return JVMTI_ERROR_INVALID_MODULE; return JVMTI_ERROR_INVALID_MODULE;
} }
// check service // check service
@ -321,7 +321,7 @@ JvmtiEnv::AddModuleProvides(jobject module, jclass service, jclass impl_class) {
// check module // check module
Handle h_module(THREAD, JNIHandles::resolve(module)); Handle h_module(THREAD, JNIHandles::resolve(module));
if (!java_lang_reflect_Module::is_instance(h_module())) { if (!java_lang_Module::is_instance(h_module())) {
return JVMTI_ERROR_INVALID_MODULE; return JVMTI_ERROR_INVALID_MODULE;
} }
// check service // check service
@ -339,6 +339,22 @@ JvmtiEnv::AddModuleProvides(jobject module, jclass service, jclass impl_class) {
return JvmtiExport::add_module_provides(h_module, h_service, h_impl_class, THREAD); return JvmtiExport::add_module_provides(h_module, h_service, h_impl_class, THREAD);
} /* end AddModuleProvides */ } /* end AddModuleProvides */
// module - pre-checked for NULL
// is_modifiable_class_ptr - pre-checked for NULL
jvmtiError
JvmtiEnv::IsModifiableModule(jobject module, jboolean* is_modifiable_module_ptr) {
JavaThread* THREAD = JavaThread::current();
// check module
Handle h_module(THREAD, JNIHandles::resolve(module));
if (!java_lang_Module::is_instance(h_module())) {
return JVMTI_ERROR_INVALID_MODULE;
}
*is_modifiable_module_ptr = JNI_TRUE;
return JVMTI_ERROR_NONE;
} /* end IsModifiableModule */
// //
// Class functions // Class functions

View file

@ -594,9 +594,9 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
current_class_name, module_from_name, new_class_name, current_class_name, module_from_name, new_class_name,
module_to_name, module_from_name, module_to_name); module_to_name, module_from_name, module_to_name);
} else { } else {
jobject jlrm = module_to->module(); jobject jlm = module_to->module();
assert(jlrm != NULL, "Null jlrm in module_to ModuleEntry"); assert(jlm != NULL, "Null jlm in module_to ModuleEntry");
intptr_t identity_hash = JNIHandles::resolve(jlrm)->identity_hash(); intptr_t identity_hash = JNIHandles::resolve(jlm)->identity_hash();
size_t len = 160 + strlen(current_class_name) + 2*strlen(module_from_name) + size_t len = 160 + strlen(current_class_name) + 2*strlen(module_from_name) +
strlen(new_class_name) + 2*sizeof(uintx); strlen(new_class_name) + 2*sizeof(uintx);
msg = NEW_RESOURCE_ARRAY(char, len); msg = NEW_RESOURCE_ARRAY(char, len);
@ -621,9 +621,9 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
current_class_name, module_from_name, new_class_name, current_class_name, module_from_name, new_class_name,
module_to_name, module_to_name, package_name, module_from_name); module_to_name, module_to_name, package_name, module_from_name);
} else { } else {
jobject jlrm = module_from->module(); jobject jlm = module_from->module();
assert(jlrm != NULL, "Null jlrm in module_from ModuleEntry"); assert(jlm != NULL, "Null jlm in module_from ModuleEntry");
intptr_t identity_hash = JNIHandles::resolve(jlrm)->identity_hash(); intptr_t identity_hash = JNIHandles::resolve(jlm)->identity_hash();
size_t len = 170 + strlen(current_class_name) + strlen(new_class_name) + size_t len = 170 + strlen(current_class_name) + strlen(new_class_name) +
2*strlen(module_to_name) + strlen(package_name) + 2*sizeof(uintx); 2*strlen(module_to_name) + strlen(package_name) + 2*sizeof(uintx);
msg = NEW_RESOURCE_ARRAY(char, len); msg = NEW_RESOURCE_ARRAY(char, len);

View file

@ -3465,7 +3465,7 @@ void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
java_lang_Thread::RUNNABLE); java_lang_Thread::RUNNABLE);
// The VM creates objects of this class. // The VM creates objects of this class.
initialize_class(vmSymbols::java_lang_reflect_Module(), CHECK); initialize_class(vmSymbols::java_lang_Module(), CHECK);
// The VM preresolves methods to these classes. Make sure that they get initialized // 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_reflect_Method(), CHECK);

View file

@ -50,8 +50,8 @@ requires.properties= \
vm.cpu.features \ vm.cpu.features \
vm.debug vm.debug
# Tests using jtreg 4.2 b04 features # Tests using jtreg 4.2 b07 features
requiredVersion=4.2 b04 requiredVersion=4.2 b07
# Path to libraries in the topmost test directory. This is needed so @library # Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them # does not need ../../ notation to reach them

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -41,7 +41,6 @@ import java.lang.reflect.Executable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.lang.reflect.Module;
import java.lang.reflect.Parameter; import java.lang.reflect.Parameter;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,6 @@
// to create a sub-type of jdk.internal.reflect.MethodAccessorImpl in order // to create a sub-type of jdk.internal.reflect.MethodAccessorImpl in order
// to bypass Reflection.getCallerClass. That should fail with an IAE. // to bypass Reflection.getCallerClass. That should fail with an IAE.
// //
import java.lang.reflect.Module;
class fakeMethodAccessor extends jdk.internal.reflect.MethodAccessorImpl { class fakeMethodAccessor extends jdk.internal.reflect.MethodAccessorImpl {
public static void main(String[] a) throws Exception { public static void main(String[] a) throws Exception {
fakeMethodAccessor f = new fakeMethodAccessor(); fakeMethodAccessor f = new fakeMethodAccessor();
@ -60,11 +59,11 @@ public static Method main:"([Ljava/lang/String;)V"
astore_1; astore_1;
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;"; getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
ldc class java/lang/String; ldc class java/lang/String;
invokevirtual Method java/lang/Class.getModule:"()Ljava/lang/reflect/Module;"; invokevirtual Method java/lang/Class.getModule:"()Ljava/lang/Module;";
ldc String "jdk.internal.misc"; ldc String "jdk.internal.misc";
ldc class FakeMethodAccessor; ldc class FakeMethodAccessor;
invokevirtual Method java/lang/Class.getModule:"()Ljava/lang/reflect/Module;"; invokevirtual Method java/lang/Class.getModule:"()Ljava/lang/Module;";
invokevirtual Method java/lang/reflect/Module.isExported:"(Ljava/lang/String;Ljava/lang/reflect/Module;)Z"; invokevirtual Method java/lang/Module.isExported:"(Ljava/lang/String;Ljava/lang/Module;)Z";
invokevirtual Method java/io/PrintStream.println:"(Z)V"; invokevirtual Method java/io/PrintStream.println:"(Z)V";
return; return;
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -55,7 +55,7 @@ public class GetSysPkgTest {
return m; return m;
} }
} }
throw new RuntimeException("Failed to find method " + name + " in java.lang.reflect.Module"); throw new RuntimeException("Failed to find method " + name + " in java.lang.Module");
} }
// Throw RuntimeException if getSystemPackageLocation() does not return // Throw RuntimeException if getSystemPackageLocation() does not return

View file

@ -28,8 +28,6 @@
* @run main AccModuleTest * @run main AccModuleTest
*/ */
import java.io.File;
public class AccModuleTest { public class AccModuleTest {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {

View file

@ -39,8 +39,6 @@ import static jdk.test.lib.Asserts.*;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
import java.lang.reflect.Layer;
import java.lang.reflect.Module;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -58,7 +56,7 @@ import myloaders.MySameClassLoader;
public class AccessExportTwice { public class AccessExportTwice {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publicly defined classes within packages of those modules. // publicly defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -87,7 +85,7 @@ public class AccessExportTwice {
ModuleFinder finder = ModuleLibrary.of(descriptor_first_mod, descriptor_second_mod); ModuleFinder finder = ModuleLibrary.of(descriptor_first_mod, descriptor_second_mod);
// Resolves "first_mod" // Resolves "first_mod"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("first_mod")); .resolve(finder, ModuleFinder.of(), Set.of("first_mod"));
@ -96,8 +94,8 @@ public class AccessExportTwice {
map.put("first_mod", MySameClassLoader.loader1); map.put("first_mod", MySameClassLoader.loader1);
map.put("second_mod", MySameClassLoader.loader1); map.put("second_mod", MySameClassLoader.loader1);
// Create Layer that contains first_mod & second_mod // Create layer that contains first_mod & second_mod
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("first_mod") == MySameClassLoader.loader1); assertTrue(layer.findLoader("first_mod") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("second_mod") == MySameClassLoader.loader1); assertTrue(layer.findLoader("second_mod") == MySameClassLoader.loader1);

View file

@ -39,8 +39,6 @@ import static jdk.test.lib.Asserts.*;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
import java.lang.reflect.Layer;
import java.lang.reflect.Module;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -56,7 +54,7 @@ import java.util.Set;
public class AccessReadTwice { public class AccessReadTwice {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publicly defined classes within packages of those modules. // publicly defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -85,7 +83,7 @@ public class AccessReadTwice {
ModuleFinder finder = ModuleLibrary.of(descriptor_first_mod, descriptor_second_mod); ModuleFinder finder = ModuleLibrary.of(descriptor_first_mod, descriptor_second_mod);
// Resolves "first_mod" and "second_mod" // Resolves "first_mod" and "second_mod"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("first_mod", "second_mod")); .resolve(finder, ModuleFinder.of(), Set.of("first_mod", "second_mod"));
@ -95,8 +93,8 @@ public class AccessReadTwice {
map.put("first_mod", loader); map.put("first_mod", loader);
map.put("second_mod", loader); map.put("second_mod", loader);
// Create Layer that contains first_mod & second_mod // Create layer that contains first_mod & second_mod
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("first_mod") == loader); assertTrue(layer.findLoader("first_mod") == loader);
assertTrue(layer.findLoader("second_mod") == loader); assertTrue(layer.findLoader("second_mod") == loader);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -59,7 +58,7 @@ import myloaders.MySameClassLoader;
// //
public class CheckRead { public class CheckRead {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publicly defined classes within packages of those modules. // publicly defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -100,7 +99,7 @@ public class CheckRead {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -110,8 +109,8 @@ public class CheckRead {
map.put("m2x", MySameClassLoader.loader1); map.put("m2x", MySameClassLoader.loader1);
map.put("m3x", MySameClassLoader.loader1); map.put("m3x", MySameClassLoader.loader1);
// Create Layer that contains m1x, m2x and m3x // Create layer that contains m1x, m2x and m3x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -59,7 +58,7 @@ import myloaders.MyDiffClassLoader;
// //
public class DiffCL_CheckRead { public class DiffCL_CheckRead {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publicly defined classes within packages of those modules. // publicly defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -100,7 +99,7 @@ public class DiffCL_CheckRead {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -110,8 +109,8 @@ public class DiffCL_CheckRead {
map.put("m2x", MyDiffClassLoader.loader2); map.put("m2x", MyDiffClassLoader.loader2);
map.put("m3x", MyDiffClassLoader.loader2); map.put("m3x", MyDiffClassLoader.loader2);
// Create Layer that contains m1x, m2x and m3x // Create layer that contains m1x, m2x and m3x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2); assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);

View file

@ -38,7 +38,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -60,7 +59,7 @@ import myloaders.MyDiffClassLoader;
// //
public class DiffCL_ExpQualOther { public class DiffCL_ExpQualOther {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -102,7 +101,7 @@ public class DiffCL_ExpQualOther {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -112,8 +111,8 @@ public class DiffCL_ExpQualOther {
map.put("m2x", MyDiffClassLoader.loader2); map.put("m2x", MyDiffClassLoader.loader2);
map.put("m3x", MyDiffClassLoader.loader2); map.put("m3x", MyDiffClassLoader.loader2);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2); assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -58,7 +57,7 @@ import myloaders.MyDiffClassLoader;
// //
public class DiffCL_ExpQualToM1 { public class DiffCL_ExpQualToM1 {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -88,7 +87,7 @@ public class DiffCL_ExpQualToM1 {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -97,8 +96,8 @@ public class DiffCL_ExpQualToM1 {
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
map.put("m2x", MyDiffClassLoader.loader2); map.put("m2x", MyDiffClassLoader.loader2);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2); assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -59,7 +58,7 @@ import myloaders.MyDiffClassLoader;
// //
public class DiffCL_ExpUnqual { public class DiffCL_ExpUnqual {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -89,7 +88,7 @@ public class DiffCL_ExpUnqual {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -98,8 +97,8 @@ public class DiffCL_ExpUnqual {
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
map.put("m2x", MyDiffClassLoader.loader2); map.put("m2x", MyDiffClassLoader.loader2);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2); assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -58,7 +57,7 @@ import myloaders.MyDiffClassLoader;
// //
public class DiffCL_PkgNotExp { public class DiffCL_PkgNotExp {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -88,7 +87,7 @@ public class DiffCL_PkgNotExp {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -97,8 +96,8 @@ public class DiffCL_PkgNotExp {
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
map.put("m2x", MyDiffClassLoader.loader2); map.put("m2x", MyDiffClassLoader.loader2);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2); assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);

View file

@ -42,8 +42,6 @@ import static jdk.test.lib.Asserts.*;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
import java.lang.reflect.Layer;
import java.lang.reflect.Module;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -68,7 +66,7 @@ import myloaders.MyDiffClassLoader;
// //
public class DiffCL_Umod { public class DiffCL_Umod {
// Create Layers over the boot layer to test different // Create layers over the boot layer to test different
// accessing scenarios of a named module to an unnamed module. // accessing scenarios of a named module to an unnamed module.
// Module m1x is a strict module and has not established // Module m1x is a strict module and has not established
@ -89,7 +87,7 @@ public class DiffCL_Umod {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -102,8 +100,8 @@ public class DiffCL_Umod {
Map<String, ClassLoader> map = new HashMap<>(); Map<String, ClassLoader> map = new HashMap<>();
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
// Create Layer that contains m1x // Create layer that contains m1x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("java.base") == null); assertTrue(layer.findLoader("java.base") == null);
@ -138,7 +136,7 @@ public class DiffCL_Umod {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -151,8 +149,8 @@ public class DiffCL_Umod {
Map<String, ClassLoader> map = new HashMap<>(); Map<String, ClassLoader> map = new HashMap<>();
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
// Create Layer that contains m1x // Create layer that contains m1x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("java.base") == null); assertTrue(layer.findLoader("java.base") == null);
@ -187,7 +185,7 @@ public class DiffCL_Umod {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -200,8 +198,8 @@ public class DiffCL_Umod {
Map<String, ClassLoader> map = new HashMap<>(); Map<String, ClassLoader> map = new HashMap<>();
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
// Create Layer that contains m1x // Create layer that contains m1x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("java.base") == null); assertTrue(layer.findLoader("java.base") == null);

View file

@ -38,7 +38,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -63,7 +62,7 @@ import myloaders.MyDiffClassLoader;
// //
public class DiffCL_UmodUpkg { public class DiffCL_UmodUpkg {
// Create Layers over the boot layer to test different // Create layers over the boot layer to test different
// accessing scenarios of a named module to an unnamed module. // accessing scenarios of a named module to an unnamed module.
// Module m1x is a strict module and has not established // Module m1x is a strict module and has not established
@ -84,7 +83,7 @@ public class DiffCL_UmodUpkg {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -97,8 +96,8 @@ public class DiffCL_UmodUpkg {
Map<String, ClassLoader> map = new HashMap<>(); Map<String, ClassLoader> map = new HashMap<>();
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
// Create Layer that contains m1x // Create layer that contains m1x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("java.base") == null); assertTrue(layer.findLoader("java.base") == null);
@ -133,7 +132,7 @@ public class DiffCL_UmodUpkg {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -146,8 +145,8 @@ public class DiffCL_UmodUpkg {
Map<String, ClassLoader> map = new HashMap<>(); Map<String, ClassLoader> map = new HashMap<>();
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
// Create Layer that contains m1x // Create layer that contains m1x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("java.base") == null); assertTrue(layer.findLoader("java.base") == null);

View file

@ -38,7 +38,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -60,7 +59,7 @@ import myloaders.MySameClassLoader;
// //
public class ExpQualOther { public class ExpQualOther {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -102,7 +101,7 @@ public class ExpQualOther {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -112,8 +111,8 @@ public class ExpQualOther {
map.put("m2x", MySameClassLoader.loader1); map.put("m2x", MySameClassLoader.loader1);
map.put("m3x", MySameClassLoader.loader1); map.put("m3x", MySameClassLoader.loader1);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -48,7 +47,7 @@ import myloaders.MySameClassLoader;
public class ExpQualToM1 { public class ExpQualToM1 {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -78,7 +77,7 @@ public class ExpQualToM1 {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -87,8 +86,8 @@ public class ExpQualToM1 {
map.put("m1x", MySameClassLoader.loader1); map.put("m1x", MySameClassLoader.loader1);
map.put("m2x", MySameClassLoader.loader1); map.put("m2x", MySameClassLoader.loader1);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -48,7 +47,7 @@ import myloaders.MySameClassLoader;
public class ExpUnqual { public class ExpUnqual {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -78,7 +77,7 @@ public class ExpUnqual {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -87,8 +86,8 @@ public class ExpUnqual {
map.put("m1x", MySameClassLoader.loader1); map.put("m1x", MySameClassLoader.loader1);
map.put("m2x", MySameClassLoader.loader1); map.put("m2x", MySameClassLoader.loader1);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);

View file

@ -41,8 +41,6 @@ import static jdk.test.lib.Asserts.*;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
import java.lang.reflect.Layer;
import java.lang.reflect.Module;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -61,7 +59,7 @@ import myloaders.MySameClassLoader;
public class ExportAllUnnamed { public class ExportAllUnnamed {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -90,7 +88,7 @@ public class ExportAllUnnamed {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -99,8 +97,8 @@ public class ExportAllUnnamed {
map.put("m1x", MySameClassLoader.loader1); map.put("m1x", MySameClassLoader.loader1);
map.put("m2x", MySameClassLoader.loader1); map.put("m2x", MySameClassLoader.loader1);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -58,7 +57,7 @@ import myloaders.MySameClassLoader;
// //
public class PkgNotExp { public class PkgNotExp {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -88,7 +87,7 @@ public class PkgNotExp {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -97,8 +96,8 @@ public class PkgNotExp {
map.put("m1x", MySameClassLoader.loader1); map.put("m1x", MySameClassLoader.loader1);
map.put("m2x", MySameClassLoader.loader1); map.put("m2x", MySameClassLoader.loader1);
// Create Layer that contains m1x and m2x // Create layer that contains m1x and m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);

View file

@ -39,11 +39,9 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
import java.lang.reflect.Module;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -68,7 +66,7 @@ import myloaders.MySameClassLoader;
// //
public class Umod { public class Umod {
// Create Layers over the boot layer to test different // Create layers over the boot layer to test different
// accessing scenarios of a named module to an unnamed module. // accessing scenarios of a named module to an unnamed module.
// Module m1x is a strict module and has not established // Module m1x is a strict module and has not established
@ -89,7 +87,7 @@ public class Umod {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -99,8 +97,8 @@ public class Umod {
Map<String, ClassLoader> map = new HashMap<>(); Map<String, ClassLoader> map = new HashMap<>();
map.put("m1x", loader); map.put("m1x", loader);
// Create Layer that contains m1x // Create layer that contains m1x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == loader); assertTrue(layer.findLoader("m1x") == loader);
assertTrue(layer.findLoader("java.base") == null); assertTrue(layer.findLoader("java.base") == null);
@ -135,7 +133,7 @@ public class Umod {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -145,8 +143,8 @@ public class Umod {
Map<String, ClassLoader> map = new HashMap<>(); Map<String, ClassLoader> map = new HashMap<>();
map.put("m1x", loader); map.put("m1x", loader);
// Create Layer that contains m1x // Create layer that contains m1x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == loader); assertTrue(layer.findLoader("m1x") == loader);
assertTrue(layer.findLoader("java.base") == null); assertTrue(layer.findLoader("java.base") == null);
@ -181,7 +179,7 @@ public class Umod {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -191,8 +189,8 @@ public class Umod {
Map<String, ClassLoader> map = new HashMap<>(); Map<String, ClassLoader> map = new HashMap<>();
map.put("m1x", loader); map.put("m1x", loader);
// Create Layer that contains m1x // Create layer that contains m1x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == loader); assertTrue(layer.findLoader("m1x") == loader);
assertTrue(layer.findLoader("java.base") == null); assertTrue(layer.findLoader("java.base") == null);

View file

@ -38,7 +38,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -60,7 +59,7 @@ import myloaders.MyDiffClassLoader;
// //
public class UmodDiffCL_ExpQualOther { public class UmodDiffCL_ExpQualOther {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -89,7 +88,7 @@ public class UmodDiffCL_ExpQualOther {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -98,8 +97,8 @@ public class UmodDiffCL_ExpQualOther {
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
map.put("m2x", MyDiffClassLoader.loader2); map.put("m2x", MyDiffClassLoader.loader2);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2); assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);

View file

@ -38,7 +38,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -60,7 +59,7 @@ import myloaders.MyDiffClassLoader;
// //
public class UmodDiffCL_ExpUnqual { public class UmodDiffCL_ExpUnqual {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -89,7 +88,7 @@ public class UmodDiffCL_ExpUnqual {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -98,8 +97,8 @@ public class UmodDiffCL_ExpUnqual {
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
map.put("m2x", MyDiffClassLoader.loader2); map.put("m2x", MyDiffClassLoader.loader2);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2); assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -59,7 +58,7 @@ import myloaders.MyDiffClassLoader;
// //
public class UmodDiffCL_PkgNotExp { public class UmodDiffCL_PkgNotExp {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -88,7 +87,7 @@ public class UmodDiffCL_PkgNotExp {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -97,8 +96,8 @@ public class UmodDiffCL_PkgNotExp {
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
map.put("m2x", MyDiffClassLoader.loader2); map.put("m2x", MyDiffClassLoader.loader2);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2); assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);

View file

@ -40,8 +40,6 @@ import static jdk.test.lib.Asserts.*;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
import java.lang.reflect.Layer;
import java.lang.reflect.Module;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -63,7 +61,7 @@ import myloaders.MySameClassLoader;
// //
public class UmodUPkg { public class UmodUPkg {
// Create Layers over the boot layer to test different // Create layers over the boot layer to test different
// accessing scenarios of a named module to an unnamed module. // accessing scenarios of a named module to an unnamed module.
// Module m1x is a strict module and has not established // Module m1x is a strict module and has not established
@ -84,7 +82,7 @@ public class UmodUPkg {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -94,8 +92,8 @@ public class UmodUPkg {
Map<String, ClassLoader> map = new HashMap<>(); Map<String, ClassLoader> map = new HashMap<>();
map.put("m1x", loader); map.put("m1x", loader);
// Create Layer that contains m1x // Create layer that contains m1x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == loader); assertTrue(layer.findLoader("m1x") == loader);
assertTrue(layer.findLoader("java.base") == null); assertTrue(layer.findLoader("java.base") == null);
@ -130,7 +128,7 @@ public class UmodUPkg {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -140,8 +138,8 @@ public class UmodUPkg {
Map<String, ClassLoader> map = new HashMap<>(); Map<String, ClassLoader> map = new HashMap<>();
map.put("m1x", loader); map.put("m1x", loader);
// Create Layer that contains m1x // Create layer that contains m1x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == loader); assertTrue(layer.findLoader("m1x") == loader);
assertTrue(layer.findLoader("java.base") == null); assertTrue(layer.findLoader("java.base") == null);

View file

@ -38,7 +38,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -60,7 +59,7 @@ import myloaders.MyDiffClassLoader;
// //
public class UmodUpkgDiffCL_ExpQualOther { public class UmodUpkgDiffCL_ExpQualOther {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -89,7 +88,7 @@ public class UmodUpkgDiffCL_ExpQualOther {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -98,8 +97,8 @@ public class UmodUpkgDiffCL_ExpQualOther {
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
map.put("m2x", MyDiffClassLoader.loader2); map.put("m2x", MyDiffClassLoader.loader2);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2); assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -59,7 +58,7 @@ import myloaders.MyDiffClassLoader;
// //
public class UmodUpkgDiffCL_NotExp { public class UmodUpkgDiffCL_NotExp {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -88,7 +87,7 @@ public class UmodUpkgDiffCL_NotExp {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -97,8 +96,8 @@ public class UmodUpkgDiffCL_NotExp {
map.put("m1x", MyDiffClassLoader.loader1); map.put("m1x", MyDiffClassLoader.loader1);
map.put("m2x", MyDiffClassLoader.loader2); map.put("m2x", MyDiffClassLoader.loader2);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MyDiffClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2); assertTrue(layer.findLoader("m2x") == MyDiffClassLoader.loader2);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -59,12 +58,12 @@ import myloaders.MySameClassLoader;
// //
public class UmodUpkg_ExpQualOther { public class UmodUpkg_ExpQualOther {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
// Define module: m1x (need to define m1x to establish the Layer successfully) // Define module: m1x (need to define m1x to establish the layer successfully)
// Can read: java.base, m2x, m3x // Can read: java.base, m2x, m3x
// Packages: none // Packages: none
// Packages exported: none // Packages exported: none
@ -98,7 +97,7 @@ public class UmodUpkg_ExpQualOther {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -108,8 +107,8 @@ public class UmodUpkg_ExpQualOther {
map.put("m2x", MySameClassLoader.loader1); map.put("m2x", MySameClassLoader.loader1);
map.put("m3x", MySameClassLoader.loader1); map.put("m3x", MySameClassLoader.loader1);
// Create Layer that contains m1x, m2x and m3x // Create layer that contains m1x, m2x and m3x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -57,7 +56,7 @@ import myloaders.MySameClassLoader;
// //
public class UmodUpkg_NotExp { public class UmodUpkg_NotExp {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -86,7 +85,7 @@ public class UmodUpkg_NotExp {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -95,8 +94,8 @@ public class UmodUpkg_NotExp {
map.put("m1x", MySameClassLoader.loader1); map.put("m1x", MySameClassLoader.loader1);
map.put("m2x", MySameClassLoader.loader1); map.put("m2x", MySameClassLoader.loader1);
// Create Layer that contains m1x and m2x // Create layer that contains m1x and m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -59,12 +58,12 @@ import myloaders.MySameClassLoader;
// //
public class Umod_ExpQualOther { public class Umod_ExpQualOther {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
// Define module: m1x (need to define m1x to establish the Layer successfully) // Define module: m1x (need to define m1x to establish the layer successfully)
// Can read: java.base, m2x, m3x // Can read: java.base, m2x, m3x
// Packages: none // Packages: none
// Packages exported: none // Packages exported: none
@ -98,7 +97,7 @@ public class Umod_ExpQualOther {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -108,8 +107,8 @@ public class Umod_ExpQualOther {
map.put("m2x", MySameClassLoader.loader1); map.put("m2x", MySameClassLoader.loader1);
map.put("m3x", MySameClassLoader.loader1); map.put("m3x", MySameClassLoader.loader1);
// Create Layer that contains m1x, m2x and m3x // Create layer that contains m1x, m2x and m3x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -59,7 +58,7 @@ import myloaders.MySameClassLoader;
public class Umod_ExpUnqual { public class Umod_ExpUnqual {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -88,7 +87,7 @@ public class Umod_ExpUnqual {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -97,8 +96,8 @@ public class Umod_ExpUnqual {
map.put("m1x", MySameClassLoader.loader1); map.put("m1x", MySameClassLoader.loader1);
map.put("m2x", MySameClassLoader.loader1); map.put("m2x", MySameClassLoader.loader1);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);

View file

@ -37,7 +37,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -57,7 +56,7 @@ import myloaders.MySameClassLoader;
// //
public class Umod_PkgNotExp { public class Umod_PkgNotExp {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -86,7 +85,7 @@ public class Umod_PkgNotExp {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -95,8 +94,8 @@ public class Umod_PkgNotExp {
map.put("m1x", MySameClassLoader.loader1); map.put("m1x", MySameClassLoader.loader1);
map.put("m2x", MySameClassLoader.loader1); map.put("m2x", MySameClassLoader.loader1);
// Create Layer that contains m1x and m2x // Create layer that contains m1x and m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1); assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);

View file

@ -22,7 +22,6 @@
*/ */
package p1; package p1;
import java.lang.reflect.*;
import p2.c2; import p2.c2;
public class c1ReadEdge { public class c1ReadEdge {

View file

@ -22,7 +22,6 @@
*/ */
package p1; package p1;
import java.lang.reflect.*;
import myloaders.MyDiffClassLoader; import myloaders.MyDiffClassLoader;
import p2.c2; import p2.c2;

View file

@ -23,7 +23,6 @@
/* /*
* package p3; * package p3;
* import java.lang.reflect.*;
* public class c3ReadEdge { * public class c3ReadEdge {
* public c3ReadEdge() { * public c3ReadEdge() {
* // Establish read edge from module m1x, where c3ReadEdge is defined, * // Establish read edge from module m1x, where c3ReadEdge is defined,
@ -75,14 +74,14 @@ class p3/c3ReadEdge {
Utf8 "java/lang/Object"; // #28 at 0xBC Utf8 "java/lang/Object"; // #28 at 0xBC
Utf8 "java/lang/Class"; // #29 at 0xCF Utf8 "java/lang/Class"; // #29 at 0xCF
Utf8 "getModule"; // #30 at 0xE1 Utf8 "getModule"; // #30 at 0xE1
Utf8 "()Ljava/lang/reflect/Module;"; // #31 at 0xED Utf8 "()Ljava/lang/Module;"; // #31 at 0xED
Utf8 "getClassLoader"; // #32 at 0x010C Utf8 "getClassLoader"; // #32 at 0x010C
Utf8 "()Ljava/lang/ClassLoader;"; // #33 at 0x011D Utf8 "()Ljava/lang/ClassLoader;"; // #33 at 0x011D
Utf8 "java/lang/ClassLoader"; // #34 at 0x0139 Utf8 "java/lang/ClassLoader"; // #34 at 0x0139
Utf8 "getUnnamedModule"; // #35 at 0x0151 Utf8 "getUnnamedModule"; // #35 at 0x0151
Utf8 "java/lang/reflect/Module"; // #36 at 0x0164 Utf8 "java/lang/Module"; // #36 at 0x0164
Utf8 "addReads"; // #37 at 0x017F Utf8 "addReads"; // #37 at 0x017F
Utf8 "(Ljava/lang/reflect/Module;)Ljava/lang/reflect/Module;"; // #38 at 0x018A Utf8 "(Ljava/lang/Module;)Ljava/lang/Module;"; // #38 at 0x018A
Utf8 "method4"; // #39 at 0x01C3 Utf8 "method4"; // #39 at 0x01C3
} // Constant Pool } // Constant Pool

View file

@ -23,7 +23,6 @@
/* /*
* package p3; * package p3;
* import java.lang.reflect.*;
* import myloaders.MyDiffClassLoader; * import myloaders.MyDiffClassLoader;
* *
* public class c3ReadEdgeDiffLoader { * public class c3ReadEdgeDiffLoader {
@ -100,14 +99,14 @@ class p3/c3ReadEdgeDiffLoader {
Utf8 "java/lang/Object"; // #31 at 0xDD Utf8 "java/lang/Object"; // #31 at 0xDD
Utf8 "java/lang/Class"; // #32 at 0xF0 Utf8 "java/lang/Class"; // #32 at 0xF0
Utf8 "getModule"; // #33 at 0x0102 Utf8 "getModule"; // #33 at 0x0102
Utf8 "()Ljava/lang/reflect/Module;"; // #34 at 0x010E Utf8 "()Ljava/lang/Module;"; // #34 at 0x010E
Utf8 "java/lang/ClassLoader"; // #35 at 0x012D Utf8 "java/lang/ClassLoader"; // #35 at 0x012D
Utf8 "getSystemClassLoader"; // #36 at 0x0145 Utf8 "getSystemClassLoader"; // #36 at 0x0145
Utf8 "()Ljava/lang/ClassLoader;"; // #37 at 0x015C Utf8 "()Ljava/lang/ClassLoader;"; // #37 at 0x015C
Utf8 "getUnnamedModule"; // #38 at 0x0178 Utf8 "getUnnamedModule"; // #38 at 0x0178
Utf8 "java/lang/reflect/Module"; // #39 at 0x018B Utf8 "java/lang/Module"; // #39 at 0x018B
Utf8 "addReads"; // #40 at 0x01A6 Utf8 "addReads"; // #40 at 0x01A6
Utf8 "(Ljava/lang/reflect/Module;)Ljava/lang/reflect/Module;"; // #41 at 0x01B1 Utf8 "(Ljava/lang/Module;)Ljava/lang/Module;"; // #41 at 0x01B1
Utf8 "myloaders/MyDiffClassLoader"; // #42 at 0x01EA Utf8 "myloaders/MyDiffClassLoader"; // #42 at 0x01EA
Utf8 "loader2"; // #43 at 0x0208 Utf8 "loader2"; // #43 at 0x0208
Utf8 "Lmyloaders/MyDiffClassLoader;"; // #44 at 0x0212 Utf8 "Lmyloaders/MyDiffClassLoader;"; // #44 at 0x0212

View file

@ -25,8 +25,6 @@
package p4; package p4;
import java.lang.reflect.Module;
public class c4 { public class c4 {
// Add a read edge from c4's module to given module m // Add a read edge from c4's module to given module m
public void addReads(Module m) { public void addReads(Module m) {

View file

@ -21,7 +21,6 @@
* questions. * questions.
*/ */
import java.lang.reflect.Module;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
/* /*
@ -31,7 +30,7 @@ import static jdk.test.lib.Asserts.*;
* @compile p2/c2.java * @compile p2/c2.java
* @compile p1/c1.java * @compile p1/c1.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckAllUnnamed * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckAllUnnamed
@ -45,10 +44,10 @@ public class AccessCheckAllUnnamed {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
Object m1x, m2x; Object m1x, m2x;
// Get the java.lang.reflect.Module object for module java.base. // Get the java.lang.Module object for module java.base.
Class jlObject = Class.forName("java.lang.Object"); Class jlObject = Class.forName("java.lang.Object");
Object jlObject_jlrM = jlObject.getModule(); Object jlM = jlObject.getModule();
assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null"); assertNotNull(jlM, "jlModule object of java.lang.Object should not be null");
// Get the class loader for AccessCheckWorks and assume it's also used to // Get the class loader for AccessCheckWorks and assume it's also used to
// load class p2.c2. // load class p2.c2.
@ -58,13 +57,13 @@ public class AccessCheckAllUnnamed {
m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p3" }); m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p3" });
assertNotNull(m1x, "Module should not be null"); assertNotNull(m1x, "Module should not be null");
ModuleHelper.DefineModule(m1x, "9.0", "m1x/there", new String[] { "p3" }); ModuleHelper.DefineModule(m1x, "9.0", "m1x/there", new String[] { "p3" });
ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); ModuleHelper.AddReadsModule(m1x, jlM);
// Define a module for p2. // Define a module for p2.
m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
assertNotNull(m2x, "Module should not be null"); assertNotNull(m2x, "Module should not be null");
ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); ModuleHelper.AddReadsModule(m2x, jlM);
try { try {
ModuleHelper.AddModuleExportsToAllUnnamed((Module)null, "p2"); ModuleHelper.AddModuleExportsToAllUnnamed((Module)null, "p2");

View file

@ -28,13 +28,12 @@
* @compile p2/c2.java * @compile p2/c2.java
* @compile p1/c1.java * @compile p1/c1.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckExp * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckExp
*/ */
import java.lang.reflect.Module;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class AccessCheckExp { public class AccessCheckExp {
@ -44,10 +43,10 @@ public class AccessCheckExp {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
Object m1x, m2x; Object m1x, m2x;
// Get the java.lang.reflect.Module object for module java.base. // Get the java.lang.Module object for module java.base.
Class jlObject = Class.forName("java.lang.Object"); Class jlObject = Class.forName("java.lang.Object");
Object jlObject_jlrM = jlObject.getModule(); Object jlObject_jlM = jlObject.getModule();
assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null"); assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
// Get the class loader for AccessCheckExp and assume it's also used to // Get the class loader for AccessCheckExp and assume it's also used to
// load classes p1.c1 and p2.c2. // load classes p1.c1 and p2.c2.
@ -57,13 +56,13 @@ public class AccessCheckExp {
m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" }); m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
assertNotNull(m1x, "Module should not be null"); assertNotNull(m1x, "Module should not be null");
ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" }); ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" });
ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
// Define a module for p2. // Define a module for p2.
m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
assertNotNull(m2x, "Module should not be null"); assertNotNull(m2x, "Module should not be null");
ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
// Make package p1 in m1x visible to everyone. // Make package p1 in m1x visible to everyone.
ModuleHelper.AddModuleExportsToAll(m1x, "p1"); ModuleHelper.AddModuleExportsToAll(m1x, "p1");

View file

@ -27,13 +27,12 @@
* @library /test/lib .. * @library /test/lib ..
* @compile p2/c2.java * @compile p2/c2.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckJavaBase * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckJavaBase
*/ */
import java.lang.reflect.Module;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class AccessCheckJavaBase { public class AccessCheckJavaBase {

View file

@ -28,13 +28,12 @@
* @compile p2/c2.java * @compile p2/c2.java
* @compile p1/c1.java * @compile p1/c1.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckRead * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckRead
*/ */
import java.lang.reflect.Module;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class AccessCheckRead { public class AccessCheckRead {
@ -44,10 +43,10 @@ public class AccessCheckRead {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
Object m1x, m2x; Object m1x, m2x;
// Get the java.lang.reflect.Module object for module java.base. // Get the java.lang.Module object for module java.base.
Class jlObject = Class.forName("java.lang.Object"); Class jlObject = Class.forName("java.lang.Object");
Object jlObject_jlrM = jlObject.getModule(); Object jlObject_jlM = jlObject.getModule();
assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null"); assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
// Get the class loader for AccessCheckRead and assume it's also used to // Get the class loader for AccessCheckRead and assume it's also used to
// load classes p1.c1 and p2.c2. // load classes p1.c1 and p2.c2.
@ -57,13 +56,13 @@ public class AccessCheckRead {
m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" }); m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
assertNotNull(m1x, "Module should not be null"); assertNotNull(m1x, "Module should not be null");
ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" }); ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" });
ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
// Define a module for p2. // Define a module for p2.
m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
assertNotNull(m2x, "Module should not be null"); assertNotNull(m2x, "Module should not be null");
ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
// Make package p1 in m1x visible to everyone. // Make package p1 in m1x visible to everyone.
ModuleHelper.AddModuleExportsToAll(m1x, "p1"); ModuleHelper.AddModuleExportsToAll(m1x, "p1");

View file

@ -28,13 +28,12 @@
* @compile p2/c2.java * @compile p2/c2.java
* @compile p3/c3.java * @compile p3/c3.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckSuper * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckSuper
*/ */
import java.lang.reflect.Module;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class AccessCheckSuper { public class AccessCheckSuper {

View file

@ -21,7 +21,6 @@
* questions. * questions.
*/ */
import java.lang.reflect.Module;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
/* /*
@ -31,7 +30,7 @@ import static jdk.test.lib.Asserts.*;
* @compile p2/c2.java * @compile p2/c2.java
* @compile p1/c1.java * @compile p1/c1.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckUnnamed * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckUnnamed
@ -44,10 +43,10 @@ public class AccessCheckUnnamed {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
Object m1x, m2x; Object m1x, m2x;
// Get the java.lang.reflect.Module object for module java.base. // Get the java.lang.Module object for module java.base.
Class jlObject = Class.forName("java.lang.Object"); Class jlObject = Class.forName("java.lang.Object");
Object jlObject_jlrM = jlObject.getModule(); Object jlObject_jlM = jlObject.getModule();
assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null"); assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
// Get the class loader for AccessCheckWorks and assume it's also used to // Get the class loader for AccessCheckWorks and assume it's also used to
// load class p2.c2. // load class p2.c2.
@ -57,7 +56,7 @@ public class AccessCheckUnnamed {
m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
assertNotNull(m2x, "Module should not be null"); assertNotNull(m2x, "Module should not be null");
ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
// p1.c1's ctor tries to call a method in p2.c2. This should fail because // p1.c1's ctor tries to call a method in p2.c2. This should fail because
// p1 is in the unnamed module and p2.c2 is not unqualifiedly exported. // p1 is in the unnamed module and p2.c2 is not unqualifiedly exported.

View file

@ -28,13 +28,12 @@
* @compile p2/c2.java * @compile p2/c2.java
* @compile p1/c1.java * @compile p1/c1.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckWorks * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckWorks
*/ */
import java.lang.reflect.Module;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class AccessCheckWorks { public class AccessCheckWorks {
@ -45,10 +44,10 @@ public class AccessCheckWorks {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
Object m1x, m2x; Object m1x, m2x;
// Get the java.lang.reflect.Module object for module java.base. // Get the java.lang.Module object for module java.base.
Class jlObject = Class.forName("java.lang.Object"); Class jlObject = Class.forName("java.lang.Object");
Object jlObject_jlrM = jlObject.getModule(); Object jlObject_jlM = jlObject.getModule();
assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null"); assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
// Get the class loader for AccessCheckWorks and assume it's also used to // Get the class loader for AccessCheckWorks and assume it's also used to
// load classes p1.c1 and p2.c2. // load classes p1.c1 and p2.c2.
@ -58,13 +57,13 @@ public class AccessCheckWorks {
m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" }); m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
assertNotNull(m1x, "Module should not be null"); assertNotNull(m1x, "Module should not be null");
ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" }); ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" });
ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
// Define a module for p2. // Define a module for p2.
m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
assertNotNull(m2x, "Module should not be null"); assertNotNull(m2x, "Module should not be null");
ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
// Make package p1 in m1x visible to everyone. // Make package p1 in m1x visible to everyone.
ModuleHelper.AddModuleExportsToAll(m1x, "p1"); ModuleHelper.AddModuleExportsToAll(m1x, "p1");

View file

@ -28,14 +28,13 @@
* @compile p2/c2.java * @compile p2/c2.java
* @compile p4/c4.java * @compile p4/c4.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI CCE_module_msg * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI CCE_module_msg
*/ */
import java.io.*; import java.io.*;
import java.lang.reflect.Module;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.nio.file.Path; import java.nio.file.Path;
@ -73,10 +72,10 @@ public class CCE_module_msg {
} }
public static void invalidClassToString() throws Throwable { public static void invalidClassToString() throws Throwable {
// Get the java.lang.reflect.Module object for module java.base. // Get the java.lang.Module object for module java.base.
Class jlObject = Class.forName("java.lang.Object"); Class jlObject = Class.forName("java.lang.Object");
Object jlObject_jlrM = jlObject.getModule(); Object jlObject_jlM = jlObject.getModule();
assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null"); assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
// Get the class loader for CCE_module_msg and assume it's also used to // Get the class loader for CCE_module_msg and assume it's also used to
// load classes p1.c1 and p2.c2. // load classes p1.c1 and p2.c2.
@ -86,7 +85,7 @@ public class CCE_module_msg {
Object m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); Object m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
assertNotNull(m2x, "Module should not be null"); assertNotNull(m2x, "Module should not be null");
ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
try { try {
ModuleHelper.AddModuleExportsToAll(m2x, "p2"); ModuleHelper.AddModuleExportsToAll(m2x, "p2");
@ -105,10 +104,10 @@ public class CCE_module_msg {
} }
public static void invalidClassToStringCustomLoader() throws Throwable { public static void invalidClassToStringCustomLoader() throws Throwable {
// Get the java.lang.reflect.Module object for module java.base. // Get the java.lang.Module object for module java.base.
Class jlObject = Class.forName("java.lang.Object"); Class jlObject = Class.forName("java.lang.Object");
Object jlObject_jlrM = jlObject.getModule(); Object jlObject_jlM = jlObject.getModule();
assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null"); assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
// Create a customer class loader to load class p4/c4. // Create a customer class loader to load class p4/c4.
URL[] urls = new URL[] { CLASSES_DIR.toUri().toURL() }; URL[] urls = new URL[] { CLASSES_DIR.toUri().toURL() };

View file

@ -28,13 +28,12 @@
* @compile p2/c2.java * @compile p2/c2.java
* @compile p1/c1.java * @compile p1/c1.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ExportTwice * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ExportTwice
*/ */
import java.lang.reflect.Module;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class ExportTwice { public class ExportTwice {
@ -46,10 +45,10 @@ public class ExportTwice {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
Object m1x, m2x, m3x; Object m1x, m2x, m3x;
// Get the java.lang.reflect.Module object for module java.base. // Get the java.lang.Module object for module java.base.
Class jlObject = Class.forName("java.lang.Object"); Class jlObject = Class.forName("java.lang.Object");
Object jlObject_jlrM = jlObject.getModule(); Object jlObject_jlM = jlObject.getModule();
assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null"); assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
// Get the class loader for ExportTwice and assume it's also used to // Get the class loader for ExportTwice and assume it's also used to
// load classes p1.c1 and p2.c2. // load classes p1.c1 and p2.c2.
@ -59,19 +58,19 @@ public class ExportTwice {
m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" }); m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
assertNotNull(m1x, "Module should not be null"); assertNotNull(m1x, "Module should not be null");
ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" }); ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" });
ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
// Define a module for p2. // Define a module for p2.
m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
assertNotNull(m2x, "Module should not be null"); assertNotNull(m2x, "Module should not be null");
ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
// Define a module for p3. // Define a module for p3.
m3x = ModuleHelper.ModuleObject("module_three", this_cldr, new String[] { "p3" }); m3x = ModuleHelper.ModuleObject("module_three", this_cldr, new String[] { "p3" });
assertNotNull(m3x, "Module should not be null"); assertNotNull(m3x, "Module should not be null");
ModuleHelper.DefineModule(m3x, "9.0", "m3x/there", new String[] { "p3" }); ModuleHelper.DefineModule(m3x, "9.0", "m3x/there", new String[] { "p3" });
ModuleHelper.AddReadsModule(m3x, jlObject_jlrM); ModuleHelper.AddReadsModule(m3x, jlObject_jlM);
// Make package p1 in m1x visible to everyone. // Make package p1 in m1x visible to everyone.
ModuleHelper.AddModuleExportsToAll(m1x, "p1"); ModuleHelper.AddModuleExportsToAll(m1x, "p1");

View file

@ -30,11 +30,10 @@
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExportToAllUnnamed * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExportToAllUnnamed
*/ */
import java.lang.reflect.Module;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class JVMAddModuleExportToAllUnnamed { public class JVMAddModuleExportToAllUnnamed {
@ -44,10 +43,10 @@ public class JVMAddModuleExportToAllUnnamed {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
Object m1x; Object m1x;
// Get the java.lang.reflect.Module object for module java.base. // Get the java.lang.Module object for module java.base.
Class jlObject = Class.forName("java.lang.Object"); Class jlObject = Class.forName("java.lang.Object");
Object jlObject_jlrM = jlObject.getModule(); Object jlObject_jlM = jlObject.getModule();
assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null"); assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
// Get the class loader for JVMAddModuleExportToAllUnnamed and assume it's also used to // Get the class loader for JVMAddModuleExportToAllUnnamed and assume it's also used to
// load class p1.c1. // load class p1.c1.
@ -57,7 +56,7 @@ public class JVMAddModuleExportToAllUnnamed {
m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" }); m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
assertNotNull(m1x, "Module should not be null"); assertNotNull(m1x, "Module should not be null");
ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" }); ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" });
ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
// Make package p1 in m1x visible to everyone. // Make package p1 in m1x visible to everyone.
ModuleHelper.AddModuleExportsToAll(m1x, "p1"); ModuleHelper.AddModuleExportsToAll(m1x, "p1");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,13 +26,12 @@
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* @library /test/lib .. * @library /test/lib ..
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExports * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExports
*/ */
import java.lang.reflect.Module;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
public class JVMAddModuleExports { public class JVMAddModuleExports {

View file

@ -21,7 +21,6 @@
* questions. * questions.
*/ */
import java.lang.reflect.Module;
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
/* /*
@ -31,7 +30,7 @@ import static jdk.test.lib.Asserts.*;
* @compile p2/c2.java * @compile p2/c2.java
* @compile p1/c1.java * @compile p1/c1.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExportsToAll * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModuleExportsToAll
@ -45,10 +44,10 @@ public class JVMAddModuleExportsToAll {
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
Object m1x, m2x, m3x; Object m1x, m2x, m3x;
// Get the java.lang.reflect.Module object for module java.base. // Get the java.lang.Module object for module java.base.
Class jlObject = Class.forName("java.lang.Object"); Class jlObject = Class.forName("java.lang.Object");
Object jlObject_jlrM = jlObject.getModule(); Object jlObject_jlM = jlObject.getModule();
assertNotNull(jlObject_jlrM, "jlrModule object of java.lang.Object should not be null"); assertNotNull(jlObject_jlM, "jlModule object of java.lang.Object should not be null");
// Get the class loader for JVMAddModuleExportsToAll and assume it's also used to // Get the class loader for JVMAddModuleExportsToAll and assume it's also used to
// load class p2.c2. // load class p2.c2.
@ -58,13 +57,13 @@ public class JVMAddModuleExportsToAll {
m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p3" }); m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p3" });
assertNotNull(m1x, "Module should not be null"); assertNotNull(m1x, "Module should not be null");
ModuleHelper.DefineModule(m1x, "9.0", "m1x/there", new String[] { "p3" }); ModuleHelper.DefineModule(m1x, "9.0", "m1x/there", new String[] { "p3" });
ModuleHelper.AddReadsModule(m1x, jlObject_jlrM); ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
// Define a module for p2. // Define a module for p2.
m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
assertNotNull(m2x, "Module should not be null"); assertNotNull(m2x, "Module should not be null");
ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
ModuleHelper.AddReadsModule(m2x, jlObject_jlrM); ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
try { try {
ModuleHelper.AddModuleExportsToAll((Module)null, "p2"); ModuleHelper.AddModuleExportsToAll((Module)null, "p2");
@ -80,7 +79,7 @@ public class JVMAddModuleExportsToAll {
// Expected // Expected
} }
try { // Expect IAE when passing a ClassLoader object instead of a java.lang.reflect.Module object. try { // Expect IAE when passing a ClassLoader object instead of a java.lang.Module object.
ModuleHelper.AddModuleExportsToAll(this_cldr, "p2"); ModuleHelper.AddModuleExportsToAll(this_cldr, "p2");
throw new RuntimeException("Failed to get the expected IAE for bad module"); throw new RuntimeException("Failed to get the expected IAE for bad module");
} catch(IllegalArgumentException e) { } catch(IllegalArgumentException e) {

View file

@ -26,7 +26,7 @@
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* @library /test/lib .. * @library /test/lib ..
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModulePackage * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddModulePackage

View file

@ -26,7 +26,7 @@
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* @library /test/lib .. * @library /test/lib ..
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddReadsModule * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMAddReadsModule

View file

@ -26,7 +26,7 @@
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* @library /test/lib .. * @library /test/lib ..
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMDefineModule * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMDefineModule
@ -78,7 +78,7 @@ public class JVMDefineModule {
ModuleHelper.DefineModule(new Object(), "9.0", "mymodule/here", new String[] { "mypackage1" }); ModuleHelper.DefineModule(new Object(), "9.0", "mymodule/here", new String[] { "mypackage1" });
throw new RuntimeException("Failed to get expected IAE or NPE for bad module"); throw new RuntimeException("Failed to get expected IAE or NPE for bad module");
} catch(IllegalArgumentException e) { } catch(IllegalArgumentException e) {
if (!e.getMessage().contains("module is not an instance of type java.lang.reflect.Module")) { if (!e.getMessage().contains("module is not an instance of type java.lang.Module")) {
throw new RuntimeException("Failed to get expected IAE message for bad module: " + e.getMessage()); throw new RuntimeException("Failed to get expected IAE message for bad module: " + e.getMessage());
} }
} }

View file

@ -27,7 +27,7 @@
* @library /test/lib .. * @library /test/lib ..
* @compile p2/c2.java * @compile p2/c2.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMGetModuleByPkgName * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JVMGetModuleByPkgName
@ -35,7 +35,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.ClassLoader; import java.lang.ClassLoader;
import java.lang.reflect.Module;
public class JVMGetModuleByPkgName { public class JVMGetModuleByPkgName {

View file

@ -27,7 +27,7 @@
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* @library /test/lib .. * @library /test/lib ..
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox
* @compile/module=java.base java/lang/reflect/ModuleHelper.java * @compile/module=java.base java/lang/ModuleHelper.java
* @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx64m -Xmx64m LoadUnloadModuleStress 15000 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx64m -Xmx64m LoadUnloadModuleStress 15000

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,6 @@
import java.net.URI; import java.net.URI;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.reflect.Module;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -41,19 +40,19 @@ public class ModuleHelper {
public static void AddModuleExports(Object from, String pkg, Object to) throws Throwable { public static void AddModuleExports(Object from, String pkg, Object to) throws Throwable {
WhiteBox wb = WhiteBox.getWhiteBox(); WhiteBox wb = WhiteBox.getWhiteBox();
wb.AddModuleExports(from, pkg, to); wb.AddModuleExports(from, pkg, to);
java.lang.reflect.ModuleHelper.addExportsNoSync((Module)from, pkg, (Module)to); java.lang.ModuleHelper.addExportsNoSync((Module)from, pkg, (Module)to);
} }
public static void AddReadsModule(Object from, Object to) throws Throwable { public static void AddReadsModule(Object from, Object to) throws Throwable {
WhiteBox wb = WhiteBox.getWhiteBox(); WhiteBox wb = WhiteBox.getWhiteBox();
wb.AddReadsModule(from, to); wb.AddReadsModule(from, to);
java.lang.reflect.ModuleHelper.addReadsNoSync((Module)from, (Module)to); java.lang.ModuleHelper.addReadsNoSync((Module)from, (Module)to);
} }
public static void AddModulePackage(Object m, String pkg) throws Throwable { public static void AddModulePackage(Object m, String pkg) throws Throwable {
WhiteBox wb = WhiteBox.getWhiteBox(); WhiteBox wb = WhiteBox.getWhiteBox();
wb.AddModulePackage(m, pkg); wb.AddModulePackage(m, pkg);
java.lang.reflect.ModuleHelper.addPackageNoSync((Module)m, pkg); java.lang.ModuleHelper.addPackageNoSync((Module)m, pkg);
} }
public static Module GetModuleByPackageName(Object ldr, String pkg) throws Throwable { public static Module GetModuleByPackageName(Object ldr, String pkg) throws Throwable {
@ -64,13 +63,13 @@ public class ModuleHelper {
public static void AddModuleExportsToAllUnnamed(Object m, String pkg) throws Throwable { public static void AddModuleExportsToAllUnnamed(Object m, String pkg) throws Throwable {
WhiteBox wb = WhiteBox.getWhiteBox(); WhiteBox wb = WhiteBox.getWhiteBox();
wb.AddModuleExportsToAllUnnamed(m, pkg); wb.AddModuleExportsToAllUnnamed(m, pkg);
//java.lang.reflect.ModuleHelper.addExportsToAllUnnamedNoSync((Module)m, pkg); //java.lang.ModuleHelper.addExportsToAllUnnamedNoSync((Module)m, pkg);
} }
public static void AddModuleExportsToAll(Object m, String pkg) throws Throwable { public static void AddModuleExportsToAll(Object m, String pkg) throws Throwable {
WhiteBox wb = WhiteBox.getWhiteBox(); WhiteBox wb = WhiteBox.getWhiteBox();
wb.AddModuleExportsToAll(m, pkg); wb.AddModuleExportsToAll(m, pkg);
java.lang.reflect.ModuleHelper.addExportsNoSync((Module)m, pkg, (Module)null); java.lang.ModuleHelper.addExportsNoSync((Module)m, pkg, (Module)null);
} }
public static Module ModuleObject(String name, ClassLoader loader, String[] pkgs) throws Throwable { public static Module ModuleObject(String name, ClassLoader loader, String[] pkgs) throws Throwable {
@ -87,7 +86,7 @@ public class ModuleHelper {
ModuleDescriptor.newModule(name).packages(pkg_set).build(); ModuleDescriptor.newModule(name).packages(pkg_set).build();
URI uri = URI.create("module:/" + name); URI uri = URI.create("module:/" + name);
return java.lang.reflect.ModuleHelper.newModule(loader, descriptor); return java.lang.ModuleHelper.newModule(loader, descriptor);
} }
} }

View file

@ -25,7 +25,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -47,7 +46,7 @@ import java.util.Set;
// //
public class ModuleNonBuiltinCLMain { public class ModuleNonBuiltinCLMain {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -90,7 +89,7 @@ public class ModuleNonBuiltinCLMain {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -103,8 +102,8 @@ public class ModuleNonBuiltinCLMain {
map.put("m2x", cl2); map.put("m2x", cl2);
map.put("m3x", cl3); map.put("m3x", cl3);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == cl1); assertTrue(layer.findLoader("m1x") == cl1);
assertTrue(layer.findLoader("m2x") == cl2); assertTrue(layer.findLoader("m2x") == cl2);
assertTrue(layer.findLoader("m3x") == cl3); assertTrue(layer.findLoader("m3x") == cl3);

View file

@ -25,7 +25,6 @@
import static jdk.test.lib.Asserts.*; import static jdk.test.lib.Asserts.*;
import java.lang.reflect.Layer;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
@ -45,7 +44,7 @@ import java.util.Set;
// //
public class ModuleSameCLMain { public class ModuleSameCLMain {
// Create a Layer over the boot layer. // Create a layer over the boot layer.
// Define modules within this layer to test access between // Define modules within this layer to test access between
// publically defined classes within packages of those modules. // publically defined classes within packages of those modules.
public void createLayerOnBoot() throws Throwable { public void createLayerOnBoot() throws Throwable {
@ -75,7 +74,7 @@ public class ModuleSameCLMain {
ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x); ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x);
// Resolves "m1x" // Resolves "m1x"
Configuration cf = Layer.boot() Configuration cf = ModuleLayer.boot()
.configuration() .configuration()
.resolve(finder, ModuleFinder.of(), Set.of("m1x")); .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
@ -85,8 +84,8 @@ public class ModuleSameCLMain {
map.put("m1x", cl1); map.put("m1x", cl1);
map.put("m2x", cl1); map.put("m2x", cl1);
// Create Layer that contains m1x & m2x // Create layer that contains m1x & m2x
Layer layer = Layer.boot().defineModules(cf, map::get); ModuleLayer layer = ModuleLayer.boot().defineModules(cf, map::get);
assertTrue(layer.findLoader("m1x") == cl1); assertTrue(layer.findLoader("m1x") == cl1);
assertTrue(layer.findLoader("m2x") == cl1); assertTrue(layer.findLoader("m2x") == cl1);
assertTrue(layer.findLoader("java.base") == null); assertTrue(layer.findLoader("java.base") == null);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,9 +25,7 @@ package test;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
import java.lang.reflect.Layer;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Module;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.*; import java.util.*;
@ -44,7 +42,7 @@ public class Main {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
ModuleFinder finder = ModuleFinder.of(MODS_DIR); ModuleFinder finder = ModuleFinder.of(MODS_DIR);
Layer layerBoot = Layer.boot(); ModuleLayer layerBoot = ModuleLayer.boot();
Configuration cf = layerBoot Configuration cf = layerBoot
.configuration() .configuration()
@ -58,7 +56,7 @@ public class Main {
Callable<Void> task = new Callable<Void>() { Callable<Void> task = new Callable<Void>() {
@Override @Override
public Void call() throws Exception { public Void call() throws Exception {
Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl); ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
Module transletModule = layer.findModule(MODULE_NAME).get(); Module transletModule = layer.findModule(MODULE_NAME).get();
testModule.addExports("test", transletModule); testModule.addExports("test", transletModule);
Class<?> c = layer.findLoader(MODULE_NAME).loadClass("translet.Main"); Class<?> c = layer.findLoader(MODULE_NAME).loadClass("translet.Main");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,9 +25,7 @@ package test;
import java.lang.module.Configuration; import java.lang.module.Configuration;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
import java.lang.reflect.Layer;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Module;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.*; import java.util.*;
@ -44,7 +42,7 @@ public class MainGC {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
ModuleFinder finder = ModuleFinder.of(MODS_DIR); ModuleFinder finder = ModuleFinder.of(MODS_DIR);
Layer layerBoot = Layer.boot(); ModuleLayer layerBoot = ModuleLayer.boot();
Configuration cf = layerBoot Configuration cf = layerBoot
.configuration() .configuration()
@ -59,7 +57,7 @@ public class MainGC {
Callable<Void> task = new Callable<Void>() { Callable<Void> task = new Callable<Void>() {
@Override @Override
public Void call() throws Exception { public Void call() throws Exception {
Layer layer = Layer.boot().defineModulesWithOneLoader(cf, scl); ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
Module transletModule = layer.findModule(MODULE_NAME).get(); Module transletModule = layer.findModule(MODULE_NAME).get();
testModule.addExports("test", transletModule); testModule.addExports("test", transletModule);
testModule.addReads(transletModule); testModule.addReads(transletModule);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,6 @@
* @run main/native GetModule * @run main/native GetModule
*/ */
import java.lang.reflect.Module;
import java.lang.management.LockInfo; import java.lang.management.LockInfo;
public class GetModule { public class GetModule {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,14 +21,14 @@
* questions. * questions.
*/ */
package java.lang.reflect; package java.lang;
import java.lang.module.ModuleDescriptor; import java.lang.module.ModuleDescriptor;
/** /**
* A helper class intended to be injected into java.lang.reflect using the * A helper class intended to be injected into java.lang using the
* java --patch-module option. The helper class provides access to package private * java --patch-module option. The helper class provides access to package private
* methods in java.lang.reflect.Module. * methods in java.lang.Module.
*/ */
public final class ModuleHelper { public final class ModuleHelper {
@ -56,8 +56,12 @@ public final class ModuleHelper {
* {@code null} then the package is exported unconditionally. * {@code null} then the package is exported unconditionally.
*/ */
public static void addExportsNoSync(Module from, String pkg, Module to) { public static void addExportsNoSync(Module from, String pkg, Module to) {
if (to == null) {
from.implAddExportsNoSync(pkg);
} else {
from.implAddExportsNoSync(pkg, to); from.implAddExportsNoSync(pkg, to);
} }
}
/** /**
* Adds a package to a module without notifying the VM. * Adds a package to a module without notifying the VM.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,8 +21,6 @@
* questions. * questions.
*/ */
import java.lang.reflect.Module;
import java.lang.reflect.Layer;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
@ -35,10 +33,10 @@ public class AllModulesCommandTestDebuggee {
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
int modCount = Layer.boot().modules().size(); int modCount = ModuleLayer.boot().modules().size();
// Send all modules names via the process output // Send all modules names via the process output
for (Module mod : Layer.boot().modules()) { for (Module mod : ModuleLayer.boot().modules()) {
String info = String.format("module %s", mod.getName()); String info = String.format("module %s", mod.getName());
write(info); write(info);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,7 +31,6 @@ package MyPackage;
*/ */
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.reflect.Module;
public class AddModuleExportsAndOpensTest { public class AddModuleExportsAndOpensTest {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,7 +47,7 @@ extern "C" {
#define FAILED 2 #define FAILED 2
static const char *EXC_CNAME = "java/lang/Exception"; static const char *EXC_CNAME = "java/lang/Exception";
static const char* MOD_CNAME = "Ljava/lang/reflect/Module;"; static const char* MOD_CNAME = "Ljava/lang/Module;";
static jvmtiEnv *jvmti = NULL; static jvmtiEnv *jvmti = NULL;
static jint result = PASSED; static jint result = PASSED;
@ -97,7 +97,7 @@ void throw_exc(JNIEnv *env, char *msg) {
} }
static static
jclass jlrM(JNIEnv *env) { jclass jlM(JNIEnv *env) {
jclass cls = NULL; jclass cls = NULL;
cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME)); cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME));
@ -127,7 +127,7 @@ jboolean is_exported(JNIEnv *env, jobject module, const char* pkg, jboolean open
if (mIsExported == NULL) { if (mIsExported == NULL) {
const char* sign = "(Ljava/lang/String;)Z"; const char* sign = "(Ljava/lang/String;)Z";
const char* name = open ? "isOpen" : "isExported"; const char* name = open ? "isOpen" : "isExported";
mIsExported = get_method(env, jlrM(env), name, sign); mIsExported = get_method(env, jlM(env), name, sign);
} }
jstr = JNI_ENV_PTR(env)->NewStringUTF(JNI_ENV_ARG(env, pkg)); jstr = JNI_ENV_PTR(env)->NewStringUTF(JNI_ENV_ARG(env, pkg));
res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module), res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module),
@ -143,9 +143,9 @@ jboolean is_exported_to(JNIEnv *env, jobject module, const char* pkg, jobject to
jboolean res = JNI_FALSE; jboolean res = JNI_FALSE;
if (mIsExportedTo == NULL) { if (mIsExportedTo == NULL) {
const char* sign = "(Ljava/lang/String;Ljava/lang/reflect/Module;)Z"; const char* sign = "(Ljava/lang/String;Ljava/lang/Module;)Z";
const char* name = open ? "isOpen" : "isExported"; const char* name = open ? "isOpen" : "isExported";
mIsExportedTo = get_method(env, jlrM(env), name, sign); mIsExportedTo = get_method(env, jlM(env), name, sign);
} }
jstr = JNI_ENV_PTR(env)->NewStringUTF(JNI_ENV_ARG(env, pkg)); jstr = JNI_ENV_PTR(env)->NewStringUTF(JNI_ENV_ARG(env, pkg));
res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module), res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module),

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,7 +32,6 @@ package MyPackage;
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.instrument.Instrumentation; import java.lang.instrument.Instrumentation;
import java.lang.reflect.Module;
public class AddModuleReadsTest { public class AddModuleReadsTest {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,7 +47,7 @@ extern "C" {
#define FAILED 2 #define FAILED 2
static const char *EXC_CNAME = "java/lang/Exception"; static const char *EXC_CNAME = "java/lang/Exception";
static const char* MOD_CNAME = "Ljava/lang/reflect/Module;"; static const char* MOD_CNAME = "Ljava/lang/Module;";
static jvmtiEnv *jvmti = NULL; static jvmtiEnv *jvmti = NULL;
static jint result = PASSED; static jint result = PASSED;
@ -96,7 +96,7 @@ void throw_exc(JNIEnv *env, char *msg) {
} }
static static
jclass jlrM(JNIEnv *env) { jclass jlM(JNIEnv *env) {
jclass cls = NULL; jclass cls = NULL;
cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME)); cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME));
@ -123,8 +123,8 @@ jboolean can_module_read(JNIEnv *env, jobject module, jobject to_module) {
jboolean res = JNI_FALSE; jboolean res = JNI_FALSE;
if (mCanRead == NULL) { if (mCanRead == NULL) {
const char* sign = "(Ljava/lang/reflect/Module;)Z"; const char* sign = "(Ljava/lang/Module;)Z";
mCanRead = get_method(env, jlrM(env), "canRead", sign); mCanRead = get_method(env, jlM(env), "canRead", sign);
} }
res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module), res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module),
mCanRead, to_module); mCanRead, to_module);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,7 +34,6 @@ package MyPackage;
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.TestProvider; import java.lang.TestProvider;
import java.lang.reflect.Module;
public class AddModuleUsesAndProvidesTest { public class AddModuleUsesAndProvidesTest {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,7 +47,7 @@ extern "C" {
#define FAILED 2 #define FAILED 2
static const char *EXC_CNAME = "java/lang/Exception"; static const char *EXC_CNAME = "java/lang/Exception";
static const char* MOD_CNAME = "Ljava/lang/reflect/Module;"; static const char* MOD_CNAME = "Ljava/lang/Module;";
static jvmtiEnv *jvmti = NULL; static jvmtiEnv *jvmti = NULL;
static jint result = PASSED; static jint result = PASSED;
@ -97,7 +97,7 @@ void throw_exc(JNIEnv *env, char *msg) {
} }
static static
jclass jlrM(JNIEnv *env) { jclass jlM(JNIEnv *env) {
jclass cls = NULL; jclass cls = NULL;
cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME)); cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME));
@ -125,7 +125,7 @@ jboolean can_use_service(JNIEnv *env, jobject module, jclass service) {
if (mCanUse == NULL) { if (mCanUse == NULL) {
const char* sign = "(Ljava/lang/Class;)Z"; const char* sign = "(Ljava/lang/Class;)Z";
mCanUse = get_method(env, jlrM(env), "canUse", sign); mCanUse = get_method(env, jlM(env), "canUse", sign);
} }
res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module), res = JNI_ENV_PTR(env)->CallBooleanMethod(JNI_ENV_ARG(env, module),
mCanUse, service); mCanUse, service);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,8 +28,6 @@
* @run main/othervm -agentlib:JvmtiGetAllModulesTest JvmtiGetAllModulesTest * @run main/othervm -agentlib:JvmtiGetAllModulesTest JvmtiGetAllModulesTest
* *
*/ */
import java.lang.reflect.Layer;
import java.lang.reflect.Module;
import java.lang.module.ModuleReference; import java.lang.module.ModuleReference;
import java.lang.module.ModuleFinder; import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReader; import java.lang.module.ModuleReader;
@ -79,15 +77,15 @@ public class JvmtiGetAllModulesTest {
final String MY_MODULE_NAME = "myModule"; final String MY_MODULE_NAME = "myModule";
// Verify that JVMTI reports exactly the same info as Java regarding the named modules // Verify that JVMTI reports exactly the same info as Java regarding the named modules
Asserts.assertEquals(Layer.boot().modules(), getModulesJVMTI()); Asserts.assertEquals(ModuleLayer.boot().modules(), getModulesJVMTI());
// Load a new named module // Load a new named module
ModuleDescriptor descriptor = ModuleDescriptor.newModule(MY_MODULE_NAME).build(); ModuleDescriptor descriptor = ModuleDescriptor.newModule(MY_MODULE_NAME).build();
ModuleFinder finder = finderOf(descriptor); ModuleFinder finder = finderOf(descriptor);
ClassLoader loader = new ClassLoader() {}; ClassLoader loader = new ClassLoader() {};
Configuration parent = Layer.boot().configuration(); Configuration parent = ModuleLayer.boot().configuration();
Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of(MY_MODULE_NAME)); Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of(MY_MODULE_NAME));
Layer my = Layer.boot().defineModules(cf, m -> loader); ModuleLayer my = ModuleLayer.boot().defineModules(cf, m -> loader);
// Verify that the loaded module is indeed reported by JVMTI // Verify that the loaded module is indeed reported by JVMTI
Set<Module> jvmtiModules = getModulesJVMTI(); Set<Module> jvmtiModules = getModulesJVMTI();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -53,7 +53,7 @@ extern "C" {
return NULL; return NULL;
} }
array = (*env)->NewObjectArray(env, modules_count, (*env)->FindClass(env, "java/lang/reflect/Module"), NULL); array = (*env)->NewObjectArray(env, modules_count, (*env)->FindClass(env, "java/lang/Module"), NULL);
for (i = 0; i < modules_count; ++i) { for (i = 0; i < modules_count; ++i) {
(*env)->SetObjectArrayElement(env, array, i, modules_ptr[i]); (*env)->SetObjectArrayElement(env, array, i, modules_ptr[i]);

View file

@ -47,7 +47,7 @@ extern "C" {
#define FAILED 2 #define FAILED 2
static const char *EXC_CNAME = "java/lang/Exception"; static const char *EXC_CNAME = "java/lang/Exception";
static const char* MOD_CNAME = "Ljava/lang/reflect/Module;"; static const char* MOD_CNAME = "Ljava/lang/Module;";
static jvmtiEnv *jvmti = NULL; static jvmtiEnv *jvmti = NULL;
static jint result = PASSED; static jint result = PASSED;
@ -115,7 +115,7 @@ jobject get_class_loader(jclass cls) {
} }
static static
jclass jlrM(JNIEnv *env) { jclass jlM(JNIEnv *env) {
jclass cls = NULL; jclass cls = NULL;
cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME)); cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME));
@ -142,7 +142,7 @@ jobject get_module_loader(JNIEnv *env, jobject module) {
jobject loader = NULL; jobject loader = NULL;
if (cl_method == NULL) { if (cl_method == NULL) {
cl_method = get_method(env, jlrM(env), "getClassLoader", "()Ljava/lang/ClassLoader;"); cl_method = get_method(env, jlM(env), "getClassLoader", "()Ljava/lang/ClassLoader;");
} }
loader = (jobject)JNI_ENV_PTR(env)->CallObjectMethod(JNI_ENV_ARG(env, module), cl_method); loader = (jobject)JNI_ENV_PTR(env)->CallObjectMethod(JNI_ENV_ARG(env, module), cl_method);
return loader; return loader;
@ -157,7 +157,7 @@ const char* get_module_name(JNIEnv *env, jobject module) {
const char *nstr = NULL; const char *nstr = NULL;
if (method == NULL) { if (method == NULL) {
method = get_method(env, jlrM(env), "getName", "()Ljava/lang/String;"); method = get_method(env, jlM(env), "getName", "()Ljava/lang/String;");
} }
jstr = (jstring)JNI_ENV_PTR(env)->CallObjectMethod(JNI_ENV_ARG(env, module), method); jstr = (jstring)JNI_ENV_PTR(env)->CallObjectMethod(JNI_ENV_ARG(env, module), method);
if (jstr != NULL) { if (jstr != NULL) {