hotspot/src/share/vm/classfile/moduleEntry.hpp
author alanb
Thu, 17 Mar 2016 19:04:01 +0000
changeset 36508 5f9eee6b383b
child 37503 77531df4dad3
permissions -rw-r--r--
8142968: Module System implementation Summary: Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282 Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, harold.seigel@oracle.com, lois.foltan@oracle.com, calvin.cheung@oracle.com, christian.tornqvist@oracle.com, erik.joelsson@oracle.com, george.triantafillou@oracle.com, igor.ignatyev@oracle.com, ioi.lam@oracle.com, james.laskey@oracle.com, jean-francois.denise@oracle.com, jiangli.zhou@oracle.com, markus.gronlund@oracle.com, serguei.spitsyn@oracle.com, staffan.larsen@oracle.com, sundararajan.athijegannathan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    23
 */
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    24
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    25
#ifndef SHARE_VM_CLASSFILE_MODULEENTRY_HPP
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    26
#define SHARE_VM_CLASSFILE_MODULEENTRY_HPP
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    27
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    28
#include "classfile/classLoaderData.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    29
#include "classfile/vmSymbols.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    30
#include "oops/symbol.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    31
#include "prims/jni.h"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    32
#include "runtime/mutexLocker.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    33
#include "trace/traceMacros.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    34
#include "utilities/growableArray.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    35
#include "utilities/hashtable.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    36
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    37
#define UNNAMED_MODULE "Unnamed Module"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    38
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    39
class ModuleClosure;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    40
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    41
// A ModuleEntry describes a module that has been defined by a call to JVM_DefineModule.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    42
// It contains:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    43
//   - Symbol* containing the module's name.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    44
//   - pointer to the java.lang.reflect.Module for this module.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    45
//   - ClassLoaderData*, class loader of this module.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    46
//   - a growable array containg other module entries that this module can read.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    47
//   - a flag indicating if this module can read all unnamed modules.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    48
//
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    49
// The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    50
// data structure.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    51
class ModuleEntry : public HashtableEntry<Symbol*, mtClass> {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    52
private:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    53
  jobject _module;                     // java.lang.reflect.Module
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    54
  jobject _pd;                         // java.security.ProtectionDomain, cached
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    55
                                       // for shared classes from this module
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    56
  ClassLoaderData* _loader;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    57
  GrowableArray<ModuleEntry*>* _reads; // list of modules that are readable by this module
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    58
  Symbol* _version;                    // module version number
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    59
  Symbol* _location;                   // module location
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    60
  bool _can_read_all_unnamed;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    61
  bool _has_default_read_edges;        // JVMTI redefine/retransform support
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    62
  TRACE_DEFINE_TRACE_ID_FIELD;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    63
  enum {MODULE_READS_SIZE = 101};      // Initial size of list of modules that the module can read.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    64
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    65
public:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    66
  void init() {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    67
    _module = NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    68
    _loader = NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    69
    _pd = NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    70
    _reads = NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    71
    _version = NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    72
    _location = NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    73
    _can_read_all_unnamed = false;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    74
    _has_default_read_edges = false;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    75
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    76
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    77
  Symbol*            name() const          { return literal(); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    78
  void               set_name(Symbol* n)   { set_literal(n); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    79
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    80
  jobject            module() const        { return _module; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    81
  void               set_module(jobject j) { _module = j; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    82
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    83
  // The shared ProtectionDomain reference is set once the VM loads a shared class
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    84
  // originated from the current Module. The referenced ProtectionDomain object is
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    85
  // created by the ClassLoader when loading a class (shared or non-shared) from the
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    86
  // Module for the first time. This ProtectionDomain object is used for all
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    87
  // classes from the Module loaded by the same ClassLoader.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    88
  Handle             shared_protection_domain();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    89
  void               set_shared_protection_domain(ClassLoaderData *loader_data,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    90
                                                  Handle pd);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    91
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    92
  ClassLoaderData*   loader() const                 { return _loader; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    93
  void               set_loader(ClassLoaderData* l) { _loader = l; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    94
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    95
  Symbol*            version() const                { return _version; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    96
  void               set_version(Symbol* version);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    97
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    98
  Symbol*            location() const               { return _location; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    99
  void               set_location(Symbol* location);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   100
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   101
  bool               can_read(ModuleEntry* m) const;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   102
  bool               has_reads() const;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   103
  void               add_read(ModuleEntry* m);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   104
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   105
  bool               is_named() const               { return (literal() != NULL); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   106
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   107
  bool can_read_all_unnamed() const {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   108
    assert(is_named() || _can_read_all_unnamed == true,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   109
           "unnamed modules can always read all unnamed modules");
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   110
    return _can_read_all_unnamed;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   111
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   112
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   113
  // Modules can only go from strict to loose.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   114
  void set_can_read_all_unnamed() { _can_read_all_unnamed = true; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   115
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   116
  bool has_default_read_edges() const {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   117
    return _has_default_read_edges;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   118
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   119
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   120
  // Sets true and returns the previous value.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   121
  bool set_has_default_read_edges() {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   122
    MutexLocker ml(Module_lock);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   123
    bool prev = _has_default_read_edges;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   124
    _has_default_read_edges = true;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   125
    return prev;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   126
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   127
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   128
  ModuleEntry* next() const {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   129
    return (ModuleEntry*)HashtableEntry<Symbol*, mtClass>::next();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   130
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   131
  ModuleEntry** next_addr() {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   132
    return (ModuleEntry**)HashtableEntry<Symbol*, mtClass>::next_addr();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   133
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   134
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   135
  // iteration support for readability
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   136
  void module_reads_do(ModuleClosure* const f);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   137
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   138
  TRACE_DEFINE_TRACE_ID_METHODS;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   139
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   140
  // Purge dead weak references out of reads list when any given class loader is unloaded.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   141
  void purge_reads();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   142
  void delete_reads();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   143
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   144
  void print() PRODUCT_RETURN;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   145
  void verify();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   146
};
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   147
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   148
// Iterator interface
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   149
class ModuleClosure: public StackObj {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   150
 public:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   151
  virtual void do_module(ModuleEntry* const module) = 0;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   152
};
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   153
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   154
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   155
// The ModuleEntryTable is a Hashtable containing a list of all modules defined
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   156
// by a particular class loader.  Each module is represented as a ModuleEntry node.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   157
//
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   158
// Each ModuleEntryTable contains a _javabase_module field which allows for the
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   159
// creation of java.base's ModuleEntry very early in bootstrapping before the
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   160
// corresponding JVM_DefineModule call for java.base occurs during module system
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   161
// initialization.  Setting up java.base's ModuleEntry early enables classes,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   162
// loaded prior to the module system being initialized to be created with their
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   163
// PackageEntry node's correctly pointing at java.base's ModuleEntry.  No class
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   164
// outside of java.base is allowed to be loaded pre-module system initialization.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   165
//
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   166
// The ModuleEntryTable's lookup is lock free.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   167
//
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   168
class ModuleEntryTable : public Hashtable<Symbol*, mtClass> {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   169
  friend class VMStructs;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   170
public:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   171
  enum Constants {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   172
    _moduletable_entry_size  = 109 // number of entries in module entry table
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   173
  };
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   174
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   175
private:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   176
  static ModuleEntry* _javabase_module;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   177
  ModuleEntry* _unnamed_module;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   178
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   179
  ModuleEntry* new_entry(unsigned int hash, Handle module_handle, Symbol* name, Symbol* version,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   180
                         Symbol* location, ClassLoaderData* class_loader);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   181
  void add_entry(int index, ModuleEntry* new_entry);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   182
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   183
  int entry_size() const { return BasicHashtable<mtClass>::entry_size(); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   184
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   185
  ModuleEntry** bucket_addr(int i) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   186
    return (ModuleEntry**)Hashtable<Symbol*, mtClass>::bucket_addr(i);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   187
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   188
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   189
  static unsigned int compute_hash(Symbol* name) { return ((name == NULL) ? 0 : (unsigned int)(name->identity_hash())); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   190
  int index_for(Symbol* name) const              { return hash_to_index(compute_hash(name)); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   191
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   192
public:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   193
  ModuleEntryTable(int table_size);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   194
  ~ModuleEntryTable();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   195
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   196
  ModuleEntry* bucket(int i) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   197
    return (ModuleEntry*)Hashtable<Symbol*, mtClass>::bucket(i);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   198
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   199
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   200
  // Create module in loader's module entry table, if already exists then
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   201
  // return null.  Assume Module_lock has been locked by caller.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   202
  ModuleEntry* locked_create_entry_or_null(Handle module_handle,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   203
                                           Symbol* module_name,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   204
                                           Symbol* module_version,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   205
                                           Symbol* module_location,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   206
                                           ClassLoaderData* loader_data);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   207
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   208
  // Only lookup module within loader's module entry table.  The table read is lock-free.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   209
  ModuleEntry* lookup_only(Symbol* name);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   210
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   211
  // purge dead weak references out of reads list
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   212
  void purge_all_module_reads();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   213
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   214
  // Special handling for unnamed module, one per class loader's ModuleEntryTable
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   215
  void create_unnamed_module(ClassLoaderData* loader_data);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   216
  ModuleEntry* unnamed_module()                           { return _unnamed_module; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   217
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   218
  // Special handling for java.base
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   219
  static ModuleEntry* javabase_module()                   { return _javabase_module; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   220
  static void set_javabase_module(ModuleEntry* java_base) { _javabase_module = java_base; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   221
  static bool javabase_defined()                          { return ((_javabase_module != NULL) &&
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   222
                                                                    (_javabase_module->module() != NULL)); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   223
  static void finalize_javabase(Handle module_handle, Symbol* version, Symbol* location);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   224
  static void patch_javabase_entries(Handle module_handle);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   225
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   226
  void print() PRODUCT_RETURN;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   227
  void verify();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   228
};
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   229
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   230
#endif // SHARE_VM_CLASSFILE_MODULEENTRY_HPP