1 /*
2 * Copyright (c) 1997, 2015, 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 *
25 #include "precompiled.hpp"
26 #include "classfile/classFileParser.hpp"
27 #include "classfile/classFileStream.hpp"
28 #include "classfile/classLoader.hpp"
29 #include "classfile/classLoaderData.inline.hpp"
30 #include "classfile/classLoaderExt.hpp"
31 #include "classfile/dictionary.hpp"
32 #include "classfile/javaClasses.inline.hpp"
33 #include "classfile/klassFactory.hpp"
34 #include "classfile/loaderConstraints.hpp"
35 #include "classfile/placeholders.hpp"
36 #include "classfile/resolutionErrors.hpp"
37 #include "classfile/stringTable.hpp"
38 #include "classfile/systemDictionary.hpp"
39 #include "classfile/vmSymbols.hpp"
40 #include "code/codeCache.hpp"
41 #include "compiler/compileBroker.hpp"
42 #include "gc/shared/gcLocker.hpp"
43 #include "interpreter/bytecodeStream.hpp"
44 #include "interpreter/interpreter.hpp"
45 #include "memory/filemap.hpp"
46 #include "memory/oopFactory.hpp"
47 #include "oops/instanceKlass.hpp"
48 #include "oops/instanceRefKlass.hpp"
49 #include "oops/klass.inline.hpp"
50 #include "oops/methodData.hpp"
51 #include "oops/objArrayKlass.hpp"
52 #include "oops/objArrayOop.inline.hpp"
53 #include "oops/oop.inline.hpp"
54 #include "oops/typeArrayKlass.hpp"
55 #include "prims/jvmtiEnvBase.hpp"
56 #include "prims/methodHandles.hpp"
57 #include "runtime/arguments.hpp"
58 #include "runtime/biasedLocking.hpp"
59 #include "runtime/fieldType.hpp"
60 #include "runtime/handles.inline.hpp"
61 #include "runtime/java.hpp"
62 #include "runtime/javaCalls.hpp"
63 #include "runtime/mutexLocker.hpp"
64 #include "runtime/orderAccess.inline.hpp"
1285
1286 // Adjust methods to recover missing data. They need addresses for
1287 // interpreter entry points and their default native method address
1288 // must be reset.
1289
1290 // Updating methods must be done under a lock so multiple
1291 // threads don't update these in parallel
1292 //
1293 // Shared classes are all currently loaded by either the bootstrap or
1294 // internal parallel class loaders, so this will never cause a deadlock
1295 // on a custom class loader lock.
1296
1297 ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader());
1298 {
1299 Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
1300 check_loader_lock_contention(lockObject, THREAD);
1301 ObjectLocker ol(lockObject, THREAD, true);
1302 ik->restore_unshareable_info(loader_data, protection_domain, CHECK_(nh));
1303 }
1304
1305 if (TraceClassLoading) {
1306 ResourceMark rm;
1307 tty->print("[Loaded %s", ik->external_name());
1308 tty->print(" from shared objects file");
1309 if (class_loader.not_null()) {
1310 tty->print(" by %s", loader_data->loader_name());
1311 }
1312 tty->print_cr("]");
1313 }
1314
1315 if (DumpLoadedClassList != NULL && classlist_file->is_open()) {
1316 // Only dump the classes that can be stored into CDS archive
1317 if (SystemDictionaryShared::is_sharing_possible(loader_data)) {
1318 ResourceMark rm(THREAD);
1319 classlist_file->print_cr("%s", ik->name()->as_C_string());
1320 classlist_file->flush();
1321 }
1322 }
1323
1324 // notify a class loaded from shared object
1325 ClassLoadingService::notify_class_loaded(ik(), true /* shared class */);
1326 }
1327 return ik;
1328 }
1329 #endif // INCLUDE_CDS
1330
1331 instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) {
1332 instanceKlassHandle nh = instanceKlassHandle(); // null Handle
|
1 /*
2 * Copyright (c) 1997, 2016, 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 *
25 #include "precompiled.hpp"
26 #include "classfile/classFileParser.hpp"
27 #include "classfile/classFileStream.hpp"
28 #include "classfile/classLoader.hpp"
29 #include "classfile/classLoaderData.inline.hpp"
30 #include "classfile/classLoaderExt.hpp"
31 #include "classfile/dictionary.hpp"
32 #include "classfile/javaClasses.inline.hpp"
33 #include "classfile/klassFactory.hpp"
34 #include "classfile/loaderConstraints.hpp"
35 #include "classfile/placeholders.hpp"
36 #include "classfile/resolutionErrors.hpp"
37 #include "classfile/stringTable.hpp"
38 #include "classfile/systemDictionary.hpp"
39 #include "classfile/vmSymbols.hpp"
40 #include "code/codeCache.hpp"
41 #include "compiler/compileBroker.hpp"
42 #include "gc/shared/gcLocker.hpp"
43 #include "interpreter/bytecodeStream.hpp"
44 #include "interpreter/interpreter.hpp"
45 #include "logging/log.hpp"
46 #include "memory/filemap.hpp"
47 #include "memory/oopFactory.hpp"
48 #include "oops/instanceKlass.hpp"
49 #include "oops/instanceRefKlass.hpp"
50 #include "oops/klass.inline.hpp"
51 #include "oops/methodData.hpp"
52 #include "oops/objArrayKlass.hpp"
53 #include "oops/objArrayOop.inline.hpp"
54 #include "oops/oop.inline.hpp"
55 #include "oops/typeArrayKlass.hpp"
56 #include "prims/jvmtiEnvBase.hpp"
57 #include "prims/methodHandles.hpp"
58 #include "runtime/arguments.hpp"
59 #include "runtime/biasedLocking.hpp"
60 #include "runtime/fieldType.hpp"
61 #include "runtime/handles.inline.hpp"
62 #include "runtime/java.hpp"
63 #include "runtime/javaCalls.hpp"
64 #include "runtime/mutexLocker.hpp"
65 #include "runtime/orderAccess.inline.hpp"
1286
1287 // Adjust methods to recover missing data. They need addresses for
1288 // interpreter entry points and their default native method address
1289 // must be reset.
1290
1291 // Updating methods must be done under a lock so multiple
1292 // threads don't update these in parallel
1293 //
1294 // Shared classes are all currently loaded by either the bootstrap or
1295 // internal parallel class loaders, so this will never cause a deadlock
1296 // on a custom class loader lock.
1297
1298 ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader());
1299 {
1300 Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
1301 check_loader_lock_contention(lockObject, THREAD);
1302 ObjectLocker ol(lockObject, THREAD, true);
1303 ik->restore_unshareable_info(loader_data, protection_domain, CHECK_(nh));
1304 }
1305
1306 if (log_is_enabled(Info, classload)) {
1307 ik()->print_loading_log(LogLevel::Info, loader_data, NULL);
1308 }
1309 if (log_is_enabled(Debug, classload)) {
1310 ik()->print_loading_log(LogLevel::Debug, loader_data, NULL);
1311 }
1312
1313 if (DumpLoadedClassList != NULL && classlist_file->is_open()) {
1314 // Only dump the classes that can be stored into CDS archive
1315 if (SystemDictionaryShared::is_sharing_possible(loader_data)) {
1316 ResourceMark rm(THREAD);
1317 classlist_file->print_cr("%s", ik->name()->as_C_string());
1318 classlist_file->flush();
1319 }
1320 }
1321
1322 // notify a class loaded from shared object
1323 ClassLoadingService::notify_class_loaded(ik(), true /* shared class */);
1324 }
1325 return ik;
1326 }
1327 #endif // INCLUDE_CDS
1328
1329 instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) {
1330 instanceKlassHandle nh = instanceKlassHandle(); // null Handle
|