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_SYSTEMDICTIONARY_HPP
26 #define SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
27
28 #include "classfile/classFileStream.hpp"
29 #include "classfile/classLoader.hpp"
30 #include "oops/objArrayOop.hpp"
31 #include "oops/symbol.hpp"
32 #include "runtime/java.hpp"
33 #include "runtime/reflectionUtils.hpp"
34 #include "utilities/hashtable.hpp"
35 #include "utilities/hashtable.inline.hpp"
36 #include "jvmci/systemDictionary_jvmci.hpp"
37
38
39 // The system dictionary stores all loaded classes and maps:
40 //
41 // [class name,class loader] -> class i.e. [Symbol*,oop] -> Klass*
42 //
43 // Classes are loaded lazily. The default VM class loader is
44 // represented as NULL.
45
46 // The underlying data structure is an open hash table with a fixed number
47 // of buckets. During loading the loader object is locked, (for the VM loader
48 // a private lock object is used). Class loading can thus be done concurrently,
49 // but only by different loaders.
177 do_klass(URL_klass, java_net_URL, Pre ) \
178 do_klass(Jar_Manifest_klass, java_util_jar_Manifest, Pre ) \
179 do_klass(sun_misc_Launcher_klass, sun_misc_Launcher, Pre ) \
180 do_klass(CodeSource_klass, java_security_CodeSource, Pre ) \
181 \
182 /* It's NULL in non-1.4 JDKs. */ \
183 do_klass(StackTraceElement_klass, java_lang_StackTraceElement, Opt ) \
184 /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
185 do_klass(nio_Buffer_klass, java_nio_Buffer, Opt ) \
186 \
187 /* Preload boxing klasses */ \
188 do_klass(Boolean_klass, java_lang_Boolean, Pre ) \
189 do_klass(Character_klass, java_lang_Character, Pre ) \
190 do_klass(Float_klass, java_lang_Float, Pre ) \
191 do_klass(Double_klass, java_lang_Double, Pre ) \
192 do_klass(Byte_klass, java_lang_Byte, Pre ) \
193 do_klass(Short_klass, java_lang_Short, Pre ) \
194 do_klass(Integer_klass, java_lang_Integer, Pre ) \
195 do_klass(Long_klass, java_lang_Long, Pre ) \
196 \
197 /* JVMCI classes. These are loaded on-demand. */ \
198 JVMCI_WK_KLASSES_DO(do_klass) \
199
200 /*end*/
201
202
203 class SystemDictionary : AllStatic {
204 friend class VMStructs;
205 friend class SystemDictionaryHandles;
206
207 public:
208 enum WKID {
209 NO_WKID = 0,
210
211 #define WK_KLASS_ENUM(name, symbol, ignore_o) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
212 WK_KLASSES_DO(WK_KLASS_ENUM)
213 #undef WK_KLASS_ENUM
214
215 WKID_LIMIT,
216
217 #if INCLUDE_JVMCI
218 FIRST_JVMCI_WKID = WK_KLASS_ENUM_NAME(HotSpotCompiledCode_klass),
219 LAST_JVMCI_WKID = WK_KLASS_ENUM_NAME(Value_klass),
220 #endif
221
222 FIRST_WKID = NO_WKID + 1
223 };
224
225 enum InitOption {
649
650 protected:
651 static Klass* find_shared_class(Symbol* class_name);
652
653 // Setup link to hierarchy
654 static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
655
656 // event based tracing
657 static void post_class_load_event(const Ticks& start_time, instanceKlassHandle k,
658 Handle initiating_loader);
659 // We pass in the hashtable index so we can calculate it outside of
660 // the SystemDictionary_lock.
661
662 // Basic find on loaded classes
663 static Klass* find_class(int index, unsigned int hash,
664 Symbol* name, ClassLoaderData* loader_data);
665 static Klass* find_class(Symbol* class_name, ClassLoaderData* loader_data);
666
667 // Basic find on classes in the midst of being loaded
668 static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
669
670 // Updating entry in dictionary
671 // Add a completely loaded class
672 static void add_klass(int index, Symbol* class_name,
673 ClassLoaderData* loader_data, KlassHandle obj);
674
675 // Add a placeholder for a class being loaded
676 static void add_placeholder(int index,
677 Symbol* class_name,
678 ClassLoaderData* loader_data);
679 static void remove_placeholder(int index,
680 Symbol* class_name,
681 ClassLoaderData* loader_data);
682
683 // Performs cleanups after resolve_super_or_fail. This typically needs
684 // to be called on failure.
685 // Won't throw, but can block.
686 static void resolution_cleanups(Symbol* class_name,
687 ClassLoaderData* loader_data,
688 TRAPS);
689
690 // Initialization
691 static void initialize_preloaded_classes(TRAPS);
692
693 // Class loader constraints
|
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_SYSTEMDICTIONARY_HPP
26 #define SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
27
28 #include "classfile/classFileStream.hpp"
29 #include "classfile/classLoader.hpp"
30 #include "classfile/systemDictionary_ext.hpp"
31 #include "oops/objArrayOop.hpp"
32 #include "oops/symbol.hpp"
33 #include "runtime/java.hpp"
34 #include "runtime/reflectionUtils.hpp"
35 #include "utilities/hashtable.hpp"
36 #include "utilities/hashtable.inline.hpp"
37 #include "jvmci/systemDictionary_jvmci.hpp"
38
39
40 // The system dictionary stores all loaded classes and maps:
41 //
42 // [class name,class loader] -> class i.e. [Symbol*,oop] -> Klass*
43 //
44 // Classes are loaded lazily. The default VM class loader is
45 // represented as NULL.
46
47 // The underlying data structure is an open hash table with a fixed number
48 // of buckets. During loading the loader object is locked, (for the VM loader
49 // a private lock object is used). Class loading can thus be done concurrently,
50 // but only by different loaders.
178 do_klass(URL_klass, java_net_URL, Pre ) \
179 do_klass(Jar_Manifest_klass, java_util_jar_Manifest, Pre ) \
180 do_klass(sun_misc_Launcher_klass, sun_misc_Launcher, Pre ) \
181 do_klass(CodeSource_klass, java_security_CodeSource, Pre ) \
182 \
183 /* It's NULL in non-1.4 JDKs. */ \
184 do_klass(StackTraceElement_klass, java_lang_StackTraceElement, Opt ) \
185 /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
186 do_klass(nio_Buffer_klass, java_nio_Buffer, Opt ) \
187 \
188 /* Preload boxing klasses */ \
189 do_klass(Boolean_klass, java_lang_Boolean, Pre ) \
190 do_klass(Character_klass, java_lang_Character, Pre ) \
191 do_klass(Float_klass, java_lang_Float, Pre ) \
192 do_klass(Double_klass, java_lang_Double, Pre ) \
193 do_klass(Byte_klass, java_lang_Byte, Pre ) \
194 do_klass(Short_klass, java_lang_Short, Pre ) \
195 do_klass(Integer_klass, java_lang_Integer, Pre ) \
196 do_klass(Long_klass, java_lang_Long, Pre ) \
197 \
198 /* Extensions */ \
199 WK_KLASSES_DO_EXT(do_klass) \
200 /* JVMCI classes. These are loaded on-demand. */ \
201 JVMCI_WK_KLASSES_DO(do_klass) \
202 \
203 /*end*/
204
205
206 class SystemDictionary : AllStatic {
207 friend class VMStructs;
208 friend class SystemDictionaryHandles;
209 friend class SharedClassUtil;
210
211 public:
212 enum WKID {
213 NO_WKID = 0,
214
215 #define WK_KLASS_ENUM(name, symbol, ignore_o) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
216 WK_KLASSES_DO(WK_KLASS_ENUM)
217 #undef WK_KLASS_ENUM
218
219 WKID_LIMIT,
220
221 #if INCLUDE_JVMCI
222 FIRST_JVMCI_WKID = WK_KLASS_ENUM_NAME(HotSpotCompiledCode_klass),
223 LAST_JVMCI_WKID = WK_KLASS_ENUM_NAME(Value_klass),
224 #endif
225
226 FIRST_WKID = NO_WKID + 1
227 };
228
229 enum InitOption {
653
654 protected:
655 static Klass* find_shared_class(Symbol* class_name);
656
657 // Setup link to hierarchy
658 static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
659
660 // event based tracing
661 static void post_class_load_event(const Ticks& start_time, instanceKlassHandle k,
662 Handle initiating_loader);
663 // We pass in the hashtable index so we can calculate it outside of
664 // the SystemDictionary_lock.
665
666 // Basic find on loaded classes
667 static Klass* find_class(int index, unsigned int hash,
668 Symbol* name, ClassLoaderData* loader_data);
669 static Klass* find_class(Symbol* class_name, ClassLoaderData* loader_data);
670
671 // Basic find on classes in the midst of being loaded
672 static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
673
674 // Add a placeholder for a class being loaded
675 static void add_placeholder(int index,
676 Symbol* class_name,
677 ClassLoaderData* loader_data);
678 static void remove_placeholder(int index,
679 Symbol* class_name,
680 ClassLoaderData* loader_data);
681
682 // Performs cleanups after resolve_super_or_fail. This typically needs
683 // to be called on failure.
684 // Won't throw, but can block.
685 static void resolution_cleanups(Symbol* class_name,
686 ClassLoaderData* loader_data,
687 TRAPS);
688
689 // Initialization
690 static void initialize_preloaded_classes(TRAPS);
691
692 // Class loader constraints
|