Path: blob/master/src/hotspot/share/cds/classListWriter.hpp
41144 views
/*1* Copyright (c) 2020, 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_CDS_CLASSLISTWRITER_HPP25#define SHARE_CDS_CLASSLISTWRITER_HPP2627#include "runtime/mutexLocker.hpp"28#include "runtime/thread.hpp"29#include "utilities/ostream.hpp"3031class ClassListWriter {32friend const char* make_log_name(const char* log_name, const char* force_directory);3334static fileStream* _classlist_file;35MutexLocker _locker;36public:37#if INCLUDE_CDS38ClassListWriter() : _locker(Thread::current(), ClassListFile_lock, Mutex::_no_safepoint_check_flag) {}39#else40ClassListWriter() : _locker(Thread::current(), NULL, Mutex::_no_safepoint_check_flag) {}41#endif4243outputStream* stream() {44return _classlist_file;45}4647static bool is_enabled() {48#if INCLUDE_CDS49return _classlist_file != NULL && _classlist_file->is_open();50#else51return false;52#endif53}5455static void init() {56#if INCLUDE_CDS57// For -XX:DumpLoadedClassList=<file> option58if (DumpLoadedClassList != NULL) {59const char* list_name = make_log_name(DumpLoadedClassList, NULL);60_classlist_file = new(ResourceObj::C_HEAP, mtInternal)61fileStream(list_name);62_classlist_file->print_cr("# NOTE: Do not modify this file.");63_classlist_file->print_cr("#");64_classlist_file->print_cr("# This file is generated via the -XX:DumpLoadedClassList=<class_list_file> option");65_classlist_file->print_cr("# and is used at CDS archive dump time (see -Xshare:dump).");66_classlist_file->print_cr("#");67FREE_C_HEAP_ARRAY(char, list_name);68}69#endif70}7172static void delete_classlist() {73#if INCLUDE_CDS74if (_classlist_file != NULL) {75delete _classlist_file;76}77#endif78}79};8081#endif // SHARE_CDS_CLASSLISTWRITER_HPP828384