annotate src/share/vm/runtime/reflectionUtils.cpp @ 4559:723df37192d6

Make it possible again to build a real client libjvm, drop the UseGraal flag. Use the --vm option instead of a special -vm option in the bench command
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 10 Feb 2012 17:04:03 +0100
parents f400f9554f09
children 70f715dfbb41
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "classfile/javaClasses.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "memory/universe.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "runtime/reflectionUtils.hpp"
3706
a59727158259 hide HotSpotMethodResolvedImpl.javaMirror field in debuggers
Lukas Stadler <lukas.stadler@jku.at>
parents: 1972
diff changeset
29 #ifdef GRAAL
a59727158259 hide HotSpotMethodResolvedImpl.javaMirror field in debuggers
Lukas Stadler <lukas.stadler@jku.at>
parents: 1972
diff changeset
30 #include "graal/graalJavaAccess.hpp"
a59727158259 hide HotSpotMethodResolvedImpl.javaMirror field in debuggers
Lukas Stadler <lukas.stadler@jku.at>
parents: 1972
diff changeset
31 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 KlassStream::KlassStream(instanceKlassHandle klass, bool local_only, bool classes_only) {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 _klass = klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 if (classes_only) {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 _interfaces = Universe::the_empty_system_obj_array();
a61af66fc99e Initial load
duke
parents:
diff changeset
37 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 _interfaces = klass->transitive_interfaces();
a61af66fc99e Initial load
duke
parents:
diff changeset
39 }
a61af66fc99e Initial load
duke
parents:
diff changeset
40 _interface_index = _interfaces->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
41 _local_only = local_only;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 _classes_only = classes_only;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 bool KlassStream::eos() {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 if (index() >= 0) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 if (_local_only) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 if (!_klass->is_interface() && _klass->super() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // go up superclass chain (not for interfaces)
a61af66fc99e Initial load
duke
parents:
diff changeset
50 _klass = _klass->super();
a61af66fc99e Initial load
duke
parents:
diff changeset
51 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 if (_interface_index > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 _klass = klassOop(_interfaces->obj_at(--_interface_index));
a61af66fc99e Initial load
duke
parents:
diff changeset
54 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58 _index = length();
a61af66fc99e Initial load
duke
parents:
diff changeset
59 next();
a61af66fc99e Initial load
duke
parents:
diff changeset
60 return eos();
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 GrowableArray<FilteredField*> *FilteredFieldsMap::_filtered_fields =
a61af66fc99e Initial load
duke
parents:
diff changeset
65 new (ResourceObj::C_HEAP) GrowableArray<FilteredField*>(3,true);
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 void FilteredFieldsMap::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 offset = java_lang_Throwable::get_backtrace_offset();
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 0
diff changeset
71 _filtered_fields->append(new FilteredField(SystemDictionary::Throwable_klass(), offset));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // The latest version of vm may be used with old jdk.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 if (JDK_Version::is_gte_jdk16x_version()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // The following class fields do not exist in
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // previous version of jdk.
a61af66fc99e Initial load
duke
parents:
diff changeset
76 offset = sun_reflect_ConstantPool::cp_oop_offset();
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 0
diff changeset
77 _filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
78 offset = sun_reflect_UnsafeStaticFieldAccessorImpl::base_offset();
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 0
diff changeset
79 _filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
3706
a59727158259 hide HotSpotMethodResolvedImpl.javaMirror field in debuggers
Lukas Stadler <lukas.stadler@jku.at>
parents: 1972
diff changeset
81 #ifdef GRAAL
4559
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4475
diff changeset
82 compute_offset(offset, SystemDictionary::HotSpotMethodResolved_klass(), "javaMirror", "Ljava/lang/Object;", false);
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4475
diff changeset
83 _filtered_fields->append(new FilteredField(SystemDictionary::HotSpotMethodResolved_klass(), offset));
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4475
diff changeset
84 compute_offset(offset, SystemDictionary::HotSpotMethodData_klass(), "hotspotMirror", "Ljava/lang/Object;", false);
723df37192d6 Make it possible again to build a real client libjvm, drop the UseGraal flag.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4475
diff changeset
85 _filtered_fields->append(new FilteredField(SystemDictionary::HotSpotMethodData_klass(), offset));
3706
a59727158259 hide HotSpotMethodResolvedImpl.javaMirror field in debuggers
Lukas Stadler <lukas.stadler@jku.at>
parents: 1972
diff changeset
86 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 int FilteredFieldStream::field_count() {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 int numflds = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 for (;!eos(); next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 numflds++;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 return numflds;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }