Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8235225: Replace CHECK_0 with CHECK_NULL for non-integer returning me…
…thods

Change CHECK_0 to CHECK_NULL and CHECK_false where appropriate

Reviewed-by: mikael, dholmes, coleenp
  • Loading branch information
Harold Seigel committed Feb 27, 2020
1 parent 2ba0575 commit a1e93283678ad1c6315d08442745c2ab52526b9d
@@ -5274,7 +5274,7 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature,
if (!legal) {
classfile_parse_error("Class name is empty or contains illegal character "
"in descriptor in class file %s",
CHECK_0);
CHECK_NULL);
return NULL;
}
return signature + newlen + 1;
@@ -5286,7 +5286,7 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature,
array_dim++;
if (array_dim > 255) {
// 4277370: array descriptor is valid only if it represents 255 or fewer dimensions.
classfile_parse_error("Array type descriptor has more than 255 dimensions in class file %s", CHECK_0);
classfile_parse_error("Array type descriptor has more than 255 dimensions in class file %s", CHECK_NULL);
}
// The rest of what's there better be a legal signature
signature++;
@@ -349,9 +349,9 @@ Klass* ClassListParser::load_current_class(TRAPS) {
// delegate to the correct loader (boot, platform or app) depending on
// the class name.

Handle s = java_lang_String::create_from_symbol(class_name_symbol, CHECK_0);
Handle s = java_lang_String::create_from_symbol(class_name_symbol, CHECK_NULL);
// ClassLoader.loadClass() wants external class name format, i.e., convert '/' chars to '.'
Handle ext_class_name = java_lang_String::externalize_classname(s, CHECK_0);
Handle ext_class_name = java_lang_String::externalize_classname(s, CHECK_NULL);
Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());

