mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-03 15:08:24 +00:00
8055146: Split Verifier incorrectly throws VerifyError for getstatic of an array field
Allow fieldClass for getstatic and putstatic to be an array Reviewed-by: dholmes, acorn
This commit is contained in:
parent
77f22c1241
commit
4e980350ca
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2015, 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
|
||||
@ -1546,10 +1546,15 @@ void ClassVerifier::verify_method(methodHandle m, TRAPS) {
|
||||
no_control_flow = true; break;
|
||||
case Bytecodes::_getstatic :
|
||||
case Bytecodes::_putstatic :
|
||||
// pass TRUE, operand can be an array type for getstatic/putstatic.
|
||||
verify_field_instructions(
|
||||
&bcs, ¤t_frame, cp, true, CHECK_VERIFY(this));
|
||||
no_control_flow = false; break;
|
||||
case Bytecodes::_getfield :
|
||||
case Bytecodes::_putfield :
|
||||
// pass FALSE, operand can't be an array type for getfield/putfield.
|
||||
verify_field_instructions(
|
||||
&bcs, ¤t_frame, cp, CHECK_VERIFY(this));
|
||||
&bcs, ¤t_frame, cp, false, CHECK_VERIFY(this));
|
||||
no_control_flow = false; break;
|
||||
case Bytecodes::_invokevirtual :
|
||||
case Bytecodes::_invokespecial :
|
||||
@ -2107,6 +2112,7 @@ bool ClassVerifier::name_in_supers(
|
||||
void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
|
||||
StackMapFrame* current_frame,
|
||||
constantPoolHandle cp,
|
||||
bool allow_arrays,
|
||||
TRAPS) {
|
||||
u2 index = bcs->get_index_u2();
|
||||
verify_cp_type(bcs->bci(), index, cp,
|
||||
@ -2126,8 +2132,8 @@ void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
|
||||
// Get referenced class type
|
||||
VerificationType ref_class_type = cp_ref_index_to_type(
|
||||
index, cp, CHECK_VERIFY(this));
|
||||
if (!ref_class_type.is_object()) {
|
||||
/* Unreachable? Class file parser verifies Fieldref contents */
|
||||
if (!ref_class_type.is_object() &&
|
||||
(!allow_arrays || !ref_class_type.is_array())) {
|
||||
verify_error(ErrorContext::bad_type(bcs->bci(),
|
||||
TypeOrigin::cp(index, ref_class_type)),
|
||||
"Expecting reference to class in class %s at constant pool index %d",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2015, 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
|
||||
@ -297,7 +297,7 @@ class ClassVerifier : public StackObj {
|
||||
|
||||
void verify_field_instructions(
|
||||
RawBytecodeStream* bcs, StackMapFrame* current_frame,
|
||||
constantPoolHandle cp, TRAPS);
|
||||
constantPoolHandle cp, bool allow_arrays, TRAPS);
|
||||
|
||||
void verify_invoke_init(
|
||||
RawBytecodeStream* bcs, u2 ref_index, VerificationType ref_class_type,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user