1 /* |
1 /* |
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
1544 return; |
1544 return; |
1545 } |
1545 } |
1546 no_control_flow = true; break; |
1546 no_control_flow = true; break; |
1547 case Bytecodes::_getstatic : |
1547 case Bytecodes::_getstatic : |
1548 case Bytecodes::_putstatic : |
1548 case Bytecodes::_putstatic : |
|
1549 // pass TRUE, operand can be an array type for getstatic/putstatic. |
|
1550 verify_field_instructions( |
|
1551 &bcs, ¤t_frame, cp, true, CHECK_VERIFY(this)); |
|
1552 no_control_flow = false; break; |
1549 case Bytecodes::_getfield : |
1553 case Bytecodes::_getfield : |
1550 case Bytecodes::_putfield : |
1554 case Bytecodes::_putfield : |
|
1555 // pass FALSE, operand can't be an array type for getfield/putfield. |
1551 verify_field_instructions( |
1556 verify_field_instructions( |
1552 &bcs, ¤t_frame, cp, CHECK_VERIFY(this)); |
1557 &bcs, ¤t_frame, cp, false, CHECK_VERIFY(this)); |
1553 no_control_flow = false; break; |
1558 no_control_flow = false; break; |
1554 case Bytecodes::_invokevirtual : |
1559 case Bytecodes::_invokevirtual : |
1555 case Bytecodes::_invokespecial : |
1560 case Bytecodes::_invokespecial : |
1556 case Bytecodes::_invokestatic : |
1561 case Bytecodes::_invokestatic : |
1557 verify_invoke_instructions( |
1562 verify_invoke_instructions( |
2105 } |
2110 } |
2106 |
2111 |
2107 void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs, |
2112 void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs, |
2108 StackMapFrame* current_frame, |
2113 StackMapFrame* current_frame, |
2109 constantPoolHandle cp, |
2114 constantPoolHandle cp, |
|
2115 bool allow_arrays, |
2110 TRAPS) { |
2116 TRAPS) { |
2111 u2 index = bcs->get_index_u2(); |
2117 u2 index = bcs->get_index_u2(); |
2112 verify_cp_type(bcs->bci(), index, cp, |
2118 verify_cp_type(bcs->bci(), index, cp, |
2113 1 << JVM_CONSTANT_Fieldref, CHECK_VERIFY(this)); |
2119 1 << JVM_CONSTANT_Fieldref, CHECK_VERIFY(this)); |
2114 |
2120 |
2124 } |
2130 } |
2125 |
2131 |
2126 // Get referenced class type |
2132 // Get referenced class type |
2127 VerificationType ref_class_type = cp_ref_index_to_type( |
2133 VerificationType ref_class_type = cp_ref_index_to_type( |
2128 index, cp, CHECK_VERIFY(this)); |
2134 index, cp, CHECK_VERIFY(this)); |
2129 if (!ref_class_type.is_object()) { |
2135 if (!ref_class_type.is_object() && |
2130 /* Unreachable? Class file parser verifies Fieldref contents */ |
2136 (!allow_arrays || !ref_class_type.is_array())) { |
2131 verify_error(ErrorContext::bad_type(bcs->bci(), |
2137 verify_error(ErrorContext::bad_type(bcs->bci(), |
2132 TypeOrigin::cp(index, ref_class_type)), |
2138 TypeOrigin::cp(index, ref_class_type)), |
2133 "Expecting reference to class in class %s at constant pool index %d", |
2139 "Expecting reference to class in class %s at constant pool index %d", |
2134 _klass->external_name(), index); |
2140 _klass->external_name(), index); |
2135 return; |
2141 return; |