Path: blob/master/src/hotspot/share/classfile/classLoader.inline.hpp
40949 views
/*1* Copyright (c) 2018, 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_CLASSLOADER_INLINE_HPP25#define SHARE_CLASSFILE_CLASSLOADER_INLINE_HPP2627#include "classfile/classLoader.hpp"2829#include "runtime/atomic.hpp"30#include "runtime/arguments.hpp"3132// Next entry in class path33inline ClassPathEntry* ClassPathEntry::next() const { return Atomic::load_acquire(&_next); }3435inline void ClassPathEntry::set_next(ClassPathEntry* next) {36// may have unlocked readers, so ensure visibility.37Atomic::release_store(&_next, next);38}3940inline ClassPathEntry* ClassLoader::classpath_entry(int n) {41assert(n >= 0, "sanity");42if (n == 0) {43assert(has_jrt_entry(), "No class path entry at 0 for exploded module builds");44return ClassLoader::_jrt_entry;45} else {46// The java runtime image is always the first entry47// in the FileMapInfo::_classpath_entry_table. Even though48// the _jrt_entry is not included in the _first_append_entry49// linked list, it must be accounted for when comparing the50// class path vs. the shared archive class path.51ClassPathEntry* e = first_append_entry();52while (--n >= 1) {53assert(e != NULL, "Not that many classpath entries.");54e = e->next();55}56return e;57}58}5960inline void ClassLoader::load_zip_library_if_needed() {61if (Atomic::load_acquire(&_libzip_loaded) == 0) {62release_load_zip_library();63}64}6566#if INCLUDE_CDS6768// Helper function used by CDS code to get the number of boot classpath69// entries during shared classpath setup time.7071inline int ClassLoader::num_boot_classpath_entries() {72Arguments::assert_is_dumping_archive();73assert(has_jrt_entry(), "must have a java runtime image");74int num_entries = 1; // count the runtime image75ClassPathEntry* e = first_append_entry();76while (e != NULL) {77num_entries ++;78e = e->next();79}80return num_entries;81}8283inline ClassPathEntry* ClassLoader::get_next_boot_classpath_entry(ClassPathEntry* e) {84if (e == ClassLoader::_jrt_entry) {85return first_append_entry();86} else {87return e->next();88}89}9091// Helper function used by CDS code to get the number of app classpath92// entries during shared classpath setup time.93inline int ClassLoader::num_app_classpath_entries() {94Arguments::assert_is_dumping_archive();95int num_entries = 0;96ClassPathEntry* e= ClassLoader::_app_classpath_entries;97while (e != NULL) {98num_entries ++;99e = e->next();100}101return num_entries;102}103104#endif // INCLUDE_CDS105106#endif // SHARE_CLASSFILE_CLASSLOADER_INLINE_HPP107108109