Wed, 27 Apr 2016 01:25:04 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #include "precompiled.hpp" |
aoqi@0 | 26 | #include "classfile/javaClasses.hpp" |
aoqi@0 | 27 | #include "memory/universe.inline.hpp" |
aoqi@0 | 28 | #include "runtime/reflectionUtils.hpp" |
aoqi@0 | 29 | |
aoqi@0 | 30 | KlassStream::KlassStream(instanceKlassHandle klass, bool local_only, |
aoqi@0 | 31 | bool classes_only, bool walk_defaults) { |
aoqi@0 | 32 | _klass = _base_klass = klass; |
aoqi@0 | 33 | _base_class_search_defaults = false; |
aoqi@0 | 34 | _defaults_checked = false; |
aoqi@0 | 35 | if (classes_only) { |
aoqi@0 | 36 | _interfaces = Universe::the_empty_klass_array(); |
aoqi@0 | 37 | } else { |
aoqi@0 | 38 | _interfaces = klass->transitive_interfaces(); |
aoqi@0 | 39 | } |
aoqi@0 | 40 | _interface_index = _interfaces->length(); |
aoqi@0 | 41 | _local_only = local_only; |
aoqi@0 | 42 | _classes_only = classes_only; |
aoqi@0 | 43 | _walk_defaults = walk_defaults; |
aoqi@0 | 44 | } |
aoqi@0 | 45 | |
aoqi@0 | 46 | bool KlassStream::eos() { |
aoqi@0 | 47 | if (index() >= 0) return false; |
aoqi@0 | 48 | if (_local_only) return true; |
aoqi@0 | 49 | if (!_klass->is_interface() && _klass->super() != NULL) { |
aoqi@0 | 50 | // go up superclass chain (not for interfaces) |
aoqi@0 | 51 | _klass = _klass->super(); |
aoqi@0 | 52 | // Next for method walks, walk default methods |
aoqi@0 | 53 | } else if (_walk_defaults && (_defaults_checked == false) && (_base_klass->default_methods() != NULL)) { |
aoqi@0 | 54 | _base_class_search_defaults = true; |
aoqi@0 | 55 | _klass = _base_klass; |
aoqi@0 | 56 | _defaults_checked = true; |
aoqi@0 | 57 | } else { |
aoqi@0 | 58 | // Next walk transitive interfaces |
aoqi@0 | 59 | if (_interface_index > 0) { |
aoqi@0 | 60 | _klass = _interfaces->at(--_interface_index); |
aoqi@0 | 61 | } else { |
aoqi@0 | 62 | return true; |
aoqi@0 | 63 | } |
aoqi@0 | 64 | } |
aoqi@0 | 65 | _index = length(); |
aoqi@0 | 66 | next(); |
aoqi@0 | 67 | return eos(); |
aoqi@0 | 68 | } |
aoqi@0 | 69 | |
aoqi@0 | 70 | |
aoqi@0 | 71 | GrowableArray<FilteredField*> *FilteredFieldsMap::_filtered_fields = |
aoqi@0 | 72 | new (ResourceObj::C_HEAP, mtInternal) GrowableArray<FilteredField*>(3,true); |
aoqi@0 | 73 | |
aoqi@0 | 74 | |
aoqi@0 | 75 | void FilteredFieldsMap::initialize() { |
aoqi@0 | 76 | int offset; |
aoqi@0 | 77 | offset = java_lang_Throwable::get_backtrace_offset(); |
aoqi@0 | 78 | _filtered_fields->append(new FilteredField(SystemDictionary::Throwable_klass(), offset)); |
aoqi@0 | 79 | // The latest version of vm may be used with old jdk. |
aoqi@0 | 80 | if (JDK_Version::is_gte_jdk16x_version()) { |
aoqi@0 | 81 | // The following class fields do not exist in |
aoqi@0 | 82 | // previous version of jdk. |
aoqi@0 | 83 | offset = sun_reflect_ConstantPool::oop_offset(); |
aoqi@0 | 84 | _filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset)); |
aoqi@0 | 85 | offset = sun_reflect_UnsafeStaticFieldAccessorImpl::base_offset(); |
aoqi@0 | 86 | _filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset)); |
aoqi@0 | 87 | } |
aoqi@0 | 88 | } |
aoqi@0 | 89 | |
aoqi@0 | 90 | int FilteredFieldStream::field_count() { |
aoqi@0 | 91 | int numflds = 0; |
aoqi@0 | 92 | for (;!eos(); next()) { |
aoqi@0 | 93 | numflds++; |
aoqi@0 | 94 | } |
aoqi@0 | 95 | return numflds; |
aoqi@0 | 96 | } |