/* * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// A KlassStream is an abstract stream for streaming over self, superclasses // and (super)interfaces. Streaming is done in reverse order (subclasses first, // interfaces last). // // for (KlassStream st(k, false, false, false); !st.eos(); st.next()) { // Klass* k = st.klass(); // ... // }
class KlassStream { protected:
InstanceKlass* _klass; // current klass/interface iterated over
InstanceKlass* _base_klass; // initial klass/interface to iterate over
Array<InstanceKlass*>*_interfaces; // transitive interfaces for initial class int _interface_index; // current interface being processed bool _local_only; // process initial class/interface only bool _classes_only; // process classes only (no interfaces) bool _walk_defaults; // process default methods bool _base_class_search_defaults; // time to process default methods bool _defaults_checked; // already checked for default methods int _index;
// A MethodStream streams over all methods in a class, superclasses and (super)interfaces. // Streaming is done in reverse order (subclasses first, methods in reverse order) // Usage: // // for (MethodStream st(k, false, false); !st.eos(); st.next()) { // Method* m = st.method(); // ... // }
// A FieldStream streams over all fields in a class, superclasses and (super)interfaces. // Streaming is done in reverse order (subclasses first, fields in reverse order) // Usage: // // for (FieldStream st(k, false, false); !st.eos(); st.next()) { // Symbol* field_name = st.name(); // ... // }
class FieldStream : public KlassStream { private: int length() { return _klass->java_fields_count(); }
class FilteredFieldsMap : AllStatic { private: static GrowableArray<FilteredField *> *_filtered_fields; public: staticvoid initialize(); staticbool is_filtered_field(Klass* klass, int field_offset) { for (int i=0; i < _filtered_fields->length(); i++) { if (klass == _filtered_fields->at(i)->klass() &&
field_offset == _filtered_fields->at(i)->field_offset()) { returntrue;
}
} returnfalse;
} staticint filtered_fields_count(Klass* klass, bool local_only) { int nflds = 0; for (int i=0; i < _filtered_fields->length(); i++) { if (local_only && klass == _filtered_fields->at(i)->klass()) {
nflds++;
} elseif (klass->is_subtype_of(_filtered_fields->at(i)->klass())) {
nflds++;
}
} return nflds;
}
};
// A FilteredFieldStream streams over all fields in a class, superclasses and // (super)interfaces. Streaming is done in reverse order (subclasses first, // fields in reverse order) // // Usage: // // for (FilteredFieldStream st(k, false, false); !st.eos(); st.next()) { // Symbol* field_name = st.name(); // ... // }
class FilteredFieldStream : public FieldStream { private: int _filtered_fields_count; bool has_filtered_field() { return (_filtered_fields_count > 0); }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.