--- a/hotspot/src/share/vm/classfile/verifier.cpp Wed Jan 14 15:57:59 2015 +0100
+++ b/hotspot/src/share/vm/classfile/verifier.cpp Wed Jan 14 15:25:13 2015 +0000
@@ -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 @@
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 @@
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 @@
// 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",
--- a/hotspot/src/share/vm/classfile/verifier.hpp Wed Jan 14 15:57:59 2015 +0100
+++ b/hotspot/src/share/vm/classfile/verifier.hpp Wed Jan 14 15:25:13 2015 +0000
@@ -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 @@
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,