Path: blob/master/src/hotspot/share/classfile/classLoaderExt.hpp
40949 views
/*1* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_CLASSFILE_CLASSLOADEREXT_HPP25#define SHARE_CLASSFILE_CLASSLOADEREXT_HPP2627#include "classfile/classLoader.hpp"28#include "classfile/moduleEntry.hpp"29#include "utilities/macros.hpp"3031class ClassListParser;3233class ClassLoaderExt: public ClassLoader { // AllStatic34public:35static bool should_verify(int classpath_index) {36CDS_ONLY(return (classpath_index >= _app_class_paths_start_index);)37NOT_CDS(return false;)38}3940#if INCLUDE_CDS41private:42enum SomeConstants {43max_classpath_index = 0x7fff44};4546static char* get_class_path_attr(const char* jar_path, char* manifest, jint manifest_size);47static void setup_app_search_path(JavaThread* current); // Only when -Xshare:dump48static void process_module_table(JavaThread* current, ModuleEntryTable* met);49// index of first app JAR in shared classpath entry table50static jshort _app_class_paths_start_index;51// index of first modular JAR in shared modulepath entry table52static jshort _app_module_paths_start_index;53// the largest path index being used during CDS dump time54static jshort _max_used_path_index;5556static bool _has_app_classes;57static bool _has_platform_classes;5859static char* read_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size, bool clean_text);60static ClassPathEntry* find_classpath_entry_from_cache(JavaThread* current, const char* path);6162public:63static void process_jar_manifest(JavaThread* current, ClassPathEntry* entry, bool check_for_duplicates);6465// Called by JVMTI code to add boot classpath66static void append_boot_classpath(ClassPathEntry* new_entry);6768static void setup_search_paths(JavaThread* current);69static void setup_module_paths(JavaThread* current);7071static char* read_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size) {72// Remove all the new-line continuations (which wrap long lines at 72 characters, see73// http://docs.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Manifest), so74// that the manifest is easier to parse.75return read_manifest(current, entry, manifest_size, true);76}77static char* read_raw_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size) {78// Do not remove new-line continuations, so we can easily pass it as an argument to79// java.util.jar.Manifest.getManifest() at run-time.80return read_manifest(current, entry, manifest_size, false);81}8283static jshort app_class_paths_start_index() { return _app_class_paths_start_index; }8485static jshort app_module_paths_start_index() { return _app_module_paths_start_index; }8687static jshort max_used_path_index() { return _max_used_path_index; }8889static void set_max_used_path_index(jshort used_index) {90_max_used_path_index = used_index;91}9293static void init_paths_start_index(jshort app_start) {94_app_class_paths_start_index = app_start;95}9697static void init_app_module_paths_start_index(jshort module_start) {98_app_module_paths_start_index = module_start;99}100101static bool is_boot_classpath(int classpath_index) {102return classpath_index < _app_class_paths_start_index;103}104105static bool has_platform_or_app_classes() {106return _has_app_classes || _has_platform_classes;107}108109static void record_result(const s2 classpath_index, InstanceKlass* result);110static InstanceKlass* load_class(Symbol* h_name, const char* path, TRAPS);111static void set_has_app_classes() {112_has_app_classes = true;113}114static void set_has_platform_classes() {115_has_platform_classes = true;116}117#endif118};119120#endif // SHARE_CLASSFILE_CLASSLOADEREXT_HPP121122123