annotate src/share/vm/runtime/reflection.hpp @ 8804:91bf0bdae37b

8008217: CDS: Class data sharing limits the malloc heap on Solaris Summary: In 64bit VM move CDS archive address to 32G on all platforms using new flag SharedBaseAddress. In 32bit VM set CDS archive address to 3Gb on Linux and let other OSs pick the address. Reviewed-by: kvn, dcubed, zgu, hseigel
author coleenp
date Wed, 20 Mar 2013 08:04:54 -0400
parents ade95d680b42
children de6a9e811145
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3895
diff changeset
2 * Copyright (c) 1997, 2012, 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: 665
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 665
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: 665
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 #ifndef SHARE_VM_RUNTIME_REFLECTION_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_RUNTIME_REFLECTION_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "oops/oop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "runtime/fieldDescriptor.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "utilities/accessFlags.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "utilities/growableArray.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Class Reflection contains utility methods needed for implementing the
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // reflection api.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Used by functions in the JVM interface.
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // NOTE that in JDK 1.4 most of reflection is now implemented in Java
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // using dynamic bytecode generation. The Array class has not yet been
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // rewritten using bytecodes; if it were, most of the rest of this
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // class could go away, as well as a few more entry points in jvm.cpp.
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class FieldStream;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 class Reflection: public AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // Access checking
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3895
diff changeset
48 static bool reflect_check_access(Klass* field_class, AccessFlags acc, Klass* target_class, bool is_method_invoke, TRAPS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Conversion
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3895
diff changeset
51 static Klass* basic_type_mirror_to_arrayklass(oop basic_type_mirror, TRAPS);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3895
diff changeset
52 static oop basic_type_arrayklass_to_mirror(Klass* basic_type_arrayklass, TRAPS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 static objArrayHandle get_parameter_types(methodHandle method, int parameter_count, oop* return_type, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
55 static objArrayHandle get_exception_types(methodHandle method, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // Creating new java.lang.reflect.xxx wrappers
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
57 static Handle new_type(Symbol* signature, KlassHandle k, TRAPS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Constants defined by java reflection api classes
a61af66fc99e Initial load
duke
parents:
diff changeset
61 enum SomeConstants {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 PUBLIC = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
63 DECLARED = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
64 MEMBER_PUBLIC = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
65 MEMBER_DECLARED = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 MAX_DIM = 255
a61af66fc99e Initial load
duke
parents:
diff changeset
67 };
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Boxing. Returns boxed value of appropriate type. Throws IllegalArgumentException.
a61af66fc99e Initial load
duke
parents:
diff changeset
70 static oop box(jvalue* v, BasicType type, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Unboxing. Returns type code and sets value.
a61af66fc99e Initial load
duke
parents:
diff changeset
72 static BasicType unbox_for_primitive(oop boxed_value, jvalue* value, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 static BasicType unbox_for_regular_object(oop boxed_value, jvalue* value);
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // Widening of basic types. Throws IllegalArgumentException.
a61af66fc99e Initial load
duke
parents:
diff changeset
76 static void widen(jvalue* value, BasicType current_type, BasicType wide_type, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // Reflective array access. Returns type code. Throws ArrayIndexOutOfBoundsException.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 static BasicType array_get(jvalue* value, arrayOop a, int index, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 static void array_set(jvalue* value, arrayOop a, int index, BasicType value_type, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // Returns mirror on array element type (NULL for basic type arrays and non-arrays).
a61af66fc99e Initial load
duke
parents:
diff changeset
82 static oop array_component_type(oop mirror, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // Object creation
a61af66fc99e Initial load
duke
parents:
diff changeset
85 static arrayOop reflect_new_array(oop element_mirror, jint length, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 static arrayOop reflect_new_multi_array(oop element_mirror, typeArrayOop dimensions, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // Verification
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3895
diff changeset
89 static bool verify_class_access(Klass* current_class, Klass* new_class, bool classloader_only);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3895
diff changeset
91 static bool verify_field_access(Klass* current_class,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3895
diff changeset
92 Klass* resolved_class,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3895
diff changeset
93 Klass* field_class,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
94 AccessFlags access,
a61af66fc99e Initial load
duke
parents:
diff changeset
95 bool classloader_only,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 bool protected_restriction = false);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3895
diff changeset
97 static bool is_same_class_package(Klass* class1, Klass* class2);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3895
diff changeset
98 static bool is_same_package_member(Klass* class1, Klass* class2, TRAPS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 static bool can_relax_access_check_for(
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3895
diff changeset
101 Klass* accessor, Klass* accesee, bool classloader_only);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // inner class reflection
665
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
104 // raise an ICCE unless the required relationship can be proven to hold
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
105 // If inner_is_member, require the inner to be a member of the outer.
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
106 // If !inner_is_member, require the inner to be anonymous (a non-member).
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
107 // Caller is responsible for figuring out in advance which case must be true.
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
108 static void check_for_inner_class(instanceKlassHandle outer, instanceKlassHandle inner,
c89f86385056 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 0
diff changeset
109 bool inner_is_member, TRAPS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 //
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Support for reflection based on dynamic bytecode generation (JDK 1.4)
a61af66fc99e Initial load
duke
parents:
diff changeset
113 //
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Create a java.lang.reflect.Method object based on a method
a61af66fc99e Initial load
duke
parents:
diff changeset
116 static oop new_method(methodHandle method, bool intern_name, bool for_constant_pool_access, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Create a java.lang.reflect.Constructor object based on a method
a61af66fc99e Initial load
duke
parents:
diff changeset
118 static oop new_constructor(methodHandle method, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Create a java.lang.reflect.Field object based on a field descriptor
a61af66fc99e Initial load
duke
parents:
diff changeset
120 static oop new_field(fieldDescriptor* fd, bool intern_name, TRAPS);
7462
ade95d680b42 8004728: Add hotspot support for parameter reflection
coleenp
parents: 6725
diff changeset
121 // Create a java.lang.reflect.Parameter object based on a
ade95d680b42 8004728: Add hotspot support for parameter reflection
coleenp
parents: 6725
diff changeset
122 // MethodParameterElement
ade95d680b42 8004728: Add hotspot support for parameter reflection
coleenp
parents: 6725
diff changeset
123 static oop new_parameter(Handle method, int index, Symbol* sym,
ade95d680b42 8004728: Add hotspot support for parameter reflection
coleenp
parents: 6725
diff changeset
124 int flags, TRAPS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // method resolution for invoke
a61af66fc99e Initial load
duke
parents:
diff changeset
128 static methodHandle resolve_interface_call(instanceKlassHandle klass, methodHandle method, KlassHandle recv_klass, Handle receiver, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Method call (shared by invoke_method and invoke_constructor)
a61af66fc99e Initial load
duke
parents:
diff changeset
130 static oop invoke(instanceKlassHandle klass, methodHandle method, Handle receiver, bool override, objArrayHandle ptypes, BasicType rtype, objArrayHandle args, bool is_method_invoke, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // Narrowing of basic types. Used to create correct jvalues for
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // boolean, byte, char and short return return values from interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // which are returned as ints. Throws IllegalArgumentException.
a61af66fc99e Initial load
duke
parents:
diff changeset
135 static void narrow(jvalue* value, BasicType narrow_type, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // Conversion
a61af66fc99e Initial load
duke
parents:
diff changeset
138 static BasicType basic_type_mirror_to_basic_type(oop basic_type_mirror, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Method invokation through java.lang.reflect.Method
a61af66fc99e Initial load
duke
parents:
diff changeset
142 static oop invoke_method(oop method_mirror, Handle receiver, objArrayHandle args, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // Method invokation through java.lang.reflect.Constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
144 static oop invoke_constructor(oop method_mirror, objArrayHandle args, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
147
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
148 #endif // SHARE_VM_RUNTIME_REFLECTION_HPP