Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/classfile/classLoader.inline.hpp
40949 views
1
/*
2
* Copyright (c) 2018, 2021, 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_CLASSFILE_CLASSLOADER_INLINE_HPP
26
#define SHARE_CLASSFILE_CLASSLOADER_INLINE_HPP
27
28
#include "classfile/classLoader.hpp"
29
30
#include "runtime/atomic.hpp"
31
#include "runtime/arguments.hpp"
32
33
// Next entry in class path
34
inline ClassPathEntry* ClassPathEntry::next() const { return Atomic::load_acquire(&_next); }
35
36
inline void ClassPathEntry::set_next(ClassPathEntry* next) {
37
// may have unlocked readers, so ensure visibility.
38
Atomic::release_store(&_next, next);
39
}
40
41
inline ClassPathEntry* ClassLoader::classpath_entry(int n) {
42
assert(n >= 0, "sanity");
43
if (n == 0) {
44
assert(has_jrt_entry(), "No class path entry at 0 for exploded module builds");
45
return ClassLoader::_jrt_entry;
46
} else {
47
// The java runtime image is always the first entry
48
// in the FileMapInfo::_classpath_entry_table. Even though
49
// the _jrt_entry is not included in the _first_append_entry
50
// linked list, it must be accounted for when comparing the
51
// class path vs. the shared archive class path.
52
ClassPathEntry* e = first_append_entry();
53
while (--n >= 1) {
54
assert(e != NULL, "Not that many classpath entries.");
55
e = e->next();
56
}
57
return e;
58
}
59
}
60
61
inline void ClassLoader::load_zip_library_if_needed() {
62
if (Atomic::load_acquire(&_libzip_loaded) == 0) {
63
release_load_zip_library();
64
}
65
}
66
67
#if INCLUDE_CDS
68
69
// Helper function used by CDS code to get the number of boot classpath
70
// entries during shared classpath setup time.
71
72
inline int ClassLoader::num_boot_classpath_entries() {
73
Arguments::assert_is_dumping_archive();
74
assert(has_jrt_entry(), "must have a java runtime image");
75
int num_entries = 1; // count the runtime image
76
ClassPathEntry* e = first_append_entry();
77
while (e != NULL) {
78
num_entries ++;
79
e = e->next();
80
}
81
return num_entries;
82
}
83
84
inline ClassPathEntry* ClassLoader::get_next_boot_classpath_entry(ClassPathEntry* e) {
85
if (e == ClassLoader::_jrt_entry) {
86
return first_append_entry();
87
} else {
88
return e->next();
89
}
90
}
91
92
// Helper function used by CDS code to get the number of app classpath
93
// entries during shared classpath setup time.
94
inline int ClassLoader::num_app_classpath_entries() {
95
Arguments::assert_is_dumping_archive();
96
int num_entries = 0;
97
ClassPathEntry* e= ClassLoader::_app_classpath_entries;
98
while (e != NULL) {
99
num_entries ++;
100
e = e->next();
101
}
102
return num_entries;
103
}
104
105
#endif // INCLUDE_CDS
106
107
#endif // SHARE_CLASSFILE_CLASSLOADER_INLINE_HPP
108
109