author | pliden |
Fri, 11 Apr 2014 12:29:24 +0200 | |
changeset 24094 | 5dbf1f44de18 |
parent 20391 | 7b146c5ebb18 |
child 25057 | f38210f84f8c |
permissions | -rw-r--r-- |
1 | 1 |
/* |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
2 |
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/javaClasses.hpp" |
|
27 |
#include "memory/universe.inline.hpp" |
|
28 |
#include "runtime/reflectionUtils.hpp" |
|
1 | 29 |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
30 |
KlassStream::KlassStream(instanceKlassHandle klass, bool local_only, |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
31 |
bool classes_only, bool walk_defaults) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
32 |
_klass = _base_klass = klass; |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
33 |
_base_class_search_defaults = false; |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
34 |
_defaults_checked = false; |
1 | 35 |
if (classes_only) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
36 |
_interfaces = Universe::the_empty_klass_array(); |
1 | 37 |
} else { |
38 |
_interfaces = klass->transitive_interfaces(); |
|
39 |
} |
|
40 |
_interface_index = _interfaces->length(); |
|
41 |
_local_only = local_only; |
|
42 |
_classes_only = classes_only; |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
43 |
_walk_defaults = walk_defaults; |
1 | 44 |
} |
45 |
||
46 |
bool KlassStream::eos() { |
|
47 |
if (index() >= 0) return false; |
|
48 |
if (_local_only) return true; |
|
49 |
if (!_klass->is_interface() && _klass->super() != NULL) { |
|
50 |
// go up superclass chain (not for interfaces) |
|
51 |
_klass = _klass->super(); |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
52 |
// Next for method walks, walk default methods |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
53 |
} else if (_walk_defaults && (_defaults_checked == false) && (_base_klass->default_methods() != NULL)) { |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
54 |
_base_class_search_defaults = true; |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
55 |
_klass = _base_klass; |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
56 |
_defaults_checked = true; |
1 | 57 |
} else { |
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
13728
diff
changeset
|
58 |
// Next walk transitive interfaces |
1 | 59 |
if (_interface_index > 0) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
60 |
_klass = _interfaces->at(--_interface_index); |
1 | 61 |
} else { |
62 |
return true; |
|
63 |
} |
|
64 |
} |
|
65 |
_index = length(); |
|
66 |
next(); |
|
67 |
return eos(); |
|
68 |
} |
|
69 |
||
70 |
||
71 |
GrowableArray<FilteredField*> *FilteredFieldsMap::_filtered_fields = |
|
13195 | 72 |
new (ResourceObj::C_HEAP, mtInternal) GrowableArray<FilteredField*>(3,true); |
1 | 73 |
|
74 |
||
75 |
void FilteredFieldsMap::initialize() { |
|
76 |
int offset; |
|
77 |
offset = java_lang_Throwable::get_backtrace_offset(); |
|
4571 | 78 |
_filtered_fields->append(new FilteredField(SystemDictionary::Throwable_klass(), offset)); |
1 | 79 |
// The latest version of vm may be used with old jdk. |
80 |
if (JDK_Version::is_gte_jdk16x_version()) { |
|
81 |
// The following class fields do not exist in |
|
82 |
// previous version of jdk. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
83 |
offset = sun_reflect_ConstantPool::oop_offset(); |
4571 | 84 |
_filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset)); |
1 | 85 |
offset = sun_reflect_UnsafeStaticFieldAccessorImpl::base_offset(); |
4571 | 86 |
_filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset)); |
1 | 87 |
} |
88 |
} |
|
89 |
||
90 |
int FilteredFieldStream::field_count() { |
|
91 |
int numflds = 0; |
|
92 |
for (;!eos(); next()) { |
|
93 |
numflds++; |
|
94 |
} |
|
95 |
return numflds; |
|
96 |
} |