src/share/vm/runtime/reflectionUtils.cpp

Tue, 11 May 2010 14:35:43 -0700

author
prr
date
Tue, 11 May 2010 14:35:43 -0700
changeset 1840
fb57d4cf76c2
parent 1577
4ce7240d622c
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6931180: Migration to recent versions of MS Platform SDK
6951582: Build problems on win64
Summary: Changes to enable building JDK7 with Microsoft Visual Studio 2010
Reviewed-by: ohair, art, ccheung, dcubed

     1 /*
     2  * Copyright 1999-2006 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 #include "incls/_precompiled.incl"
    26 #include "incls/_reflectionUtils.cpp.incl"
    28 KlassStream::KlassStream(instanceKlassHandle klass, bool local_only, bool classes_only) {
    29   _klass = klass;
    30   if (classes_only) {
    31     _interfaces = Universe::the_empty_system_obj_array();
    32   } else {
    33     _interfaces = klass->transitive_interfaces();
    34   }
    35   _interface_index = _interfaces->length();
    36   _local_only = local_only;
    37   _classes_only = classes_only;
    38 }
    40 bool KlassStream::eos() {
    41   if (index() >= 0) return false;
    42   if (_local_only) return true;
    43   if (!_klass->is_interface() && _klass->super() != NULL) {
    44     // go up superclass chain (not for interfaces)
    45     _klass = _klass->super();
    46   } else {
    47     if (_interface_index > 0) {
    48       _klass = klassOop(_interfaces->obj_at(--_interface_index));
    49     } else {
    50       return true;
    51     }
    52   }
    53   _index = length();
    54   next();
    55   return eos();
    56 }
    59 GrowableArray<FilteredField*> *FilteredFieldsMap::_filtered_fields =
    60   new (ResourceObj::C_HEAP) GrowableArray<FilteredField*>(3,true);
    63 void FilteredFieldsMap::initialize() {
    64   int offset;
    65   offset = java_lang_Throwable::get_backtrace_offset();
    66   _filtered_fields->append(new FilteredField(SystemDictionary::Throwable_klass(), offset));
    67   // The latest version of vm may be used with old jdk.
    68   if (JDK_Version::is_gte_jdk16x_version()) {
    69     // The following class fields do not exist in
    70     // previous version of jdk.
    71     offset = sun_reflect_ConstantPool::cp_oop_offset();
    72     _filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset));
    73     offset = sun_reflect_UnsafeStaticFieldAccessorImpl::base_offset();
    74     _filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset));
    75   }
    76 }
    78 int FilteredFieldStream::field_count() {
    79   int numflds = 0;
    80   for (;!eos(); next()) {
    81     numflds++;
    82   }
    83   return numflds;
    84 }

mercurial