# HG changeset patch # User drchase # Date 1401733949 14400 # Node ID 0b9500028980e196e6246350f877c5657109af03 # Parent 8e20ef014b08e25607f2bc52f8affadc1ba433de 8029381: assert(is_method_type()) failed: bad cast Summary: Access to method_type and appendix from constant pool (cpcache) needs to be guarded by is_f1_null() because of racy update/initialization. Reviewed-by: kvn, coleenp, jrose diff -r 8e20ef014b08 -r 0b9500028980 src/share/vm/oops/cpCache.cpp --- a/src/share/vm/oops/cpCache.cpp Wed Jun 11 10:46:47 2014 +0200 +++ b/src/share/vm/oops/cpCache.cpp Mon Jun 02 14:32:29 2014 -0400 @@ -406,7 +406,7 @@ oop ConstantPoolCacheEntry::appendix_if_resolved(constantPoolHandle cpool) { - if (is_f1_null() || !has_appendix()) + if (!has_appendix()) return NULL; const int ref_index = f2_as_index() + _indy_resolved_references_appendix_offset; objArrayOop resolved_references = cpool->resolved_references(); @@ -415,7 +415,7 @@ oop ConstantPoolCacheEntry::method_type_if_resolved(constantPoolHandle cpool) { - if (is_f1_null() || !has_method_type()) + if (!has_method_type()) return NULL; const int ref_index = f2_as_index() + _indy_resolved_references_method_type_offset; objArrayOop resolved_references = cpool->resolved_references(); diff -r 8e20ef014b08 -r 0b9500028980 src/share/vm/oops/cpCache.hpp --- a/src/share/vm/oops/cpCache.hpp Wed Jun 11 10:46:47 2014 +0200 +++ b/src/share/vm/oops/cpCache.hpp Mon Jun 02 14:32:29 2014 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -346,8 +346,8 @@ bool is_final() const { return (_flags & (1 << is_final_shift)) != 0; } bool is_forced_virtual() const { return (_flags & (1 << is_forced_virtual_shift)) != 0; } bool is_vfinal() const { return (_flags & (1 << is_vfinal_shift)) != 0; } - bool has_appendix() const { return (_flags & (1 << has_appendix_shift)) != 0; } - bool has_method_type() const { return (_flags & (1 << has_method_type_shift)) != 0; } + bool has_appendix() const { return (!is_f1_null()) && (_flags & (1 << has_appendix_shift)) != 0; } + bool has_method_type() const { return (!is_f1_null()) && (_flags & (1 << has_method_type_shift)) != 0; } bool is_method_entry() const { return (_flags & (1 << is_field_entry_shift)) == 0; } bool is_field_entry() const { return (_flags & (1 << is_field_entry_shift)) != 0; } bool is_byte() const { return flag_state() == btos; }