/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*
*/
#include "classfile/classFileParser.hpp"
#include "runtime/perfData.hpp"
// The VM class loader.
// Meta-index (optional, to be able to skip opening boot classpath jar files)
private:
char** _meta_package_names;
public:
~MetaIndex();
bool may_contain(const char* class_name);
};
// Class path entry (directory or zip file)
private:
public:
// Next entry in class path
// may have unlocked readers, so write atomically.
}
virtual bool is_jar_file() = 0;
virtual const char* name() = 0;
virtual bool is_lazy();
// Constructor
// Attempt to locate file_name through this class path entry.
// Returns a class file parsing stream if successfull.
// Debugging
NOT_PRODUCT(virtual bool is_rt_jar() = 0;)
};
private:
public:
bool is_jar_file() { return false; }
ClassPathDirEntry(char* dir);
// Debugging
NOT_PRODUCT(bool is_rt_jar();)
};
// Type definitions for zip file and zip file entry
typedef void* jzfile;
typedef struct {
} jzentry;
private:
public:
bool is_jar_file() { return true; }
// Debugging
NOT_PRODUCT(bool is_rt_jar();)
NOT_PRODUCT(bool is_rt_jar12();)
NOT_PRODUCT(bool is_rt_jar13();)
};
// For lazier loading of boot class path entries
private:
public:
bool is_jar_file();
virtual bool is_lazy();
// Debugging
NOT_PRODUCT(bool is_rt_jar();)
};
class PackageHashtable;
class PackageInfo;
template <MEMFLAGS F> class HashtableBucket;
public:
enum SomeConstants {
};
private:
friend class LazyClassPathEntry;
// Performance counters
// First entry in linked list of ClassPathEntry instances
// Last entry in linked list of ClassPathEntry instances
// Hash table used to keep track of loaded packages
static const char* _shared_archive;
// Hash function
static unsigned int hash(const char *s, int n);
// Returns the package file name corresponding to the specified package
// or class name, or null if not found.
// Adds a new package entry for the specified class or package name and
// corresponding directory or jar file name.
// Initialization
static void setup_meta_index();
static void setup_bootstrap_search_path();
static void load_zip_library();
static void create_class_path_entry(char *path, struct stat st, ClassPathEntry **new_entry, bool lazy);
// Canonicalizes path names, so strcmp will work properly. This is mainly
// to avoid confusing the zip library
public:
// Used by the kernel jvm.
static void update_class_path_entry_list(const char *path,
bool check_for_duplicates);
static void print_bootclasspath();
// Timing
// Record how often system loader lock object is contended
}
// Record how often non system loader lock object is contended
}
// Record how many calls to JVM_FindLoadedClass w/o holding a lock
}
// Record how many calls to JVM_DefineClass w/o holding a lock
}
// Record how many calls to jni_DefineClass w/o holding a lock
}
// Record how many calls to Unsafe_DefineClass
return _unsafe_defineClassCallCounter;
}
// Record how many times SystemDictionary::load_instance_class call
// fails with linkageError when Unsyncloadclass flag is set.
return _load_instance_class_failCounter;
}
// Load individual .class file
// 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 "/".
// 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 "/".
// Initialization
static void initialize();
static void create_package_info_table();
int number_of_entries);
static int compute_Object_vtable();
while (--n >= 0) {
e = e->next();
}
return e;
}
// Sharing dump and restore
// 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();
// indicates if class path already contains a entry (exact match by name)
// adds a class path list
// creates a class path zip entry (returns NULL if JAR file cannot be opened)
// Debugging
// Force compilation of all methods in all classes in bootstrap class path (stress test)
#ifndef PRODUCT
private:
static int _compile_the_world_counter;
public:
static void compile_the_world();
#endif //PRODUCT
};
// 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,
};
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.
// 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;
int _event_type;
int _prev_active_event;
public:
int* recursion_counters, /* thread-local recursion counter array */
int type /* event type */ ) :
_timep(timep), _selftimep(selftimep), _eventp(eventp), _recursion_counters(recursion_counters), _timers(timers), _event_type(type) {
initialize();
}
int type /* event type */ ) :
_timep(timep), _selftimep(NULL), _eventp(NULL), _recursion_counters(NULL), _timers(timers), _event_type(type) {
initialize();
}
void initialize();
};
#endif // SHARE_VM_CLASSFILE_CLASSLOADER_HPP