提交 110eb26d 编写于 作者: H hseigel

8031819: Remove legacy jdk checks and code

Summary: Delete old jdk specific code.
Reviewed-by: dholmes, coleenp, zgu, lfoltan
上级 3c014836
......@@ -4667,9 +4667,7 @@ bool ClassFileParser::has_illegal_visibility(jint flags) {
}
bool ClassFileParser::is_supported_version(u2 major, u2 minor) {
u2 max_version =
JDK_Version::is_gte_jdk17x_version() ? JAVA_MAX_SUPPORTED_VERSION :
(JDK_Version::is_gte_jdk16x_version() ? JAVA_6_VERSION : JAVA_1_5_VERSION);
u2 max_version = JAVA_MAX_SUPPORTED_VERSION;
return (major >= JAVA_MIN_SUPPORTED_VERSION) &&
(major <= max_version) &&
((major != max_version) ||
......
......@@ -1126,7 +1126,7 @@ void ClassLoader::verify() {
// JDK 1.3 version
typedef struct real_jzentry13 { /* Zip file entry */
typedef struct real_jzentry { /* Zip file entry */
char *name; /* entry name */
jint time; /* modification time */
jint size; /* size of uncompressed data */
......@@ -1135,9 +1135,9 @@ typedef struct real_jzentry13 { /* Zip file entry */
char *comment; /* optional zip file comment */
jbyte *extra; /* optional extra data */
jint pos; /* position of LOC header (if negative) or data */
} real_jzentry13;
} real_jzentry;
typedef struct real_jzfile13 { /* Zip file */
typedef struct real_jzfile { /* Zip file */
char *name; /* zip file name */
jint refs; /* number of active references */
jint fd; /* open file descriptor */
......@@ -1148,42 +1148,14 @@ typedef struct real_jzfile13 { /* Zip file */
jint total; /* total number of entries */
unsigned short *table; /* Hash chain heads: indexes into entries */
jint tablelen; /* number of hash eads */
real_jzfile13 *next; /* next zip file in search list */
real_jzfile *next; /* next zip file in search list */
jzentry *cache; /* we cache the most recently freed jzentry */
/* Information on metadata names in META-INF directory */
char **metanames; /* array of meta names (may have null names) */
jint metacount; /* number of slots in metanames array */
/* If there are any per-entry comments, they are in the comments array */
char **comments;
} real_jzfile13;
// JDK 1.2 version
typedef struct real_jzentry12 { /* Zip file entry */
char *name; /* entry name */
jint time; /* modification time */
jint size; /* size of uncompressed data */
jint 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 */
jint pos; /* position of LOC header (if negative) or data */
struct real_jzentry12 *next; /* next entry in hash table */
} real_jzentry12;
typedef struct real_jzfile12 { /* Zip file */
char *name; /* zip file name */
jint refs; /* number of active references */
jint fd; /* open file descriptor */
void *lock; /* read lock */
char *comment; /* zip file comment */
char *msg; /* zip error message */
real_jzentry12 *entries; /* array of zip entries */
jint total; /* total number of entries */
real_jzentry12 **table; /* hash table of entries */
jint tablelen; /* number of buckets */
jzfile *next; /* next zip file in search list */
} real_jzfile12;
} real_jzfile;
void ClassPathDirEntry::compile_the_world(Handle loader, TRAPS) {
// For now we only compile all methods in all classes in zip/jar files
......@@ -1197,10 +1169,14 @@ bool ClassPathDirEntry::is_rt_jar() {
}
void ClassPathZipEntry::compile_the_world(Handle loader, TRAPS) {
if (JDK_Version::is_jdk12x_version()) {
compile_the_world12(loader, THREAD);
} else {
compile_the_world13(loader, THREAD);
real_jzfile* zip = (real_jzfile*) _zip;
tty->print_cr("CompileTheWorld : Compiling all classes in %s", zip->name);
tty->cr();
// Iterate over all entries in zip file
for (int n = 0; ; n++) {
real_jzentry * ze = (real_jzentry *)((*GetNextEntry)(_zip, n));
if (ze == NULL) break;
ClassLoader::compile_the_world_in(ze->name, loader, CHECK);
}
if (HAS_PENDING_EXCEPTION) {
if (PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())) {
......@@ -1213,54 +1189,8 @@ void ClassPathZipEntry::compile_the_world(Handle loader, TRAPS) {
}
}
// Version that works for JDK 1.3.x
void ClassPathZipEntry::compile_the_world13(Handle loader, TRAPS) {
real_jzfile13* zip = (real_jzfile13*) _zip;
tty->print_cr("CompileTheWorld : Compiling all classes in %s", zip->name);
tty->cr();
// Iterate over all entries in zip file
for (int n = 0; ; n++) {
real_jzentry13 * ze = (real_jzentry13 *)((*GetNextEntry)(_zip, n));
if (ze == NULL) break;
ClassLoader::compile_the_world_in(ze->name, loader, CHECK);
}
}
// Version that works for JDK 1.2.x
void ClassPathZipEntry::compile_the_world12(Handle loader, TRAPS) {
real_jzfile12* zip = (real_jzfile12*) _zip;
tty->print_cr("CompileTheWorld : Compiling all classes in %s", zip->name);
tty->cr();
// Iterate over all entries in zip file
for (int n = 0; ; n++) {
real_jzentry12 * ze = (real_jzentry12 *)((*GetNextEntry)(_zip, n));
if (ze == NULL) break;
ClassLoader::compile_the_world_in(ze->name, loader, CHECK);
}
}
bool ClassPathZipEntry::is_rt_jar() {
if (JDK_Version::is_jdk12x_version()) {
return is_rt_jar12();
} else {
return is_rt_jar13();
}
}
// JDK 1.3 version
bool ClassPathZipEntry::is_rt_jar13() {
real_jzfile13* zip = (real_jzfile13*) _zip;
int len = (int)strlen(zip->name);
// Check whether zip name ends in "rt.jar"
// This will match other archives named rt.jar as well, but this is
// only used for debugging.
return (len >= 6) && (strcasecmp(zip->name + len - 6, "rt.jar") == 0);
}
// JDK 1.2 version
bool ClassPathZipEntry::is_rt_jar12() {
real_jzfile12* zip = (real_jzfile12*) _zip;
real_jzfile* zip = (real_jzfile*) _zip;
int len = (int)strlen(zip->name);
// Check whether zip name ends in "rt.jar"
// This will match other archives named rt.jar as well, but this is
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, 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
......@@ -111,11 +111,7 @@ class ClassPathZipEntry: public ClassPathEntry {
void contents_do(void f(const char* name, void* context), void* context);
// Debugging
NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
NOT_PRODUCT(void compile_the_world12(Handle loader, TRAPS);) // JDK 1.2 version
NOT_PRODUCT(void compile_the_world13(Handle loader, TRAPS);) // JDK 1.3 version
NOT_PRODUCT(bool is_rt_jar();)
NOT_PRODUCT(bool is_rt_jar12();)
NOT_PRODUCT(bool is_rt_jar13();)
};
......
......@@ -857,9 +857,7 @@ void java_lang_Class::compute_offsets() {
}
int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
if (!JDK_Version::is_gte_jdk15x_version()
|| classRedefinedCount_offset == -1) {
// The classRedefinedCount field is only present starting in 1.5.
if (classRedefinedCount_offset == -1) {
// If we don't have an offset for it then just return -1 as a marker.
return -1;
}
......@@ -868,9 +866,7 @@ int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
}
void java_lang_Class::set_classRedefinedCount(oop the_class_mirror, int value) {
if (!JDK_Version::is_gte_jdk15x_version()
|| classRedefinedCount_offset == -1) {
// The classRedefinedCount field is only present starting in 1.5.
if (classRedefinedCount_offset == -1) {
// If we don't have an offset for it then nothing to set.
return;
}
......@@ -1000,9 +996,7 @@ oop java_lang_Thread::inherited_access_control_context(oop java_thread) {
jlong java_lang_Thread::stackSize(oop java_thread) {
// The stackSize field is only present starting in 1.4
if (_stackSize_offset > 0) {
assert(JDK_Version::is_gte_jdk14x_version(), "sanity check");
return java_thread->long_field(_stackSize_offset);
} else {
return 0;
......@@ -1078,7 +1072,7 @@ bool java_lang_Thread::set_park_event(oop java_thread, jlong ptr) {
const char* java_lang_Thread::thread_status_name(oop java_thread) {
assert(JDK_Version::is_gte_jdk15x_version() && _thread_status_offset != 0, "Must have thread status");
assert(_thread_status_offset != 0, "Must have thread status");
ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
switch (status) {
case NEW : return "NEW";
......@@ -1217,7 +1211,6 @@ void java_lang_Throwable::set_stacktrace(oop throwable, oop st_element_array) {
}
void java_lang_Throwable::clear_stacktrace(oop throwable) {
assert(JDK_Version::is_gte_jdk14x_version(), "should only be called in >= 1.4");
set_stacktrace(throwable, NULL);
}
......@@ -1548,12 +1541,9 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, methodHandle met
// Start out by clearing the backtrace for this object, in case the VM
// runs out of memory while allocating the stack trace
set_backtrace(throwable(), NULL);
if (JDK_Version::is_gte_jdk14x_version()) {
// New since 1.4, clear lazily constructed Java level stacktrace if
// refilling occurs
// This is unnecessary in 1.7+ but harmless
clear_stacktrace(throwable());
}
// Clear lazily constructed Java level stacktrace if refilling occurs
// This is unnecessary in 1.7+ but harmless
clear_stacktrace(throwable());
int max_depth = MaxJavaStackTraceDepth;
JavaThread* thread = (JavaThread*)THREAD;
......@@ -1739,13 +1729,9 @@ void java_lang_Throwable::fill_in_stack_trace_of_preallocated_backtrace(Handle t
if (chunk_count >= max_chunks) break;
}
// For Java 7+ we support the Throwable immutability protocol defined for Java 7. This support
// was missing in 7u0 so in 7u0 there is a workaround in the Throwable class. That workaround
// can be removed in a JDK using this JVM version
if (JDK_Version::is_gte_jdk17x_version()) {
java_lang_Throwable::set_stacktrace(throwable(), java_lang_Throwable::unassigned_stacktrace());
assert(java_lang_Throwable::unassigned_stacktrace() != NULL, "not initialized");
}
// We support the Throwable immutability protocol defined for Java 7.
java_lang_Throwable::set_stacktrace(throwable(), java_lang_Throwable::unassigned_stacktrace());
assert(java_lang_Throwable::unassigned_stacktrace() != NULL, "not initialized");
}
......@@ -3022,8 +3008,7 @@ bool java_lang_ClassLoader::isAncestor(oop loader, oop cl) {
// based on non-null field
// Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it
bool java_lang_ClassLoader::parallelCapable(oop class_loader) {
if (!JDK_Version::is_gte_jdk17x_version()
|| parallelCapable_offset == -1) {
if (parallelCapable_offset == -1) {
// Default for backward compatibility is false
return false;
}
......@@ -3219,7 +3204,6 @@ void java_nio_Buffer::compute_offsets() {
void java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(TRAPS) {
if (_owner_offset != 0) return;
assert(JDK_Version::is_gte_jdk16x_version(), "Must be JDK 1.6 or later");
SystemDictionary::load_abstract_ownable_synchronizer_klass(CHECK);
Klass* k = SystemDictionary::abstract_ownable_synchronizer_klass();
compute_offset(_owner_offset, k,
......@@ -3309,15 +3293,10 @@ void JavaClasses::compute_offsets() {
java_lang_reflect_Method::compute_offsets();
java_lang_reflect_Constructor::compute_offsets();
java_lang_reflect_Field::compute_offsets();
if (JDK_Version::is_gte_jdk14x_version()) {
java_nio_Buffer::compute_offsets();
}
if (JDK_Version::is_gte_jdk15x_version()) {
sun_reflect_ConstantPool::compute_offsets();
sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets();
}
if (JDK_Version::is_gte_jdk18x_version())
java_lang_reflect_Parameter::compute_offsets();
java_nio_Buffer::compute_offsets();
sun_reflect_ConstantPool::compute_offsets();
sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets();
java_lang_reflect_Parameter::compute_offsets();
// generated interpreter code wants to know about the offsets we just computed:
AbstractAssembler::update_delayed_values();
......@@ -3502,7 +3481,7 @@ void JavaClasses::check_offsets() {
// into merlin "for some time." Without it, the vm will fail with early
// merlin builds.
if (CheckAssertionStatusDirectives && JDK_Version::is_gte_jdk14x_version()) {
if (CheckAssertionStatusDirectives) {
const char* nm = "java/lang/AssertionStatusDirectives";
const char* sig = "[Ljava/lang/String;";
CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classes, sig);
......
......@@ -1754,8 +1754,6 @@ void SystemDictionary::methods_do(void f(Method*)) {
// Lazily load klasses
void SystemDictionary::load_abstract_ownable_synchronizer_klass(TRAPS) {
assert(JDK_Version::is_gte_jdk16x_version(), "Must be JDK 1.6 or later");
// if multiple threads calling this function, only one thread will load
// the class. The other threads will find the loaded version once the
// class is loaded.
......
......@@ -139,14 +139,13 @@ class Ticks;
do_klass(reflect_Constructor_klass, java_lang_reflect_Constructor, Pre ) \
\
/* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \
/* Universe::is_gte_jdk14x_version() is not set up by this point. */ \
/* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
do_klass(reflect_MagicAccessorImpl_klass, sun_reflect_MagicAccessorImpl, Opt ) \
do_klass(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \
do_klass(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \
do_klass(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Pre ) \
do_klass(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Pre ) \
do_klass(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt ) \
do_klass(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15 ) \
do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15 ) \
do_klass(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt ) \
do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt ) \
do_klass(reflect_CallerSensitive_klass, sun_reflect_CallerSensitive, Opt ) \
\
/* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
......@@ -169,7 +168,6 @@ class Ticks;
\
/* It's NULL in non-1.4 JDKs. */ \
do_klass(StackTraceElement_klass, java_lang_StackTraceElement, Opt ) \
/* Universe::is_gte_jdk14x_version() is not set up by this point. */ \
/* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
do_klass(nio_Buffer_klass, java_nio_Buffer, Opt ) \
\
......@@ -209,10 +207,8 @@ class SystemDictionary : AllStatic {
// Options after this point will use resolve_or_null instead.
Opt, // preload tried; NULL if not present
Opt_Only_JDK14NewRef, // preload tried; use only with NewReflection
Opt_Only_JDK15, // preload tried; use only with JDK1.5+
OPTION_LIMIT,
CEIL_LG_OPTION_LIMIT = 4 // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT)
CEIL_LG_OPTION_LIMIT = 2 // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT)
};
......@@ -385,15 +381,6 @@ public:
static Klass* check_klass_Pre( Klass* k) { return check_klass(k); }
static Klass* check_klass_Opt( Klass* k) { return k; }
static Klass* check_klass_Opt_Only_JDK15(Klass* k) {
assert(JDK_Version::is_gte_jdk15x_version(), "JDK 1.5 only");
return k;
}
static Klass* check_klass_Opt_Only_JDK14NewRef(Klass* k) {
assert(JDK_Version::is_gte_jdk14x_version(), "JDK 1.4 only");
// despite the optional loading, if you use this it must be present:
return check_klass(k);
}
static bool initialize_wk_klass(WKID id, int init_opt, TRAPS);
static void initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS);
......
......@@ -320,7 +320,6 @@
template(reference_discovered_name, "discovered") \
template(run_finalization_name, "runFinalization") \
template(run_finalizers_on_exit_name, "runFinalizersOnExit") \
template(uncaughtException_name, "uncaughtException") \
template(dispatchUncaughtException_name, "dispatchUncaughtException") \
template(initializeSystemClass_name, "initializeSystemClass") \
template(loadClass_name, "loadClass") \
......
......@@ -945,12 +945,8 @@ void LinkResolver::linktime_resolve_special_method(methodHandle& resolved_method
Klass *klass_to_check = !InstanceKlass::cast(current_klass())->is_anonymous() ?
current_klass() :
InstanceKlass::cast(current_klass())->host_klass();
// As of the fix for 4486457 we disable verification for all of the
// dynamically-generated bytecodes associated with the 1.4
// reflection implementation, not just those associated with
// sun/reflect/SerializationConstructorAccessor.
bool is_reflect = JDK_Version::is_gte_jdk14x_version() &&
klass_to_check->is_subclass_of(
// Disable verification for the dynamically-generated reflection bytecodes.
bool is_reflect = klass_to_check->is_subclass_of(
SystemDictionary::reflect_MagicAccessorImpl_klass());
if (!is_reflect &&
......
......@@ -1000,9 +1000,6 @@ void universe2_init() {
}
// This function is defined in JVM.cpp
extern void initialize_converter_functions();
bool universe_post_init() {
assert(!is_init_completed(), "Error: initialization not yet completed!");
Universe::_fully_initialized = true;
......@@ -1144,11 +1141,6 @@ bool universe_post_init() {
SystemDictionary::ProtectionDomain_klass(), m);;
}
// The following is initializing converter functions for serialization in
// JVM.cpp. If we clean up the StrictMath code above we may want to find
// a better solution for this as well.
initialize_converter_functions();
// This needs to be done before the first scavenge/gc, since
// it's an input to soft ref clearing policy.
{
......
......@@ -1023,8 +1023,7 @@ bool Method::is_ignored_by_security_stack_walk() const {
// This is Method.invoke() -- ignore it
return true;
}
if (JDK_Version::is_gte_jdk14x_version() &&
method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) {
if (method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) {
// This is an auxilary frame -- ignore it
return true;
}
......
......@@ -3923,50 +3923,6 @@ JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon) {
}
// Support for Serialization
typedef jfloat (JNICALL *IntBitsToFloatFn )(JNIEnv* env, jclass cb, jint value);
typedef jdouble (JNICALL *LongBitsToDoubleFn)(JNIEnv* env, jclass cb, jlong value);
typedef jint (JNICALL *FloatToIntBitsFn )(JNIEnv* env, jclass cb, jfloat value);
typedef jlong (JNICALL *DoubleToLongBitsFn)(JNIEnv* env, jclass cb, jdouble value);
static IntBitsToFloatFn int_bits_to_float_fn = NULL;
static LongBitsToDoubleFn long_bits_to_double_fn = NULL;
static FloatToIntBitsFn float_to_int_bits_fn = NULL;
static DoubleToLongBitsFn double_to_long_bits_fn = NULL;
void initialize_converter_functions() {
if (JDK_Version::is_gte_jdk14x_version()) {
// These functions only exist for compatibility with 1.3.1 and earlier
return;
}
// called from universe_post_init()
assert(
int_bits_to_float_fn == NULL &&
long_bits_to_double_fn == NULL &&
float_to_int_bits_fn == NULL &&
double_to_long_bits_fn == NULL ,
"initialization done twice"
);
// initialize
int_bits_to_float_fn = CAST_TO_FN_PTR(IntBitsToFloatFn , NativeLookup::base_library_lookup("java/lang/Float" , "intBitsToFloat" , "(I)F"));
long_bits_to_double_fn = CAST_TO_FN_PTR(LongBitsToDoubleFn, NativeLookup::base_library_lookup("java/lang/Double", "longBitsToDouble", "(J)D"));
float_to_int_bits_fn = CAST_TO_FN_PTR(FloatToIntBitsFn , NativeLookup::base_library_lookup("java/lang/Float" , "floatToIntBits" , "(F)I"));
double_to_long_bits_fn = CAST_TO_FN_PTR(DoubleToLongBitsFn, NativeLookup::base_library_lookup("java/lang/Double", "doubleToLongBits", "(D)J"));
// verify
assert(
int_bits_to_float_fn != NULL &&
long_bits_to_double_fn != NULL &&
float_to_int_bits_fn != NULL &&
double_to_long_bits_fn != NULL ,
"initialization failed"
);
}
// Shared JNI/JVM entry points //////////////////////////////////////////////////////////////
jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) {
......
......@@ -185,64 +185,7 @@ jint Unsafe_invocation_key_to_method_slot(jint key) {
// Get/SetObject must be special-cased, since it works with handles.
// The xxx140 variants for backward compatibility do not allow a full-width offset.
UNSAFE_ENTRY(jobject, Unsafe_GetObject140(JNIEnv *env, jobject unsafe, jobject obj, jint offset))
UnsafeWrapper("Unsafe_GetObject");
if (obj == NULL) THROW_0(vmSymbols::java_lang_NullPointerException());
GET_OOP_FIELD(obj, offset, v)
jobject ret = JNIHandles::make_local(env, v);
#if INCLUDE_ALL_GCS
// We could be accessing the referent field in a reference
// object. If G1 is enabled then we need to register a non-null
// referent with the SATB barrier.
if (UseG1GC) {
bool needs_barrier = false;
if (ret != NULL) {
if (offset == java_lang_ref_Reference::referent_offset) {
oop o = JNIHandles::resolve_non_null(obj);
Klass* k = o->klass();
if (InstanceKlass::cast(k)->reference_type() != REF_NONE) {
assert(InstanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity");
needs_barrier = true;
}
}
}
if (needs_barrier) {
oop referent = JNIHandles::resolve(ret);
G1SATBCardTableModRefBS::enqueue(referent);
}
}
#endif // INCLUDE_ALL_GCS
return ret;
UNSAFE_END
UNSAFE_ENTRY(void, Unsafe_SetObject140(JNIEnv *env, jobject unsafe, jobject obj, jint offset, jobject x_h))
UnsafeWrapper("Unsafe_SetObject");
if (obj == NULL) THROW(vmSymbols::java_lang_NullPointerException());
oop x = JNIHandles::resolve(x_h);
//SET_FIELD(obj, offset, oop, x);
oop p = JNIHandles::resolve(obj);
if (UseCompressedOops) {
if (x != NULL) {
// If there is a heap base pointer, we are obliged to emit a store barrier.
oop_store((narrowOop*)index_oop_from_field_offset_long(p, offset), x);
} else {
narrowOop n = oopDesc::encode_heap_oop_not_null(x);
*(narrowOop*)index_oop_from_field_offset_long(p, offset) = n;
}
} else {
if (x != NULL) {
// If there is a heap base pointer, we are obliged to emit a store barrier.
oop_store((oop*)index_oop_from_field_offset_long(p, offset), x);
} else {
*(oop*)index_oop_from_field_offset_long(p, offset) = x;
}
}
UNSAFE_END
// The normal variants allow a null base pointer with an arbitrary address.
// These functions allow a null base pointer with an arbitrary address.
// But if the base pointer is non-null, the offset should make some sense.
// That is, it should be in the range [0, MAX_OBJECT_SIZE].
UNSAFE_ENTRY(jobject, Unsafe_GetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset))
......@@ -1350,9 +1293,6 @@ UNSAFE_END
// These are the methods for 1.4.0
static JNINativeMethod methods_140[] = {
{CC"getObject", CC"("OBJ"I)"OBJ"", FN_PTR(Unsafe_GetObject140)},
{CC"putObject", CC"("OBJ"I"OBJ")V", FN_PTR(Unsafe_SetObject140)},
DECLARE_GETSETOOP_140(Boolean, Z),
DECLARE_GETSETOOP_140(Byte, B),
DECLARE_GETSETOOP_140(Short, S),
......
......@@ -222,10 +222,8 @@ void Arguments::init_version_specific_system_properties() {
const char* spec_vendor = "Sun Microsystems Inc.";
uint32_t spec_version = 0;
if (JDK_Version::is_gte_jdk17x_version()) {
spec_vendor = "Oracle Corporation";
spec_version = JDK_Version::current().major_version();
}
spec_vendor = "Oracle Corporation";
spec_version = JDK_Version::current().major_version();
jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
PropertyList_add(&_system_properties,
......@@ -3695,14 +3693,6 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
PrintGC = true;
}
if (!JDK_Version::is_gte_jdk18x_version()) {
// To avoid changing the log format for 7 updates this flag is only
// true by default in JDK8 and above.
if (FLAG_IS_DEFAULT(PrintGCCause)) {
FLAG_SET_DEFAULT(PrintGCCause, false);
}
}
// Set object alignment values.
set_object_alignment();
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, 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
......@@ -197,58 +197,6 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC {
_runtime_version = version;
}
// Convenience methods for queries on the current major/minor version
static bool is_jdk12x_version() {
return current().compare_major(2) == 0;
}
static bool is_jdk13x_version() {
return current().compare_major(3) == 0;
}
static bool is_jdk14x_version() {
return current().compare_major(4) == 0;
}
static bool is_jdk15x_version() {
return current().compare_major(5) == 0;
}
static bool is_jdk16x_version() {
return current().compare_major(6) == 0;
}
static bool is_jdk17x_version() {
return current().compare_major(7) == 0;
}
static bool is_jdk18x_version() {
return current().compare_major(8) == 0;
}
static bool is_gte_jdk13x_version() {
return current().compare_major(3) >= 0;
}
static bool is_gte_jdk14x_version() {
return current().compare_major(4) >= 0;
}
static bool is_gte_jdk15x_version() {
return current().compare_major(5) >= 0;
}
static bool is_gte_jdk16x_version() {
return current().compare_major(6) >= 0;
}
static bool is_gte_jdk17x_version() {
return current().compare_major(7) >= 0;
}
static bool is_gte_jdk18x_version() {
return current().compare_major(8) >= 0;
}
};
#endif // SHARE_VM_RUNTIME_JAVA_HPP
......@@ -410,49 +410,6 @@ oop Reflection::array_component_type(oop mirror, TRAPS) {
}
bool Reflection::reflect_check_access(Klass* field_class, AccessFlags acc, Klass* target_class, bool is_method_invoke, TRAPS) {
// field_class : declaring class
// acc : declared field access
// target_class : for protected
// Check if field or method is accessible to client. Throw an
// IllegalAccessException and return false if not.
// The "client" is the class associated with the nearest real frame
// getCallerClass already skips Method.invoke frames, so pass 0 in
// that case (same as classic).
ResourceMark rm(THREAD);
assert(THREAD->is_Java_thread(), "sanity check");
Klass* client_class = ((JavaThread *)THREAD)->security_get_caller_class(is_method_invoke ? 0 : 1);
if (client_class != field_class) {
if (!verify_class_access(client_class, field_class, false)
|| !verify_field_access(client_class,
field_class,
field_class,
acc,
false)) {
THROW_(vmSymbols::java_lang_IllegalAccessException(), false);
}
}
// Additional test for protected members: JLS 6.6.2
if (acc.is_protected()) {
if (target_class != client_class) {
if (!is_same_class_package(client_class, field_class)) {
if (!target_class->is_subclass_of(client_class)) {
THROW_(vmSymbols::java_lang_IllegalAccessException(), false);
}
}
}
}
// Passed all tests
return true;
}
bool Reflection::verify_class_access(Klass* current_class, Klass* new_class, bool classloader_only) {
// Verify that current_class can access new_class. If the classloader_only
// flag is set, we automatically allow any accesses in which current_class
......@@ -463,10 +420,9 @@ bool Reflection::verify_class_access(Klass* current_class, Klass* new_class, boo
is_same_class_package(current_class, new_class)) {
return true;
}
// New (1.4) reflection implementation. Allow all accesses from
// sun/reflect/MagicAccessorImpl subclasses to succeed trivially.
if ( JDK_Version::is_gte_jdk14x_version()
&& current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
// Allow all accesses from sun/reflect/MagicAccessorImpl subclasses to
// succeed trivially.
if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
return true;
}
......@@ -567,10 +523,9 @@ bool Reflection::verify_field_access(Klass* current_class,
return true;
}
// New (1.4) reflection implementation. Allow all accesses from
// sun/reflect/MagicAccessorImpl subclasses to succeed trivially.
if ( JDK_Version::is_gte_jdk14x_version()
&& current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
// Allow all accesses from sun/reflect/MagicAccessorImpl subclasses to
// succeed trivially.
if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
return true;
}
......@@ -707,12 +662,10 @@ Handle Reflection::new_type(Symbol* signature, KlassHandle k, TRAPS) {
oop Reflection::new_method(methodHandle method, bool for_constant_pool_access, TRAPS) {
// In jdk1.2.x, getMethods on an interface erroneously includes <clinit>, thus the complicated assert.
// Also allow sun.reflect.ConstantPool to refer to <clinit> methods as java.lang.reflect.Methods.
// Allow sun.reflect.ConstantPool to refer to <clinit> methods as java.lang.reflect.Methods.
assert(!method()->is_initializer() ||
(for_constant_pool_access && method()->is_static()) ||
(method()->name() == vmSymbols::class_initializer_name()
&& method()->method_holder()->is_interface() && JDK_Version::is_jdk12x_version()), "should call new_constructor instead");
(for_constant_pool_access && method()->is_static()),
"should call new_constructor instead");
instanceKlassHandle holder (THREAD, method->method_holder());
int slot = method->method_idnum();
......@@ -978,22 +931,6 @@ oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method,
reflected_method->signature()));
}
// In the JDK 1.4 reflection implementation, the security check is
// done at the Java level
if (!JDK_Version::is_gte_jdk14x_version()) {
// Access checking (unless overridden by Method)
if (!override) {
if (!(klass->is_public() && reflected_method->is_public())) {
bool access = Reflection::reflect_check_access(klass(), reflected_method->access_flags(), target_klass(), is_method_invoke, CHECK_NULL);
if (!access) {
return NULL; // exception
}
}
}
} // !Universe::is_gte_jdk14x_version()
assert(ptypes->is_objArray(), "just checking");
int args_len = args.is_null() ? 0 : args->length();
// Check number of arguments
......
......@@ -44,9 +44,6 @@ class FieldStream;
class Reflection: public AllStatic {
private:
// Access checking
static bool reflect_check_access(Klass* field_class, AccessFlags acc, Klass* target_class, bool is_method_invoke, TRAPS);
// Conversion
static Klass* basic_type_mirror_to_arrayklass(oop basic_type_mirror, TRAPS);
static oop basic_type_arrayklass_to_mirror(Klass* basic_type_arrayklass, TRAPS);
......
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2014, 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
......@@ -76,15 +76,10 @@ void FilteredFieldsMap::initialize() {
int offset;
offset = java_lang_Throwable::get_backtrace_offset();
_filtered_fields->append(new FilteredField(SystemDictionary::Throwable_klass(), offset));
// The latest version of vm may be used with old jdk.
if (JDK_Version::is_gte_jdk16x_version()) {
// The following class fields do not exist in
// previous version of jdk.
offset = sun_reflect_ConstantPool::oop_offset();
_filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset));
offset = sun_reflect_UnsafeStaticFieldAccessorImpl::base_offset();
_filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset));
}
offset = sun_reflect_ConstantPool::oop_offset();
_filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset));
offset = sun_reflect_UnsafeStaticFieldAccessorImpl::base_offset();
_filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset));
}
int FilteredFieldStream::field_count() {
......
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2014, 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
......@@ -41,8 +41,7 @@ void ServiceThread::initialize() {
instanceKlassHandle klass (THREAD, SystemDictionary::Thread_klass());
instanceHandle thread_oop = klass->allocate_instance_handle(CHECK);
const char* name = JDK_Version::is_gte_jdk17x_version() ?
"Service Thread" : "Low Memory Detector";
const char* name = "Service Thread";
Handle string = java_lang_String::create_from_str(name, CHECK);
......
......@@ -1738,55 +1738,26 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
CLEAR_PENDING_EXCEPTION;
}
// FIXIT: The is_null check is only so it works better on JDK1.2 VM's. This
// has to be fixed by a runtime query method
if (!destroy_vm || JDK_Version::is_jdk12x_version()) {
// JSR-166: change call from from ThreadGroup.uncaughtException to
// java.lang.Thread.dispatchUncaughtException
if (!destroy_vm) {
if (uncaught_exception.not_null()) {
Handle group(this, java_lang_Thread::threadGroup(threadObj()));
{
EXCEPTION_MARK;
// Check if the method Thread.dispatchUncaughtException() exists. If so
// call it. Otherwise we have an older library without the JSR-166 changes,
// so call ThreadGroup.uncaughtException()
KlassHandle recvrKlass(THREAD, threadObj->klass());
CallInfo callinfo;
KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
LinkResolver::resolve_virtual_call(callinfo, threadObj, recvrKlass, thread_klass,
vmSymbols::dispatchUncaughtException_name(),
vmSymbols::throwable_void_signature(),
KlassHandle(), false, false, THREAD);
EXCEPTION_MARK;
// Call method Thread.dispatchUncaughtException().
KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
JavaValue result(T_VOID);
JavaCalls::call_virtual(&result,
threadObj, thread_klass,
vmSymbols::dispatchUncaughtException_name(),
vmSymbols::throwable_void_signature(),
uncaught_exception,
THREAD);
if (HAS_PENDING_EXCEPTION) {
ResourceMark rm(this);
jio_fprintf(defaultStream::error_stream(),
"\nException: %s thrown from the UncaughtExceptionHandler"
" in thread \"%s\"\n",
pending_exception()->klass()->external_name(),
get_thread_name());
CLEAR_PENDING_EXCEPTION;
methodHandle method = callinfo.selected_method();
if (method.not_null()) {
JavaValue result(T_VOID);
JavaCalls::call_virtual(&result,
threadObj, thread_klass,
vmSymbols::dispatchUncaughtException_name(),
vmSymbols::throwable_void_signature(),
uncaught_exception,
THREAD);
} else {
KlassHandle thread_group(THREAD, SystemDictionary::ThreadGroup_klass());
JavaValue result(T_VOID);
JavaCalls::call_virtual(&result,
group, thread_group,
vmSymbols::uncaughtException_name(),
vmSymbols::thread_throwable_void_signature(),
threadObj, // Arg 1
uncaught_exception, // Arg 2
THREAD);
}
if (HAS_PENDING_EXCEPTION) {
ResourceMark rm(this);
jio_fprintf(defaultStream::error_stream(),
"\nException: %s thrown from the UncaughtExceptionHandler"
" in thread \"%s\"\n",
pending_exception()->klass()->external_name(),
get_thread_name());
CLEAR_PENDING_EXCEPTION;
}
}
}
......@@ -2848,7 +2819,7 @@ void JavaThread::print_on(outputStream *st) const {
Thread::print_on(st);
// print guess for valid stack memory region (assume 4K pages); helps lock debugging
st->print_cr("[" INTPTR_FORMAT "]", (intptr_t)last_Java_sp() & ~right_n_bits(12));
if (thread_oop != NULL && JDK_Version::is_gte_jdk15x_version()) {
if (thread_oop != NULL) {
st->print_cr(" java.lang.Thread.State: %s", java_lang_Thread::thread_status_name(thread_oop));
}
#ifndef PRODUCT
......@@ -3948,15 +3919,8 @@ bool Threads::destroy_vm() {
}
os::wait_for_keypress_at_exit();
if (JDK_Version::is_jdk12x_version()) {
// We are the last thread running, so check if finalizers should be run.
// For 1.3 or later this is done in thread->invoke_shutdown_hooks()
HandleMark rm(thread);
Universe::run_finalizers_on_exit();
} else {
// run Java level shutdown hooks
thread->invoke_shutdown_hooks();
}
// run Java level shutdown hooks
thread->invoke_shutdown_hooks();
before_exit(thread);
......
......@@ -480,9 +480,8 @@ void vframeStreamCommon::skip_prefixed_method_and_wrappers() {
void vframeStreamCommon::skip_reflection_related_frames() {
while (!at_end() &&
(JDK_Version::is_gte_jdk14x_version() &&
(method()->method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass()) ||
method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass())))) {
method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass()))) {
next();
}
}
......
......@@ -184,9 +184,7 @@ bool VM_PrintThreads::doit_prologue() {
assert(Thread::current()->is_Java_thread(), "just checking");
// Make sure AbstractOwnableSynchronizer is loaded
if (JDK_Version::is_gte_jdk16x_version()) {
java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current());
}
java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current());
// Get Heap_lock if concurrent locks will be dumped
if (_print_concurrent_locks) {
......@@ -225,7 +223,7 @@ bool VM_FindDeadlocks::doit_prologue() {
assert(Thread::current()->is_Java_thread(), "just checking");
// Load AbstractOwnableSynchronizer class
if (_concurrent_locks && JDK_Version::is_gte_jdk16x_version()) {
if (_concurrent_locks) {
java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current());
}
......@@ -283,9 +281,7 @@ bool VM_ThreadDump::doit_prologue() {
assert(Thread::current()->is_Java_thread(), "just checking");
// Load AbstractOwnableSynchronizer class before taking thread snapshots
if (JDK_Version::is_gte_jdk16x_version()) {
java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current());
}
java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current());
if (_with_locked_synchronizers) {
// Acquire Heap_lock to dump concurrent locks
......
......@@ -160,8 +160,7 @@ const char* Abstract_VM_Version::vm_vendor() {
#ifdef VENDOR
return XSTR(VENDOR);
#else
return JDK_Version::is_gte_jdk17x_version() ?
"Oracle Corporation" : "Sun Microsystems Inc.";
return "Oracle Corporation";
#endif
}
......
......@@ -1229,10 +1229,8 @@ JVM_ENTRY(jint, jmm_GetThreadInfo(JNIEnv *env, jlongArray ids, jint maxDepth, jo
"The length of the given ThreadInfo array does not match the length of the given array of thread IDs", -1);
}
if (JDK_Version::is_gte_jdk16x_version()) {
// make sure the AbstractOwnableSynchronizer klass is loaded before taking thread snapshots
java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(CHECK_0);
}
// make sure the AbstractOwnableSynchronizer klass is loaded before taking thread snapshots
java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(CHECK_0);
// Must use ThreadDumpResult to store the ThreadSnapshot.
// GC may occur after the thread snapshots are taken but before
......@@ -1303,10 +1301,8 @@ JVM_END
JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboolean locked_monitors, jboolean locked_synchronizers))
ResourceMark rm(THREAD);
if (JDK_Version::is_gte_jdk16x_version()) {
// make sure the AbstractOwnableSynchronizer klass is loaded before taking thread snapshots
java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(CHECK_NULL);
}
// make sure the AbstractOwnableSynchronizer klass is loaded before taking thread snapshots
java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(CHECK_NULL);
typeArrayOop ta = typeArrayOop(JNIHandles::resolve(thread_ids));
int num_threads = (ta != NULL ? ta->length() : 0);
......
......@@ -665,17 +665,15 @@ void ConcurrentLocksDump::dump_at_safepoint() {
// dump all locked concurrent locks
assert(SafepointSynchronize::is_at_safepoint(), "all threads are stopped");
if (JDK_Version::is_gte_jdk16x_version()) {
ResourceMark rm;
ResourceMark rm;
GrowableArray<oop>* aos_objects = new GrowableArray<oop>(INITIAL_ARRAY_SIZE);
GrowableArray<oop>* aos_objects = new GrowableArray<oop>(INITIAL_ARRAY_SIZE);
// Find all instances of AbstractOwnableSynchronizer
HeapInspection::find_instances_at_safepoint(SystemDictionary::abstract_ownable_synchronizer_klass(),
// Find all instances of AbstractOwnableSynchronizer
HeapInspection::find_instances_at_safepoint(SystemDictionary::abstract_ownable_synchronizer_klass(),
aos_objects);
// Build a map of thread to its owned AQS locks
build_map(aos_objects);
}
// Build a map of thread to its owned AQS locks
build_map(aos_objects);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册