1 /*
2 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_CLASSFILE_MODULES_HPP
26 #define SHARE_VM_CLASSFILE_MODULES_HPP
27
28 #include "memory/allocation.hpp"
29 #include "runtime/handles.hpp"
30
31 class Symbol;
32
33 class Modules : AllStatic {
34
35 public:
36 // define_module defines a module containing the specified packages. It binds the
37 // module to its class loader by creating the ModuleEntry record in the
38 // ClassLoader's ModuleEntry table, and creates PackageEntry records in the class
39 // loader's PackageEntry table. As in JVM_DefineClass the jstring format for all
40 // package names must use "/" and not "."
41 //
42 // IllegalArgumentExceptions are thrown for the following :
43 // * Module's Class loader is not a subclass of java.lang.ClassLoader
44 // * Module's Class loader already has a module with that name
45 // * Module's Class loader has already defined types for any of the module's packages
46 // * Module_name is syntactically bad
47 // * Packages contains an illegal package name
48 // * A package already exists in another module for this class loader
49 // * Module is an unnamed module
50 // * num_packages is negative
105 // IllegalArgumentException is thrown if loader is neither null nor a subtype of
106 // java/lang/ClassLoader.
107 static jobject get_named_module(Handle h_loader, const char* package, TRAPS);
108
109 // If package is defined by loader, return the
110 // java.lang.Module object for the module in which the package is defined.
111 // Returns NULL if package is invalid or not defined by loader.
112 static jobject get_module(Symbol* package_name, Handle h_loader, TRAPS);
113
114 // Marks the specified package as exported to all unnamed modules.
115 // If either module or package is null then NullPointerException is thrown.
116 // If module or package is bad, or module is unnamed, or package is not in
117 // module then IllegalArgumentException is thrown.
118 static void add_module_exports_to_all_unnamed(jobject module, const char* package, TRAPS);
119
120 // Return TRUE if package_name is syntactically valid, false otherwise.
121 static bool verify_package_name(const char *package_name);
122
123 // Return TRUE iff package is defined by loader
124 static bool is_package_defined(Symbol* package_name, Handle h_loader, TRAPS);
125 };
126
127 #endif // SHARE_VM_CLASSFILE_MODULES_HPP
|
1 /*
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_CLASSFILE_MODULES_HPP
26 #define SHARE_VM_CLASSFILE_MODULES_HPP
27
28 #include "memory/allocation.hpp"
29 #include "runtime/handles.hpp"
30
31 class ModuleEntryTable;
32 class Symbol;
33
34 class Modules : AllStatic {
35
36 public:
37 // define_module defines a module containing the specified packages. It binds the
38 // module to its class loader by creating the ModuleEntry record in the
39 // ClassLoader's ModuleEntry table, and creates PackageEntry records in the class
40 // loader's PackageEntry table. As in JVM_DefineClass the jstring format for all
41 // package names must use "/" and not "."
42 //
43 // IllegalArgumentExceptions are thrown for the following :
44 // * Module's Class loader is not a subclass of java.lang.ClassLoader
45 // * Module's Class loader already has a module with that name
46 // * Module's Class loader has already defined types for any of the module's packages
47 // * Module_name is syntactically bad
48 // * Packages contains an illegal package name
49 // * A package already exists in another module for this class loader
50 // * Module is an unnamed module
51 // * num_packages is negative
106 // IllegalArgumentException is thrown if loader is neither null nor a subtype of
107 // java/lang/ClassLoader.
108 static jobject get_named_module(Handle h_loader, const char* package, TRAPS);
109
110 // If package is defined by loader, return the
111 // java.lang.Module object for the module in which the package is defined.
112 // Returns NULL if package is invalid or not defined by loader.
113 static jobject get_module(Symbol* package_name, Handle h_loader, TRAPS);
114
115 // Marks the specified package as exported to all unnamed modules.
116 // If either module or package is null then NullPointerException is thrown.
117 // If module or package is bad, or module is unnamed, or package is not in
118 // module then IllegalArgumentException is thrown.
119 static void add_module_exports_to_all_unnamed(jobject module, const char* package, TRAPS);
120
121 // Return TRUE if package_name is syntactically valid, false otherwise.
122 static bool verify_package_name(const char *package_name);
123
124 // Return TRUE iff package is defined by loader
125 static bool is_package_defined(Symbol* package_name, Handle h_loader, TRAPS);
126 static ModuleEntryTable* get_module_entry_table(Handle h_loader);
127 };
128
129 #endif // SHARE_VM_CLASSFILE_MODULES_HPP
|