1 /*
2 * Copyright (c) 2014, 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 *
46
47 static char* get_class_path_attr(const char* jar_path, char* manifest, jint manifest_size);
48 static void setup_app_search_path(JavaThread* current); // Only when -Xshare:dump
49 static void process_module_table(JavaThread* current, ModuleEntryTable* met);
50 // index of first app JAR in shared classpath entry table
51 static jshort _app_class_paths_start_index;
52 // index of first modular JAR in shared modulepath entry table
53 static jshort _app_module_paths_start_index;
54 // the largest path index being used during CDS dump time
55 static jshort _max_used_path_index;
56 // number of module paths
57 static int _num_module_paths;
58
59 static bool _has_app_classes;
60 static bool _has_platform_classes;
61 static bool _has_non_jar_in_classpath;
62
63 static char* read_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size, bool clean_text);
64 static bool has_jar_suffix(const char* filename);
65
66 public:
67 static void process_jar_manifest(JavaThread* current, ClassPathEntry* entry);
68
69 // Called by JVMTI code to add boot classpath
70 static void append_boot_classpath(ClassPathEntry* new_entry);
71
72 static void setup_search_paths(JavaThread* current);
73 static void setup_module_paths(JavaThread* current);
74 static void extract_jar_files_from_path(const char* path, GrowableArray<const char*>* module_paths);
75 static int compare_module_path_by_name(const char** p1, const char** p2);
76
77 static char* read_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size) {
78 // Remove all the new-line continuations (which wrap long lines at 72 characters, see
79 // http://docs.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Manifest), so
80 // that the manifest is easier to parse.
81 return read_manifest(current, entry, manifest_size, true);
82 }
83 static char* read_raw_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size) {
84 // Do not remove new-line continuations, so we can easily pass it as an argument to
85 // java.util.jar.Manifest.getManifest() at run-time.
115 }
116
117 static bool has_platform_or_app_classes() {
118 return _has_app_classes || _has_platform_classes;
119 }
120
121 static bool has_non_jar_in_classpath() {
122 return _has_non_jar_in_classpath;
123 }
124
125 static void record_result(const s2 classpath_index, InstanceKlass* result, bool redefined);
126 static void set_has_app_classes() {
127 _has_app_classes = true;
128 }
129 static void set_has_platform_classes() {
130 _has_platform_classes = true;
131 }
132 static void set_has_non_jar_in_classpath() {
133 _has_non_jar_in_classpath = true;
134 }
135 #endif // INCLUDE_CDS
136 };
137
138 #endif // SHARE_CLASSFILE_CLASSLOADEREXT_HPP
|
1 /*
2 * Copyright (c) 2014, 2023, 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 *
46
47 static char* get_class_path_attr(const char* jar_path, char* manifest, jint manifest_size);
48 static void setup_app_search_path(JavaThread* current); // Only when -Xshare:dump
49 static void process_module_table(JavaThread* current, ModuleEntryTable* met);
50 // index of first app JAR in shared classpath entry table
51 static jshort _app_class_paths_start_index;
52 // index of first modular JAR in shared modulepath entry table
53 static jshort _app_module_paths_start_index;
54 // the largest path index being used during CDS dump time
55 static jshort _max_used_path_index;
56 // number of module paths
57 static int _num_module_paths;
58
59 static bool _has_app_classes;
60 static bool _has_platform_classes;
61 static bool _has_non_jar_in_classpath;
62
63 static char* read_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size, bool clean_text);
64 static bool has_jar_suffix(const char* filename);
65
66 // All classes whose path_index is within
67 // [_app_class_exclusion_start_path_index ... _app_module_paths_start_index)
68 // are excluded from the archive. See -XX:CacheOnlyClassesIn.
69 static int _app_class_exclusion_start_path_index;
70
71 static ClassPathEntry* get_class_path_entry(s2 classpath_index);
72 static void check_invalid_classpath_index(s2 classpath_index, InstanceKlass* ik);
73 public:
74 static void process_jar_manifest(JavaThread* current, ClassPathEntry* entry);
75
76 // Called by JVMTI code to add boot classpath
77 static void append_boot_classpath(ClassPathEntry* new_entry);
78
79 static void setup_search_paths(JavaThread* current);
80 static void setup_module_paths(JavaThread* current);
81 static void extract_jar_files_from_path(const char* path, GrowableArray<const char*>* module_paths);
82 static int compare_module_path_by_name(const char** p1, const char** p2);
83
84 static char* read_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size) {
85 // Remove all the new-line continuations (which wrap long lines at 72 characters, see
86 // http://docs.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Manifest), so
87 // that the manifest is easier to parse.
88 return read_manifest(current, entry, manifest_size, true);
89 }
90 static char* read_raw_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size) {
91 // Do not remove new-line continuations, so we can easily pass it as an argument to
92 // java.util.jar.Manifest.getManifest() at run-time.
122 }
123
124 static bool has_platform_or_app_classes() {
125 return _has_app_classes || _has_platform_classes;
126 }
127
128 static bool has_non_jar_in_classpath() {
129 return _has_non_jar_in_classpath;
130 }
131
132 static void record_result(const s2 classpath_index, InstanceKlass* result, bool redefined);
133 static void set_has_app_classes() {
134 _has_app_classes = true;
135 }
136 static void set_has_platform_classes() {
137 _has_platform_classes = true;
138 }
139 static void set_has_non_jar_in_classpath() {
140 _has_non_jar_in_classpath = true;
141 }
142
143 // -XX:CacheOnlyClassesIn=
144 static bool should_be_excluded(InstanceKlass* k);
145 static void set_app_class_exclusion_start_path_index(int i) {
146 _app_class_exclusion_start_path_index = i;
147 }
148
149 #endif // INCLUDE_CDS
150 };
151
152 #endif // SHARE_CLASSFILE_CLASSLOADEREXT_HPP
|