0N/A/*
1879N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "classfile/javaClasses.hpp"
1879N/A#include "memory/universe.inline.hpp"
1879N/A#include "runtime/reflectionUtils.hpp"
0N/A
0N/AKlassStream::KlassStream(instanceKlassHandle klass, bool local_only, bool classes_only) {
0N/A _klass = klass;
0N/A if (classes_only) {
0N/A _interfaces = Universe::the_empty_system_obj_array();
0N/A } else {
0N/A _interfaces = klass->transitive_interfaces();
0N/A }
0N/A _interface_index = _interfaces->length();
0N/A _local_only = local_only;
0N/A _classes_only = classes_only;
0N/A}
0N/A
0N/Abool KlassStream::eos() {
0N/A if (index() >= 0) return false;
0N/A if (_local_only) return true;
0N/A if (!_klass->is_interface() && _klass->super() != NULL) {
0N/A // go up superclass chain (not for interfaces)
0N/A _klass = _klass->super();
0N/A } else {
0N/A if (_interface_index > 0) {
0N/A _klass = klassOop(_interfaces->obj_at(--_interface_index));
0N/A } else {
0N/A return true;
0N/A }
0N/A }
0N/A _index = length();
0N/A next();
0N/A return eos();
0N/A}
0N/A
0N/A
0N/AGrowableArray<FilteredField*> *FilteredFieldsMap::_filtered_fields =
3863N/A new (ResourceObj::C_HEAP, mtInternal) GrowableArray<FilteredField*>(3,true);
0N/A
0N/A
0N/Avoid FilteredFieldsMap::initialize() {
0N/A int offset;
0N/A offset = java_lang_Throwable::get_backtrace_offset();
1142N/A _filtered_fields->append(new FilteredField(SystemDictionary::Throwable_klass(), offset));
0N/A // The latest version of vm may be used with old jdk.
0N/A if (JDK_Version::is_gte_jdk16x_version()) {
0N/A // The following class fields do not exist in
0N/A // previous version of jdk.
0N/A offset = sun_reflect_ConstantPool::cp_oop_offset();
1142N/A _filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset));
0N/A offset = sun_reflect_UnsafeStaticFieldAccessorImpl::base_offset();
1142N/A _filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset));
0N/A }
0N/A}
0N/A
0N/Aint FilteredFieldStream::field_count() {
0N/A int numflds = 0;
0N/A for (;!eos(); next()) {
0N/A numflds++;
0N/A }
0N/A return numflds;
0N/A}