src/share/vm/runtime/reflectionUtils.hpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2005, 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  *
  23  */
  24 












  25 // A KlassStream is an abstract stream for streaming over self, superclasses
  26 // and (super)interfaces. Streaming is done in reverse order (subclasses first,
  27 // interfaces last).
  28 //
  29 //    for (KlassStream st(k, false, false); !st.eos(); st.next()) {
  30 //      klassOop k = st.klass();
  31 //      ...
  32 //    }
  33 
  34 class KlassStream VALUE_OBJ_CLASS_SPEC {
  35  protected:
  36   instanceKlassHandle _klass;           // current klass/interface iterated over
  37   objArrayHandle      _interfaces;      // transitive interfaces for initial class
  38   int                 _interface_index; // current interface being processed
  39   bool                _local_only;      // process initial class/interface only
  40   bool                _classes_only;    // process classes only (no interfaces)
  41   int                 _index;
  42 
  43   virtual int length() const = 0;
  44 


 192 class FilteredFieldStream : public FieldStream {
 193  private:
 194   int  _filtered_fields_count;
 195   bool has_filtered_field() { return (_filtered_fields_count > 0); }
 196 
 197  public:
 198   FilteredFieldStream(instanceKlassHandle klass, bool local_only, bool classes_only)
 199     : FieldStream(klass, local_only, classes_only) {
 200     _filtered_fields_count = FilteredFieldsMap::filtered_fields_count((klassOop)klass(), local_only);
 201   }
 202   int field_count();
 203   void next() {
 204     _index -= instanceKlass::next_offset;
 205     if (has_filtered_field()) {
 206       while (_index >=0 && FilteredFieldsMap::is_filtered_field((klassOop)_klass(), offset())) {
 207         _index -= instanceKlass::next_offset;
 208       }
 209     }
 210   }
 211 };


   1 /*
   2  * Copyright (c) 1999, 2010, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_REFLECTIONUTILS_HPP
  26 #define SHARE_VM_RUNTIME_REFLECTIONUTILS_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "oops/instanceKlass.hpp"
  30 #include "oops/objArrayOop.hpp"
  31 #include "oops/oopsHierarchy.hpp"
  32 #include "runtime/handles.inline.hpp"
  33 #include "runtime/reflection.hpp"
  34 #include "utilities/accessFlags.hpp"
  35 #include "utilities/globalDefinitions.hpp"
  36 
  37 // A KlassStream is an abstract stream for streaming over self, superclasses
  38 // and (super)interfaces. Streaming is done in reverse order (subclasses first,
  39 // interfaces last).
  40 //
  41 //    for (KlassStream st(k, false, false); !st.eos(); st.next()) {
  42 //      klassOop k = st.klass();
  43 //      ...
  44 //    }
  45 
  46 class KlassStream VALUE_OBJ_CLASS_SPEC {
  47  protected:
  48   instanceKlassHandle _klass;           // current klass/interface iterated over
  49   objArrayHandle      _interfaces;      // transitive interfaces for initial class
  50   int                 _interface_index; // current interface being processed
  51   bool                _local_only;      // process initial class/interface only
  52   bool                _classes_only;    // process classes only (no interfaces)
  53   int                 _index;
  54 
  55   virtual int length() const = 0;
  56 


 204 class FilteredFieldStream : public FieldStream {
 205  private:
 206   int  _filtered_fields_count;
 207   bool has_filtered_field() { return (_filtered_fields_count > 0); }
 208 
 209  public:
 210   FilteredFieldStream(instanceKlassHandle klass, bool local_only, bool classes_only)
 211     : FieldStream(klass, local_only, classes_only) {
 212     _filtered_fields_count = FilteredFieldsMap::filtered_fields_count((klassOop)klass(), local_only);
 213   }
 214   int field_count();
 215   void next() {
 216     _index -= instanceKlass::next_offset;
 217     if (has_filtered_field()) {
 218       while (_index >=0 && FilteredFieldsMap::is_filtered_field((klassOop)_klass(), offset())) {
 219         _index -= instanceKlass::next_offset;
 220       }
 221     }
 222   }
 223 };
 224 
 225 #endif // SHARE_VM_RUNTIME_REFLECTIONUTILS_HPP