1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
697
698 // Sizing
699 int length() const { return _length; }
700 void set_length(int length) { _length = length; }
701
702 // Tells whether index is within bounds.
703 bool is_within_bounds(int index) const {
704 return 0 <= index && index < length();
705 }
706
707 // Sizing (in words)
708 static int header_size() { return sizeof(ConstantPool)/wordSize; }
709 static int size(int length) { return align_metadata_size(header_size() + length); }
710 int size() const { return size(length()); }
711 #if INCLUDE_SERVICES
712 void collect_statistics(KlassSizeStats *sz) const;
713 #endif
714
715 friend class ClassFileParser;
716 friend class SystemDictionary;
717
718 // Used by compiler to prevent classloading.
719 static Method* method_at_if_loaded (const constantPoolHandle& this_cp, int which);
720 static bool has_appendix_at_if_loaded (const constantPoolHandle& this_cp, int which);
721 static oop appendix_at_if_loaded (const constantPoolHandle& this_cp, int which);
722 static bool has_method_type_at_if_loaded (const constantPoolHandle& this_cp, int which);
723 static oop method_type_at_if_loaded (const constantPoolHandle& this_cp, int which);
724 static Klass* klass_at_if_loaded (const constantPoolHandle& this_cp, int which);
725 static Klass* klass_ref_at_if_loaded (const constantPoolHandle& this_cp, int which);
726
727 // Routines currently used for annotations (only called by jvm.cpp) but which might be used in the
728 // future by other Java code. These take constant pool indices rather than
729 // constant pool cache indices as do the peer methods above.
730 Symbol* uncached_klass_ref_at_noresolve(int which);
731 Symbol* uncached_name_ref_at(int which) { return impl_name_ref_at(which, true); }
732 Symbol* uncached_signature_ref_at(int which) { return impl_signature_ref_at(which, true); }
733 int uncached_klass_ref_index_at(int which) { return impl_klass_ref_index_at(which, true); }
734 int uncached_name_and_type_ref_index_at(int which) { return impl_name_and_type_ref_index_at(which, true); }
735
736 // Sharing
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
697
698 // Sizing
699 int length() const { return _length; }
700 void set_length(int length) { _length = length; }
701
702 // Tells whether index is within bounds.
703 bool is_within_bounds(int index) const {
704 return 0 <= index && index < length();
705 }
706
707 // Sizing (in words)
708 static int header_size() { return sizeof(ConstantPool)/wordSize; }
709 static int size(int length) { return align_metadata_size(header_size() + length); }
710 int size() const { return size(length()); }
711 #if INCLUDE_SERVICES
712 void collect_statistics(KlassSizeStats *sz) const;
713 #endif
714
715 friend class ClassFileParser;
716 friend class SystemDictionary;
717 template <class T> friend class CppVtabTesterA; // See metaspaceShared.cpp
718 template <class T> friend class CppVtabTesterB;
719 template <class T> friend class CppVtabCloner;
720
721 // Used by compiler to prevent classloading.
722 static Method* method_at_if_loaded (const constantPoolHandle& this_cp, int which);
723 static bool has_appendix_at_if_loaded (const constantPoolHandle& this_cp, int which);
724 static oop appendix_at_if_loaded (const constantPoolHandle& this_cp, int which);
725 static bool has_method_type_at_if_loaded (const constantPoolHandle& this_cp, int which);
726 static oop method_type_at_if_loaded (const constantPoolHandle& this_cp, int which);
727 static Klass* klass_at_if_loaded (const constantPoolHandle& this_cp, int which);
728 static Klass* klass_ref_at_if_loaded (const constantPoolHandle& this_cp, int which);
729
730 // Routines currently used for annotations (only called by jvm.cpp) but which might be used in the
731 // future by other Java code. These take constant pool indices rather than
732 // constant pool cache indices as do the peer methods above.
733 Symbol* uncached_klass_ref_at_noresolve(int which);
734 Symbol* uncached_name_ref_at(int which) { return impl_name_ref_at(which, true); }
735 Symbol* uncached_signature_ref_at(int which) { return impl_signature_ref_at(which, true); }
736 int uncached_klass_ref_index_at(int which) { return impl_klass_ref_index_at(which, true); }
737 int uncached_name_and_type_ref_index_at(int which) { return impl_name_and_type_ref_index_at(which, true); }
738
739 // Sharing
|