JavaCalls::call_virtual(&result,
@@ -296,7 +296,7 @@ Handle java_lang_String::create_from_unicode(const jchar* unicode, int length, T
}

oop java_lang_String::create_oop_from_unicode(const jchar* unicode, int length, TRAPS) {
Handle h_obj = create_from_unicode(unicode, length, CHECK_0);
Handle h_obj = create_from_unicode(unicode, length, CHECK_NULL);
return h_obj();
}

@@ -343,7 +343,7 @@ Handle java_lang_String::create_from_str(const char* utf8_str, TRAPS) {
}

oop java_lang_String::create_oop_from_str(const char* utf8_str, TRAPS) {
Handle h_obj = create_from_str(utf8_str, CHECK_0);
Handle h_obj = create_from_str(utf8_str, CHECK_NULL);
return h_obj();
}

@@ -1441,7 +1441,7 @@ void java_lang_Class::set_source_file(oop java_class, oop source_file) {
oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
// This should be improved by adding a field at the Java level or by
// introducing a new VM klass (see comment in ClassFileParser)
oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0);
oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_NULL);
if (type != T_VOID) {
Klass* aklass = Universe::typeArrayKlassObj(type);
assert(aklass != NULL, "correct bootstrap");
@@ -2647,13 +2647,13 @@ oop java_lang_StackTraceElement::create(const methodHandle& method, int bci, TRA
InstanceKlass* k = SystemDictionary::StackTraceElement_klass();
assert(k != NULL, "must be loaded in 1.4+");
if (k->should_be_initialized()) {
k->initialize(CHECK_0);
k->initialize(CHECK_NULL);
}

Handle element = k->allocate_instance_handle(CHECK_0);
Handle element = k->allocate_instance_handle(CHECK_NULL);

int version = method->constants()->version();
fill_in(element, method->method_holder(), method, version, bci, method->name(), CHECK_0);
fill_in(element, method->method_holder(), method, version, bci, method->name(), CHECK_NULL);
return element();
}

@@ -3399,13 +3399,13 @@ oop java_lang_boxing_object::initialize_and_allocate(BasicType type, TRAPS) {
Klass* k = SystemDictionary::box_klass(type);
if (k == NULL) return NULL;
InstanceKlass* ik = InstanceKlass::cast(k);
if (!ik->is_initialized()) ik->initialize(CHECK_0);
if (!ik->is_initialized()) ik->initialize(CHECK_NULL);
return ik->allocate_instance(THREAD);
}


oop java_lang_boxing_object::create(BasicType type, jvalue* value, TRAPS) {
oop box = initialize_and_allocate(type, CHECK_0);
oop box = initialize_and_allocate(type, CHECK_NULL);
if (box == NULL) return NULL;
switch (type) {
case T_BOOLEAN:
@@ -4036,9 +4036,9 @@ oop java_security_AccessControlContext::create(objArrayHandle context, bool isPr
assert(_isPrivileged_offset != 0, "offsets should have been initialized");
assert(_isAuthorized_offset != -1, "offsets should have been initialized");
// Ensure klass is initialized
SystemDictionary::AccessControlContext_klass()->initialize(CHECK_0);
SystemDictionary::AccessControlContext_klass()->initialize(CHECK_NULL);
// Allocate result
oop result = SystemDictionary::AccessControlContext_klass()->allocate_instance(CHECK_0);
oop result = SystemDictionary::AccessControlContext_klass()->allocate_instance(CHECK_NULL);
// Fill in values
result->obj_field_put(_context_offset, context());
result->obj_field_put(_privilegedContext_offset, privileged_context());
@@ -1918,7 +1918,7 @@ bool SystemDictionary::resolve_wk_klass(WKID id, TRAPS) {
InstanceKlass** klassp = &_well_known_klasses[id];

if ((*klassp) == NULL) {
Klass* k = resolve_or_fail(symbol, true, CHECK_0);
Klass* k = resolve_or_fail(symbol, true, CHECK_false);
(*klassp) = InstanceKlass::cast(k);
}
return ((*klassp) != NULL);
@@ -979,7 +979,7 @@ bool SystemDictionaryShared::add_unregistered_class(InstanceKlass* k, TRAPS) {
bool isnew = _loaded_unregistered_classes.put(name, true);
assert(isnew, "sanity");
MutexLocker mu_r(THREAD, Compile_lock); // add_to_hierarchy asserts this.
SystemDictionary::add_to_hierarchy(k, CHECK_0);
SystemDictionary::add_to_hierarchy(k, CHECK_false);
return true;
}
}
@@ -534,7 +534,7 @@ C2V_VMENTRY_NULL(jobject, lookupType, (JNIEnv* env, jobject, jstring jname, jcla
}

if (resolve) {
resolved_klass = SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK_0);
resolved_klass = SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK_NULL);
if (resolved_klass == NULL) {
JVMCI_THROW_MSG_NULL(ClassNotFoundException, str);
}
@@ -543,7 +543,7 @@ C2V_VMENTRY_NULL(jobject, lookupType, (JNIEnv* env, jobject, jstring jname, jcla
// This is a name from a signature. Strip off the trimmings.
// Call recursive to keep scope of strippedsym.
TempNewSymbol strippedsym = Signature::strip_envelope(class_name);
resolved_klass = SystemDictionary::find(strippedsym, class_loader, protection_domain, CHECK_0);
resolved_klass = SystemDictionary::find(strippedsym, class_loader, protection_domain, CHECK_NULL);
} else if (Signature::is_array(class_name)) {
SignatureStream ss(class_name, false);
int ndim = ss.skip_array_prefix();
@@ -552,15 +552,15 @@ C2V_VMENTRY_NULL(jobject, lookupType, (JNIEnv* env, jobject, jstring jname, jcla
resolved_klass = SystemDictionary::find(strippedsym,
class_loader,
protection_domain,
CHECK_0);
CHECK_NULL);
if (!resolved_klass.is_null()) {
resolved_klass = resolved_klass->array_klass(ndim, CHECK_0);
resolved_klass = resolved_klass->array_klass(ndim, CHECK_NULL);
}
} else {
resolved_klass = TypeArrayKlass::cast(Universe::typeArrayKlassObj(ss.type()))->array_klass(ndim, CHECK_0);
resolved_klass = TypeArrayKlass::cast(Universe::typeArrayKlassObj(ss.type()))->array_klass(ndim, CHECK_NULL);
}
} else {
resolved_klass = SystemDictionary::find(class_name, class_loader, protection_domain, CHECK_0);
resolved_klass = SystemDictionary::find(class_name, class_loader, protection_domain, CHECK_NULL);
}
}
JVMCIObject result = JVMCIENV->get_jvmci_type(resolved_klass, JVMCI_CHECK_NULL);
@@ -704,8 +704,8 @@ C2V_VMENTRY_NULL(jobject, resolveFieldInPool, (JNIEnv* env, jobject, jobject jvm
Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF);
fieldDescriptor fd;
methodHandle mh(THREAD, (jvmci_method != NULL) ? JVMCIENV->asMethod(jvmci_method) : NULL);
LinkInfo link_info(cp, index, mh, CHECK_0);
LinkResolver::resolve_field(fd, link_info, Bytecodes::java_code(code), false, CHECK_0);
LinkInfo link_info(cp, index, mh, CHECK_NULL);
LinkResolver::resolve_field(fd, link_info, Bytecodes::java_code(code), false, CHECK_NULL);
JVMCIPrimitiveArray info = JVMCIENV->wrap(info_handle);
if (info.is_null() || JVMCIENV->get_length(info) != 3) {
JVMCI_ERROR_NULL("info must not be null and have a length of 3");
@@ -1825,7 +1825,7 @@ C2V_VMENTRY_0(jboolean, isInternedString, (JNIEnv* env, jobject, jobject object)
return false;
}
int len;
jchar* name = java_lang_String::as_unicode_string(str(), len, CHECK_0);
jchar* name = java_lang_String::as_unicode_string(str(), len, CHECK_false);
return (StringTable::lookup(name, len) != NULL);
C2V_END

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, 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
@@ -124,12 +124,12 @@ GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots,
}

objArrayOop ArrayKlass::allocate_arrayArray(int n, int length, TRAPS) {
check_array_allocation_length(length, arrayOopDesc::max_array_length(T_ARRAY), CHECK_0);
check_array_allocation_length(length, arrayOopDesc::max_array_length(T_ARRAY), CHECK_NULL);
int size = objArrayOopDesc::object_size(length);
Klass* k = array_klass(n+dimension(), CHECK_0);
Klass* k = array_klass(n+dimension(), CHECK_NULL);
ArrayKlass* ak = ArrayKlass::cast(k);
objArrayOop o = (objArrayOop)Universe::heap()->array_allocate(ak, size, length,
/* do_zero */ true, CHECK_0);
/* do_zero */ true, CHECK_NULL);
// initialization to NULL not necessary, area already cleared
return o;
}
@@ -80,13 +80,13 @@ Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data,
Klass* ek = NULL;
{
MutexUnlocker mu(MultiArray_lock);
super_klass = element_super->array_klass(CHECK_0);
super_klass = element_super->array_klass(CHECK_NULL);
for( int i = element_supers->length()-1; i >= 0; i-- ) {
Klass* elem_super = element_supers->at(i);
elem_super->array_klass(CHECK_0);
elem_super->array_klass(CHECK_NULL);
}
// Now retry from the beginning
ek = element_klass->array_klass(n, CHECK_0);
ek = element_klass->array_klass(n, CHECK_NULL);
} // re-lock
return ek;
}
@@ -124,13 +124,13 @@ Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data,
}

// Initialize instance variables
ObjArrayKlass* oak = ObjArrayKlass::allocate(loader_data, n, element_klass, name, CHECK_0);
ObjArrayKlass* oak = ObjArrayKlass::allocate(loader_data, n, element_klass, name, CHECK_NULL);

ModuleEntry* module = oak->module();
assert(module != NULL, "No module entry for array");

// Call complete_create_array_klass after all instance variables has been initialized.
ArrayKlass::complete_create_array_klass(oak, super_klass, module, CHECK_0);
ArrayKlass::complete_create_array_klass(oak, super_klass, module, CHECK_NULL);

// Add all classes to our internal class loader list here,
// including classes in the bootstrap (NULL) class loader.
@@ -171,7 +171,7 @@ int ObjArrayKlass::oop_size(oop obj) const {
}

objArrayOop ObjArrayKlass::allocate(int length, TRAPS) {
check_array_allocation_length(length, arrayOopDesc::max_array_length(T_OBJECT), CHECK_0);
check_array_allocation_length(length, arrayOopDesc::max_array_length(T_OBJECT), CHECK_NULL);
int size = objArrayOopDesc::object_size(length);
return (objArrayOop)Universe::heap()->array_allocate(this, size, length,
/* do_zero */ true, THREAD);
@@ -2540,7 +2540,7 @@ JNI_ENTRY(Return, \
Return ret = NULL;\
DT_RETURN_MARK(New##Result##Array, Return, (const Return&)ret);\
\
oop obj= oopFactory::Allocator(len, CHECK_0); \
oop obj= oopFactory::Allocator(len, CHECK_NULL); \
ret = (Return) JNIHandles::make_local(env, obj); \
return ret;\
JNI_END
@@ -558,7 +558,7 @@ JVM_ENTRY(jstring, JVM_GetExtendedNPEMessage(JNIEnv *env, jthrowable throwable))
stringStream ss;
bool ok = BytecodeUtils::get_NPE_message_at(&ss, method, bci);
if (ok) {
oop result = java_lang_String::create_oop_from_str(ss.base(), CHECK_0);
oop result = java_lang_String::create_oop_from_str(ss.base(), CHECK_NULL);
return (jstring) JNIHandles::make_local(env, result);
} else {
return NULL;
@@ -1482,19 +1482,19 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp,
case JVM_CONSTANT_Long:
// just copy the entry to *merge_cp_p, but double and long take
// two constant pool entries
ConstantPool::copy_entry_to(old_cp, old_i, *merge_cp_p, old_i, CHECK_0);
ConstantPool::copy_entry_to(old_cp, old_i, *merge_cp_p, old_i, CHECK_false);
old_i++;
break;

default:
// just copy the entry to *merge_cp_p
ConstantPool::copy_entry_to(old_cp, old_i, *merge_cp_p, old_i, CHECK_0);
ConstantPool::copy_entry_to(old_cp, old_i, *merge_cp_p, old_i, CHECK_false);
break;
}
} // end for each old_cp entry

ConstantPool::copy_operands(old_cp, *merge_cp_p, CHECK_0);
(*merge_cp_p)->extend_operands(scratch_cp, CHECK_0);
ConstantPool::copy_operands(old_cp, *merge_cp_p, CHECK_false);
(*merge_cp_p)->extend_operands(scratch_cp, CHECK_false);

// We don't need to sanity check that *merge_cp_length_p is within
// *merge_cp_p bounds since we have the minimum on-entry check above.
@@ -1528,7 +1528,7 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp,
}

bool match = scratch_cp->compare_entry_to(scratch_i, *merge_cp_p,
scratch_i, CHECK_0);
scratch_i, CHECK_false);
if (match) {
// found a match at the same index so nothing more to do
continue;
@@ -1543,7 +1543,7 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp,
}

int found_i = scratch_cp->find_matching_entry(scratch_i, *merge_cp_p,
CHECK_0);
CHECK_false);
if (found_i != 0) {
guarantee(found_i != scratch_i,
"compare_entry_to() and find_matching_entry() do not agree");
@@ -1564,7 +1564,7 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp,
// No match found so we have to append this entry and any unique
// referenced entries to *merge_cp_p.
append_entry(scratch_cp, scratch_i, merge_cp_p, merge_cp_length_p,
CHECK_0);
CHECK_false);
}
}

@@ -1592,7 +1592,7 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp,
}

int found_i =
scratch_cp->find_matching_entry(scratch_i, *merge_cp_p, CHECK_0);
scratch_cp->find_matching_entry(scratch_i, *merge_cp_p, CHECK_false);
if (found_i != 0) {
// Found a matching entry somewhere else in *merge_cp_p so
// just need a mapping entry.
@@ -1603,7 +1603,7 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp,
// No match found so we have to append this entry and any unique
// referenced entries to *merge_cp_p.
append_entry(scratch_cp, scratch_i, merge_cp_p, merge_cp_length_p,
CHECK_0);
CHECK_false);
}

log_debug(redefine, class, constantpool)
@@ -1356,7 +1356,7 @@ JVM_ENTRY(jboolean, jmm_ResetStatistic(JNIEnv *env, jvalue obj, jmmStatisticType
THROW_(vmSymbols::java_lang_NullPointerException(), JNI_FALSE);
}

GCMemoryManager* mgr = get_gc_memory_manager_from_jobject(o, CHECK_0);
GCMemoryManager* mgr = get_gc_memory_manager_from_jobject(o, CHECK_false);
if (mgr != NULL) {
mgr->reset_gc_stat();
return true;
@@ -1402,7 +1402,7 @@ JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env))
int nFlags = (int) JVMFlag::numFlags - 1;
// allocate a temp array
objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(),
nFlags, CHECK_0);
nFlags, CHECK_NULL);
objArrayHandle flags_ah(THREAD, r);
int num_entries = 0;
for (int i = 0; i < nFlags; i++) {
@@ -1413,15 +1413,15 @@ JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env))
}
// Exclude the locked (experimental, diagnostic) flags
if (flag->is_unlocked() || flag->is_unlocker()) {
Handle s = java_lang_String::create_from_str(flag->_name, CHECK_0);
Handle s = java_lang_String::create_from_str(flag->_name, CHECK_NULL);
flags_ah->obj_at_put(num_entries, s());
num_entries++;
}
}

