1 /* |
1 /* |
2 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "classfile/javaClasses.hpp" |
26 #include "classfile/javaClasses.hpp" |
27 #include "memory/universe.inline.hpp" |
27 #include "memory/universe.inline.hpp" |
28 #include "runtime/reflectionUtils.hpp" |
28 #include "runtime/reflectionUtils.hpp" |
29 |
29 |
30 KlassStream::KlassStream(instanceKlassHandle klass, bool local_only, |
30 KlassStream::KlassStream(InstanceKlass* klass, bool local_only, |
31 bool classes_only, bool walk_defaults) { |
31 bool classes_only, bool walk_defaults) { |
32 _klass = _base_klass = klass; |
32 _klass = _base_klass = klass; |
33 _base_class_search_defaults = false; |
33 _base_class_search_defaults = false; |
34 _defaults_checked = false; |
34 _defaults_checked = false; |
35 if (classes_only) { |
35 if (classes_only) { |
46 bool KlassStream::eos() { |
46 bool KlassStream::eos() { |
47 if (index() >= 0) return false; |
47 if (index() >= 0) return false; |
48 if (_local_only) return true; |
48 if (_local_only) return true; |
49 if (!_klass->is_interface() && _klass->super() != NULL) { |
49 if (!_klass->is_interface() && _klass->super() != NULL) { |
50 // go up superclass chain (not for interfaces) |
50 // go up superclass chain (not for interfaces) |
51 _klass = _klass->super(); |
51 _klass = InstanceKlass::cast(_klass->super()); |
52 // Next for method walks, walk default methods |
52 // Next for method walks, walk default methods |
53 } else if (_walk_defaults && (_defaults_checked == false) && (_base_klass->default_methods() != NULL)) { |
53 } else if (_walk_defaults && (_defaults_checked == false) && (_base_klass->default_methods() != NULL)) { |
54 _base_class_search_defaults = true; |
54 _base_class_search_defaults = true; |
55 _klass = _base_klass; |
55 _klass = _base_klass; |
56 _defaults_checked = true; |
56 _defaults_checked = true; |
57 } else { |
57 } else { |
58 // Next walk transitive interfaces |
58 // Next walk transitive interfaces |
59 if (_interface_index > 0) { |
59 if (_interface_index > 0) { |
60 _klass = _interfaces->at(--_interface_index); |
60 _klass = InstanceKlass::cast(_interfaces->at(--_interface_index)); |
61 } else { |
61 } else { |
62 return true; |
62 return true; |
63 } |
63 } |
64 } |
64 } |
65 _index = length(); |
65 _index = length(); |