< prev index next >

src/hotspot/share/classfile/modules.hpp

Print this page
rev 58870 : 8242452: During module definition, move conversion of packages from native to VM
8242290: Pointless verification in get_package_entry_by_name
Reviewed-by: lfoltan, alanb, iklam


  20 * or visit www.oracle.com if you need additional information or have any
  21 * questions.
  22 *
  23 */
  24 
  25 #ifndef SHARE_CLASSFILE_MODULES_HPP
  26 #define SHARE_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
  52   // * num_packages is non-zero when packages is null
  53   //  NullPointerExceptions are thrown if module is null.
  54   static void define_module(jobject module, jboolean is_open, jstring version,
  55                             jstring location, const char* const* packages,
  56                             jsize num_packages, TRAPS);
  57 
  58   // Provides the java.lang.Module for the unnamed module defined
  59   // to the boot loader.
  60   //
  61   //  IllegalArgumentExceptions are thrown for the following :
  62   //  * Module has a name
  63   //  * Module is not a subclass of java.lang.Module
  64   //  * Module's class loader is not the boot loader
  65   //  NullPointerExceptions are thrown if module is null.
  66   static void set_bootloader_unnamed_module(jobject module, TRAPS);
  67 
  68   // This either does a qualified export of package in module from_module to module
  69   // to_module or, if to_module is null, does an unqualified export of package.
  70   // The format for the package name must use "/' not ".".
  71   //
  72   // Error conditions causing IlegalArgumentException to be throw :
  73   // * Module from_module does not exist
  74   // * Module to_module is not null and does not exist
  75   // * Package is not syntactically correct
  76   // * Package is not defined for from_module's class loader
  77   // * Package is not in module from_module.
  78   static void add_module_exports(jobject from_module, const char* package, jobject to_module, TRAPS);
  79 
  80   // This does a qualified export of package in module from_module to module
  81   // to_module.  The format for the package name must use "/' not ".".
  82   //
  83   // Error conditions causing IlegalArgumentException to be throw :
  84   // * Module from_module does not exist
  85   // * Module to_module does not exist
  86   // * Package is not syntactically correct
  87   // * Package is not defined for from_module's class loader
  88   // * Package is not in module from_module.
  89   static void add_module_exports_qualified(jobject from_module, const char* package, jobject to_module, TRAPS);
  90 
  91   // add_reads_module adds module to_module to the list of modules that from_module
  92   // can read.  If from_module is the same as to_module then this is a no-op.
  93   // If to_module is null then from_module is marked as a loose module (meaning that
  94   // from_module can read all current and future unnamed  modules).
  95   // An IllegalArgumentException is thrown if from_module is null or either (non-null)
  96   // module does not exist.
  97   static void add_reads_module(jobject from_module, jobject to_module, TRAPS);
  98 
  99   // Return the java.lang.Module object for this class object.
 100   static jobject get_module(jclass clazz, TRAPS);
 101 
 102   // Return the java.lang.Module object for this class loader and package.
 103   // Returns NULL if the class loader has not loaded any classes in the package.
 104   // The package should contain /'s, not .'s, as in java/lang, not java.lang.
 105   // NullPointerException is thrown if package is null.
 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   // Marks the specified package as exported to all unnamed modules.
 111   // If either module or package is null then NullPointerException is thrown.
 112   // If module or package is bad, or module is unnamed, or package is not in
 113   // module then IllegalArgumentException is thrown.
 114   static void add_module_exports_to_all_unnamed(jobject module, const char* package, TRAPS);
 115 
 116   // Return TRUE if package_name is syntactically valid, false otherwise.
 117   static bool verify_package_name(const char *package_name);
 118 
 119   // Return TRUE iff package is defined by loader
 120   static bool is_package_defined(Symbol* package_name, Handle h_loader, TRAPS);
 121   static ModuleEntryTable* get_module_entry_table(Handle h_loader);
 122 };
 123 
 124 #endif // SHARE_CLASSFILE_MODULES_HPP


  20 * or visit www.oracle.com if you need additional information or have any
  21 * questions.
  22 *
  23 */
  24 
  25 #ifndef SHARE_CLASSFILE_MODULES_HPP
  26 #define SHARE_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.  The jstring for all package names will convert "."
  41   // to "/"
  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 or a non-String object
  49   // * A package already exists in another module for this class loader
  50   // * Module is an unnamed module


  51   //  NullPointerExceptions are thrown if module is null.
  52   static void define_module(jobject module, jboolean is_open, jstring version,
  53                             jstring location, jobjectArray packages, TRAPS);

  54 
  55   // Provides the java.lang.Module for the unnamed module defined
  56   // to the boot loader.
  57   //
  58   //  IllegalArgumentExceptions are thrown for the following :
  59   //  * Module has a name
  60   //  * Module is not a subclass of java.lang.Module
  61   //  * Module's class loader is not the boot loader
  62   //  NullPointerExceptions are thrown if module is null.
  63   static void set_bootloader_unnamed_module(jobject module, TRAPS);
  64 
  65   // This either does a qualified export of package in module from_module to module
  66   // to_module or, if to_module is null, does an unqualified export of package.
  67   // Any "." in the package name will be converted to to "/"
  68   //
  69   // Error conditions causing IlegalArgumentException to be throw :
  70   // * Module from_module does not exist
  71   // * Module to_module is not null and does not exist
  72   // * Package is not syntactically correct
  73   // * Package is not defined for from_module's class loader
  74   // * Package is not in module from_module.
  75   static void add_module_exports(jobject from_module, jstring package, jobject to_module, TRAPS);
  76 
  77   // This does a qualified export of package in module from_module to module
  78   // to_module.  Any "." in the package name will be converted to to "/"
  79   //
  80   // Error conditions causing IlegalArgumentException to be throw :
  81   // * Module from_module does not exist
  82   // * Module to_module does not exist
  83   // * Package is not syntactically correct
  84   // * Package is not defined for from_module's class loader
  85   // * Package is not in module from_module.
  86   static void add_module_exports_qualified(jobject from_module, jstring package, jobject to_module, TRAPS);
  87 
  88   // add_reads_module adds module to_module to the list of modules that from_module
  89   // can read.  If from_module is the same as to_module then this is a no-op.
  90   // If to_module is null then from_module is marked as a loose module (meaning that
  91   // from_module can read all current and future unnamed  modules).
  92   // An IllegalArgumentException is thrown if from_module is null or either (non-null)
  93   // module does not exist.
  94   static void add_reads_module(jobject from_module, jobject to_module, TRAPS);
  95 
  96   // Return the java.lang.Module object for this class object.
  97   static jobject get_module(jclass clazz, TRAPS);
  98 
  99   // Return the java.lang.Module object for this class loader and package.
 100   // Returns NULL if the class loader has not loaded any classes in the package.
 101   // The package should contain /'s, not .'s, as in java/lang, not java.lang.
 102   // NullPointerException is thrown if package is null.
 103   // IllegalArgumentException is thrown if loader is neither null nor a subtype of
 104   // java/lang/ClassLoader.
 105   static jobject get_named_module(Handle h_loader, const char* package, TRAPS);
 106 
 107   // Marks the specified package as exported to all unnamed modules.
 108   // If either module or package is null then NullPointerException is thrown.
 109   // If module or package is bad, or module is unnamed, or package is not in
 110   // module then IllegalArgumentException is thrown.
 111   static void add_module_exports_to_all_unnamed(jobject module, jstring package, TRAPS);



 112 
 113   // Return TRUE iff package is defined by loader
 114   static bool is_package_defined(Symbol* package_name, Handle h_loader, TRAPS);
 115   static ModuleEntryTable* get_module_entry_table(Handle h_loader);
 116 };
 117 
 118 #endif // SHARE_CLASSFILE_MODULES_HPP
< prev index next >