if (num_entries < nFlags) {
// Return array of right length
objArrayOop res = oopFactory::new_objArray(SystemDictionary::String_klass(), num_entries, CHECK_0);
objArrayOop res = oopFactory::new_objArray(SystemDictionary::String_klass(), num_entries, CHECK_NULL);
for(int i = 0; i < num_entries; i++) {
res->obj_at_put(i, flags_ah->obj_at(i));
}
@@ -1754,15 +1754,15 @@ static Handle find_deadlocks(bool object_monitors_only, TRAPS) {
// object_monitors_only - if true, only check object monitors
//
JVM_ENTRY(jobjectArray, jmm_FindDeadlockedThreads(JNIEnv *env, jboolean object_monitors_only))
Handle result = find_deadlocks(object_monitors_only != 0, CHECK_0);
Handle result = find_deadlocks(object_monitors_only != 0, CHECK_NULL);
return (jobjectArray) JNIHandles::make_local(env, result());
JVM_END

// Finds cycles of threads that are deadlocked on monitor locks
// Returns an array of Thread objects which are in deadlock, if any.
// Otherwise, returns NULL.
JVM_ENTRY(jobjectArray, jmm_FindMonitorDeadlockedThreads(JNIEnv *env))
Handle result = find_deadlocks(true, CHECK_0);
Handle result = find_deadlocks(true, CHECK_NULL);
return (jobjectArray) JNIHandles::make_local(env, result());
JVM_END

@@ -1810,7 +1810,7 @@ static objArrayOop get_memory_usage_objArray(jobjectArray array, int length, TRA
}

// check if the element of array is of type MemoryUsage class
Klass* usage_klass = Management::java_lang_management_MemoryUsage_klass(CHECK_0);
Klass* usage_klass = Management::java_lang_management_MemoryUsage_klass(CHECK_NULL);
Klass* element_klass = ObjArrayKlass::cast(array_h->klass())->element_klass();
if (element_klass != usage_klass) {
THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),

0 comments on commit a1e9328

Please sign in to comment.