/* * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
virtualbool is_modules_image() const { returnfalse; } virtualbool is_jar_file() const { returnfalse; } // Is this entry created from the "Class-path" attribute from a JAR Manifest? virtualbool from_class_path_attr() const { returnfalse; } virtualconstchar* name() const = 0; virtual JImageFile* jimage() const { return NULL; } virtualvoid close_jimage() {} // Constructor
ClassPathEntry() : _next(NULL) {} // Attempt to locate file_name through this class path entry. // Returns a class file parsing stream if successful. virtual ClassFileStream* open_stream(JavaThread* current, constchar* name) = 0; // Open the stream for a specific class loader virtual ClassFileStream* open_stream_for_loader(JavaThread* current, constchar* name, ClassLoaderData* loader_data) { return open_stream(current, name);
}
};
class ClassPathDirEntry: public ClassPathEntry { private: constchar* _dir; // Name of directory public: constchar* name() const { return _dir; }
ClassPathDirEntry(constchar* dir) {
_dir = copy_path(dir);
} virtual ~ClassPathDirEntry();
ClassFileStream* open_stream(JavaThread* current, constchar* name);
};
// Type definitions for zip file and zip file entry typedefvoid* jzfile; typedefstruct { char *name; /* entry name */
jlong time; /* modification time */
jlong size; /* size of uncompressed data */
jlong csize; /* size of compressed data (zero if uncompressed) */
jint crc; /* crc of uncompressed data */ char *comment; /* optional zip file comment */
jbyte *extra; /* optional extra data */
jlong pos; /* position of LOC header (if negative) or data */
} jzentry;
class ClassPathZipEntry: public ClassPathEntry { private:
jzfile* _zip; // The zip archive constchar* _zip_name; // Name of zip archive bool _from_class_path_attr; // From the "Class-path" attribute of a jar file public: bool is_jar_file() const { returntrue; } bool from_class_path_attr() const { return _from_class_path_attr; } constchar* name() const { return _zip_name; }
ClassPathZipEntry(jzfile* zip, constchar* zip_name, bool is_boot_append, bool from_class_path_attr); virtual ~ClassPathZipEntry();
u1* open_entry(JavaThread* current, constchar* name, jint* filesize, bool nul_terminate);
ClassFileStream* open_stream(JavaThread* current, constchar* name);
};
// ModuleClassPathList contains a linked list of ClassPathEntry's // that have been specified for a specific module. Currently, // the only way to specify a module/path pair is via the --patch-module // command line option. class ModuleClassPathList : public CHeapObj<mtClass> { private:
Symbol* _module_name; // First and last entries of class path entries for a specific module
ClassPathEntry* _module_first_entry;
ClassPathEntry* _module_last_entry; public:
Symbol* module_name() const { return _module_name; }
ClassPathEntry* module_first_entry() const { return _module_first_entry; }
ModuleClassPathList(Symbol* module_name);
~ModuleClassPathList(); void add_to_list(ClassPathEntry* new_entry);
};
// The boot class path consists of 3 ordered pieces: // 1. the module/path pairs specified to --patch-module // --patch-module=<module>=<file>(<pathsep><file>)* // 2. the base piece // [jimage | build with exploded modules] // 3. boot loader append path // [-Xbootclasspath/a]; [jvmti appended entries] // // The boot loader must obey this order when attempting // to load a class.
// 1. Contains the module/path pairs specified to --patch-module static GrowableArray<ModuleClassPathList*>* _patch_mod_entries;
// 2. the base piece // Contains the ClassPathEntry of the modular java runtime image. // If no java runtime image is present, this indicates a // build with exploded modules is being used instead. static ClassPathEntry* _jrt_entry; static GrowableArray<ModuleClassPathList*>* _exploded_entries; enum { EXPLODED_ENTRY_SIZE = 80 }; // Initial number of exploded modules
// 3. the boot loader's append path // [-Xbootclasspath/a]; [jvmti appended entries] // Note: boot loader append path does not support named modules. static ClassPathEntry* volatile _first_append_entry_list; static ClassPathEntry* first_append_entry() { return Atomic::load_acquire(&_first_append_entry_list);
}
// Last entry in linked list of appended ClassPathEntry instances static ClassPathEntry* volatile _last_append_entry;
// Record how many calls to Unsafe_DefineClass static PerfCounter* unsafe_defineClassCallCounter() { return _unsafe_defineClassCallCounter;
}
// Modular java runtime image is present vs. a build with exploded modules staticbool has_jrt_entry() { return (_jrt_entry != NULL); } static ClassPathEntry* get_jrt_entry() { return _jrt_entry; } staticvoid close_jrt_image();
// Add a module's exploded directory to the boot loader's exploded module build list staticvoid add_to_exploded_build_list(JavaThread* current, Symbol* module_name);
// Attempt load of individual class from either the patched or exploded modules build lists static ClassFileStream* search_module_entries(JavaThread* current, const GrowableArray<ModuleClassPathList*>* const module_list, constchar* const class_name, constchar* const file_name);
// If the specified package has been loaded by the system, then returns // the name of the directory or ZIP file that the package was loaded from. // Returns null if the package was not loaded. // Note: The specified name can either be the name of a class or package. // If a package name is specified, then it must be "/"-separator and also // end with a trailing "/". static oop get_system_package(constchar* name, TRAPS);
// Returns an array of Java strings representing all of the currently // loaded system packages. // Note: The package names returned are "/"-separated and end with a // trailing "/". static objArrayOop get_system_packages(TRAPS);
// Helper function used by CDS code to get the number of boot classpath // entries during shared classpath setup time. staticint num_boot_classpath_entries();
// Helper function used by CDS code to get the number of app classpath // entries during shared classpath setup time. staticint num_app_classpath_entries();
// Helper function used by CDS code to get the number of module path // entries during shared classpath setup time. staticint num_module_path_entries(); staticvoid exit_with_path_failure(constchar* error, constchar* message); staticchar* skip_uri_protocol(char* source); staticvoid record_result(JavaThread* current, InstanceKlass* ik, const ClassFileStream* stream, bool redefined); #endif
staticchar* lookup_vm_options();
// Determines if the named module is present in the // modules jimage file or in the exploded modules directory. staticbool is_module_observable(constchar* module_name);
staticvoid trace_class_path(constchar* msg, constchar* name = NULL);
// VM monitoring and management support static jlong classloader_time_ms(); static jlong class_method_total_size(); static jlong class_init_count(); static jlong class_init_time_ms(); static jlong class_verify_time_ms(); static jlong class_link_count(); static jlong class_link_time_ms();
// adds a class path to the boot append entries staticvoid add_to_boot_append_entries(ClassPathEntry* new_entry);
// creates a class path zip entry (returns NULL if JAR file cannot be opened) static ClassPathZipEntry* create_class_path_zip_entry(constchar *apath, bool is_boot_append);
// Extract package name from a fully qualified class name // *bad_class_name is set to true if there's a problem with parsing class_name, to // distinguish from a class_name with no package name, as both cases have a NULL return value static Symbol* package_from_class_name(const Symbol* class_name, bool* bad_class_name = NULL);
// PerfClassTraceTime is used to measure time for class loading related events. // This class tracks cumulative time and exclusive time for specific event types. // During the execution of one event, other event types (e.g. class loading and // resolution) as well as recursive calls of the same event type could happen. // Only one elapsed timer (cumulative) and one thread-local self timer (exclusive) // (i.e. only one event type) are active at a time even multiple PerfClassTraceTime // instances have been created as multiple events are happening. class PerfClassTraceTime { public: enum {
CLASS_LOAD = 0,
CLASS_LINK = 1,
CLASS_VERIFY = 2,
CLASS_CLINIT = 3,
DEFINE_CLASS = 4,
EVENT_TYPE_COUNT = 5
}; protected: // _t tracks time from initialization to destruction of this timer instance // including time for all other event types, and recursive calls of this type. // When a timer is called recursively, the elapsedTimer _t would not be used.
elapsedTimer _t;
PerfLongCounter* _timep;
PerfLongCounter* _selftimep;
PerfLongCounter* _eventp; // pointer to thread-local recursion counter and timer array // The thread_local timers track cumulative time for specific event types // exclusive of time for other event types, but including recursive calls // of the same type. int* _recursion_counters;
elapsedTimer* _timers; int _event_type; int _prev_active_event;
public:
inline PerfClassTraceTime(PerfLongCounter* timep, /* counter incremented with inclusive time */
PerfLongCounter* selftimep, /* counter incremented with exclusive time */
PerfLongCounter* eventp, /* event counter */ int* recursion_counters, /* thread-local recursion counter array */
elapsedTimer* timers, /* thread-local timer array */ int type /* event type */ ) :
_timep(timep), _selftimep(selftimep), _eventp(eventp), _recursion_counters(recursion_counters), _timers(timers), _event_type(type) {
initialize();
}
inline PerfClassTraceTime(PerfLongCounter* timep, /* counter incremented with inclusive time */
elapsedTimer* timers, /* thread-local timer array */ int type /* event type */ ) :
_timep(timep), _selftimep(NULL), _eventp(NULL), _recursion_counters(NULL), _timers(timers), _event_type(type) {
initialize();
}
~PerfClassTraceTime(); void initialize();
};
#endif// SHARE_CLASSFILE_CLASSLOADER_HPP
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.