src/share/vm/classfile/verifier.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff src/share/vm/classfile/verifier.cpp
src/share/vm/classfile/verifier.cpp
Print this page
*** 134,145 ****
if (klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) {
ClassVerifier split_verifier(klass, THREAD);
split_verifier.verify_class(THREAD);
exception_name = split_verifier.result();
if (can_failover && !HAS_PENDING_EXCEPTION &&
! (exception_name == vmSymbols::java_lang_VerifyError() ||
! exception_name == vmSymbols::java_lang_ClassFormatError())) {
if (TraceClassInitialization || VerboseVerification) {
tty->print_cr(
"Fail over class verification to old verifier for: %s", klassName);
}
exception_name = inference_verify(
--- 134,145 ----
if (klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) {
ClassVerifier split_verifier(klass, THREAD);
split_verifier.verify_class(THREAD);
exception_name = split_verifier.result();
if (can_failover && !HAS_PENDING_EXCEPTION &&
! (exception_name->equals(vmSymbols::java_lang_VerifyError()) ||
! exception_name->equals(vmSymbols::java_lang_ClassFormatError()))) {
if (TraceClassInitialization || VerboseVerification) {
tty->print_cr(
"Fail over class verification to old verifier for: %s", klassName);
}
exception_name = inference_verify(
*** 195,208 ****
return (should_verify_for(klass->class_loader(), should_verify_class) &&
// return if the class is a bootstrapping class
// or defineClass specified not to verify by default (flags override passed arg)
// We need to skip the following four for bootstraping
! name != vmSymbols::java_lang_Object() &&
! name != vmSymbols::java_lang_Class() &&
! name != vmSymbols::java_lang_String() &&
! name != vmSymbols::java_lang_Throwable() &&
// Can not verify the bytecodes for shared classes because they have
// already been rewritten to contain constant pool cache indices,
// which the verifier can't understand.
// Shared classes shouldn't have stackmaps either.
--- 195,208 ----
return (should_verify_for(klass->class_loader(), should_verify_class) &&
// return if the class is a bootstrapping class
// or defineClass specified not to verify by default (flags override passed arg)
// We need to skip the following four for bootstraping
! name->not_equals(vmSymbols::java_lang_Object()) &&
! name->not_equals(vmSymbols::java_lang_Class()) &&
! name->not_equals(vmSymbols::java_lang_String()) &&
! name->not_equals(vmSymbols::java_lang_Throwable()) &&
// Can not verify the bytecodes for shared classes because they have
// already been rewritten to contain constant pool cache indices,
// which the verifier can't understand.
// Shared classes shouldn't have stackmaps either.
*** 1547,1557 ****
"Method expects a return value");
return;
}
// Make sure "this" has been initialized if current method is an
// <init>
! if (_method->name() == vmSymbols::object_initializer_name() &&
current_frame.flag_this_uninit()) {
verify_error(ErrorContext::bad_code(bci),
"Constructor must call super() or this() "
"before return");
return;
--- 1547,1557 ----
"Method expects a return value");
return;
}
// Make sure "this" has been initialized if current method is an
// <init>
! if (_method->name()->equals(vmSymbols::object_initializer_name()) &&
current_frame.flag_this_uninit()) {
verify_error(ErrorContext::bad_code(bci),
"Constructor must call super() or this() "
"before return");
return;
*** 2116,2126 ****
bool ClassVerifier::name_in_supers(
Symbol* ref_name, instanceKlassHandle current) {
Klass* super = current->super();
while (super != NULL) {
! if (super->name() == ref_name) {
return true;
}
super = super->super();
}
return false;
--- 2116,2126 ----
bool ClassVerifier::name_in_supers(
Symbol* ref_name, instanceKlassHandle current) {
Klass* super = current->super();
while (super != NULL) {
! if (super->name()->equals(ref_name)) {
return true;
}
super = super->super();
}
return false;
*** 2446,2457 ****
VerificationType type = current_frame->pop_stack(
VerificationType::reference_check(), CHECK_VERIFY(this));
if (type == VerificationType::uninitialized_this_type()) {
// The method must be an <init> method of this class or its superclass
Klass* superk = current_class()->super();
! if (ref_class_type.name() != current_class()->name() &&
! ref_class_type.name() != superk->name()) {
verify_error(ErrorContext::bad_type(bci,
TypeOrigin::implicit(ref_class_type),
TypeOrigin::implicit(current_type())),
"Bad <init> method call");
return;
--- 2446,2457 ----
VerificationType type = current_frame->pop_stack(
VerificationType::reference_check(), CHECK_VERIFY(this));
if (type == VerificationType::uninitialized_this_type()) {
// The method must be an <init> method of this class or its superclass
Klass* superk = current_class()->super();
! if (ref_class_type.name()->not_equals(current_class()->name()) &&
! ref_class_type.name()->not_equals(superk->name())) {
verify_error(ErrorContext::bad_type(bci,
TypeOrigin::implicit(ref_class_type),
TypeOrigin::implicit(current_type())),
"Bad <init> method call");
return;
*** 2692,2702 ****
}
if (method_name->byte_at(0) == '<') {
// Make sure <init> can only be invoked by invokespecial
if (opcode != Bytecodes::_invokespecial ||
! method_name != vmSymbols::object_initializer_name()) {
verify_error(ErrorContext::bad_code(bci),
"Illegal call to internal method");
return;
}
} else if (opcode == Bytecodes::_invokespecial
--- 2692,2702 ----
}
if (method_name->byte_at(0) == '<') {
// Make sure <init> can only be invoked by invokespecial
if (opcode != Bytecodes::_invokespecial ||
! method_name->not_equals(vmSymbols::object_initializer_name())) {
verify_error(ErrorContext::bad_code(bci),
"Illegal call to internal method");
return;
}
} else if (opcode == Bytecodes::_invokespecial
*** 2738,2748 ****
current_frame->pop_stack(sig_types[i], CHECK_VERIFY(this));
}
// Check objectref on operand stack
if (opcode != Bytecodes::_invokestatic &&
opcode != Bytecodes::_invokedynamic) {
! if (method_name == vmSymbols::object_initializer_name()) { // <init> method
verify_invoke_init(bcs, index, ref_class_type, current_frame,
code_length, in_try_block, this_uninit, cp, stackmap_table,
CHECK_VERIFY(this));
} else { // other methods
// Ensures that target class is assignable to method class.
--- 2738,2748 ----
current_frame->pop_stack(sig_types[i], CHECK_VERIFY(this));
}
// Check objectref on operand stack
if (opcode != Bytecodes::_invokestatic &&
opcode != Bytecodes::_invokedynamic) {
! if (method_name->equals(vmSymbols::object_initializer_name())) { // <init> method
verify_invoke_init(bcs, index, ref_class_type, current_frame,
code_length, in_try_block, this_uninit, cp, stackmap_table,
CHECK_VERIFY(this));
} else { // other methods
// Ensures that target class is assignable to method class.
*** 2781,2793 ****
// It's protected access, check if stack object is
// assignable to current class.
bool is_assignable = current_type().is_assignable_from(
stack_object_type, this, true, CHECK_VERIFY(this));
if (!is_assignable) {
! if (ref_class_type.name() == vmSymbols::java_lang_Object()
&& stack_object_type.is_array()
! && method_name == vmSymbols::clone_name()) {
// Special case: arrays pretend to implement public Object
// clone().
} else {
verify_error(ErrorContext::bad_type(bci,
current_frame->stack_top_ctx(),
--- 2781,2793 ----
// It's protected access, check if stack object is
// assignable to current class.
bool is_assignable = current_type().is_assignable_from(
stack_object_type, this, true, CHECK_VERIFY(this));
if (!is_assignable) {
! if (ref_class_type.name()->equals(vmSymbols::java_lang_Object())
&& stack_object_type.is_array()
! && method_name->equals(vmSymbols::clone_name())) {
// Special case: arrays pretend to implement public Object
// clone().
} else {
verify_error(ErrorContext::bad_type(bci,
current_frame->stack_top_ctx(),
*** 2805,2815 ****
}
}
}
// Push the result type.
if (sig_stream.type() != T_VOID) {
! if (method_name == vmSymbols::object_initializer_name()) {
// <init> method must have a void return type
/* Unreachable? Class file parser verifies that methods with '<' have
* void return */
verify_error(ErrorContext::bad_code(bci),
"Return type must be void in <init> method");
--- 2805,2815 ----
}
}
}
// Push the result type.
if (sig_stream.type() != T_VOID) {
! if (method_name->equals(vmSymbols::object_initializer_name())) {
// <init> method must have a void return type
/* Unreachable? Class file parser verifies that methods with '<' have
* void return */
verify_error(ErrorContext::bad_code(bci),
"Return type must be void in <init> method");
*** 2974,2984 ****
}
// The verifier creates symbols which are substrings of Symbols.
// These are stored in the verifier until the end of verification so that
// they can be reference counted.
! Symbol* ClassVerifier::create_temporary_symbol(const Symbol *s, int begin,
int end, TRAPS) {
Symbol* sym = SymbolTable::new_symbol(s, begin, end, CHECK_NULL);
_symbols->push(sym);
return sym;
}
--- 2974,2984 ----
}
// The verifier creates symbols which are substrings of Symbols.
// These are stored in the verifier until the end of verification so that
// they can be reference counted.
! Symbol* ClassVerifier::create_temporary_symbol(const Symbol* s, int begin,
int end, TRAPS) {
Symbol* sym = SymbolTable::new_symbol(s, begin, end, CHECK_NULL);
_symbols->push(sym);
return sym;
}
src/share/vm/classfile/verifier.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File