annotate src/share/vm/runtime/reflectionUtils.cpp @ 61:5a76ab815e34

6667833: Remove CacheTimeMillis Summary: Remove -XX:+CacheTimeMillis option and associated functionality Reviewed-by: acorn, never
author sbohne
date Wed, 19 Mar 2008 09:58:01 -0400
parents
children 4ce7240d622c
rev   line source
duke@0 1 /*
duke@0 2 * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 #include "incls/_precompiled.incl"
duke@0 26 #include "incls/_reflectionUtils.cpp.incl"
duke@0 27
duke@0 28 KlassStream::KlassStream(instanceKlassHandle klass, bool local_only, bool classes_only) {
duke@0 29 _klass = klass;
duke@0 30 if (classes_only) {
duke@0 31 _interfaces = Universe::the_empty_system_obj_array();
duke@0 32 } else {
duke@0 33 _interfaces = klass->transitive_interfaces();
duke@0 34 }
duke@0 35 _interface_index = _interfaces->length();
duke@0 36 _local_only = local_only;
duke@0 37 _classes_only = classes_only;
duke@0 38 }
duke@0 39
duke@0 40 bool KlassStream::eos() {
duke@0 41 if (index() >= 0) return false;
duke@0 42 if (_local_only) return true;
duke@0 43 if (!_klass->is_interface() && _klass->super() != NULL) {
duke@0 44 // go up superclass chain (not for interfaces)
duke@0 45 _klass = _klass->super();
duke@0 46 } else {
duke@0 47 if (_interface_index > 0) {
duke@0 48 _klass = klassOop(_interfaces->obj_at(--_interface_index));
duke@0 49 } else {
duke@0 50 return true;
duke@0 51 }
duke@0 52 }
duke@0 53 _index = length();
duke@0 54 next();
duke@0 55 return eos();
duke@0 56 }
duke@0 57
duke@0 58
duke@0 59 GrowableArray<FilteredField*> *FilteredFieldsMap::_filtered_fields =
duke@0 60 new (ResourceObj::C_HEAP) GrowableArray<FilteredField*>(3,true);
duke@0 61
duke@0 62
duke@0 63 void FilteredFieldsMap::initialize() {
duke@0 64 int offset;
duke@0 65 offset = java_lang_Throwable::get_backtrace_offset();
duke@0 66 _filtered_fields->append(new FilteredField(SystemDictionary::throwable_klass(), offset));
duke@0 67 // The latest version of vm may be used with old jdk.
duke@0 68 if (JDK_Version::is_gte_jdk16x_version()) {
duke@0 69 // The following class fields do not exist in
duke@0 70 // previous version of jdk.
duke@0 71 offset = sun_reflect_ConstantPool::cp_oop_offset();
duke@0 72 _filtered_fields->append(new FilteredField(SystemDictionary::reflect_constant_pool_klass(), offset));
duke@0 73 offset = sun_reflect_UnsafeStaticFieldAccessorImpl::base_offset();
duke@0 74 _filtered_fields->append(new FilteredField(SystemDictionary::reflect_unsafe_static_field_accessor_impl_klass(), offset));
duke@0 75 }
duke@0 76 }
duke@0 77
duke@0 78 int FilteredFieldStream::field_count() {
duke@0 79 int numflds = 0;
duke@0 80 for (;!eos(); next()) {
duke@0 81 numflds++;
duke@0 82 }
duke@0 83 return numflds;
duke@0 84 }