Tue, 07 Jul 2009 14:23:00 -0400
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
Summary: Changing the behavior of -XX:+PrintHeapAtGC for G1 from printing lengthy, per-region information to instead printing a concise summary.
Reviewed-by: ysr, apetrusenko, jcoomes
duke@435 | 1 | /* |
jrose@1100 | 2 | * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | // Class Reflection contains utility methods needed for implementing the |
duke@435 | 26 | // reflection api. |
duke@435 | 27 | // |
duke@435 | 28 | // Used by functions in the JVM interface. |
duke@435 | 29 | // |
duke@435 | 30 | // NOTE that in JDK 1.4 most of reflection is now implemented in Java |
duke@435 | 31 | // using dynamic bytecode generation. The Array class has not yet been |
duke@435 | 32 | // rewritten using bytecodes; if it were, most of the rest of this |
duke@435 | 33 | // class could go away, as well as a few more entry points in jvm.cpp. |
duke@435 | 34 | |
duke@435 | 35 | class FieldStream; |
duke@435 | 36 | |
duke@435 | 37 | class Reflection: public AllStatic { |
duke@435 | 38 | private: |
duke@435 | 39 | // Access checking |
duke@435 | 40 | static bool reflect_check_access(klassOop field_class, AccessFlags acc, klassOop target_class, bool is_method_invoke, TRAPS); |
duke@435 | 41 | |
duke@435 | 42 | // Conversion |
duke@435 | 43 | static klassOop basic_type_mirror_to_arrayklass(oop basic_type_mirror, TRAPS); |
duke@435 | 44 | static oop basic_type_arrayklass_to_mirror(klassOop basic_type_arrayklass, TRAPS); |
duke@435 | 45 | |
duke@435 | 46 | static objArrayHandle get_parameter_types(methodHandle method, int parameter_count, oop* return_type, TRAPS); |
duke@435 | 47 | static objArrayHandle get_exception_types(methodHandle method, TRAPS); |
duke@435 | 48 | // Creating new java.lang.reflect.xxx wrappers |
duke@435 | 49 | static Handle new_type(symbolHandle signature, KlassHandle k, TRAPS); |
duke@435 | 50 | |
duke@435 | 51 | public: |
duke@435 | 52 | // Constants defined by java reflection api classes |
duke@435 | 53 | enum SomeConstants { |
duke@435 | 54 | PUBLIC = 0, |
duke@435 | 55 | DECLARED = 1, |
duke@435 | 56 | MEMBER_PUBLIC = 0, |
duke@435 | 57 | MEMBER_DECLARED = 1, |
duke@435 | 58 | MAX_DIM = 255 |
duke@435 | 59 | }; |
duke@435 | 60 | |
duke@435 | 61 | // Boxing. Returns boxed value of appropriate type. Throws IllegalArgumentException. |
duke@435 | 62 | static oop box(jvalue* v, BasicType type, TRAPS); |
duke@435 | 63 | // Unboxing. Returns type code and sets value. |
duke@435 | 64 | static BasicType unbox_for_primitive(oop boxed_value, jvalue* value, TRAPS); |
duke@435 | 65 | static BasicType unbox_for_regular_object(oop boxed_value, jvalue* value); |
duke@435 | 66 | |
duke@435 | 67 | // Widening of basic types. Throws IllegalArgumentException. |
duke@435 | 68 | static void widen(jvalue* value, BasicType current_type, BasicType wide_type, TRAPS); |
duke@435 | 69 | |
duke@435 | 70 | // Reflective array access. Returns type code. Throws ArrayIndexOutOfBoundsException. |
duke@435 | 71 | static BasicType array_get(jvalue* value, arrayOop a, int index, TRAPS); |
duke@435 | 72 | static void array_set(jvalue* value, arrayOop a, int index, BasicType value_type, TRAPS); |
duke@435 | 73 | // Returns mirror on array element type (NULL for basic type arrays and non-arrays). |
duke@435 | 74 | static oop array_component_type(oop mirror, TRAPS); |
duke@435 | 75 | |
duke@435 | 76 | // Object creation |
duke@435 | 77 | static arrayOop reflect_new_array(oop element_mirror, jint length, TRAPS); |
duke@435 | 78 | static arrayOop reflect_new_multi_array(oop element_mirror, typeArrayOop dimensions, TRAPS); |
duke@435 | 79 | |
duke@435 | 80 | // Verification |
duke@435 | 81 | static bool verify_class_access(klassOop current_class, klassOop new_class, bool classloader_only); |
duke@435 | 82 | |
duke@435 | 83 | static bool verify_field_access(klassOop current_class, |
duke@435 | 84 | klassOop resolved_class, |
duke@435 | 85 | klassOop field_class, |
duke@435 | 86 | AccessFlags access, |
duke@435 | 87 | bool classloader_only, |
duke@435 | 88 | bool protected_restriction = false); |
duke@435 | 89 | static bool is_same_class_package(klassOop class1, klassOop class2); |
jrose@1100 | 90 | static bool is_same_package_member(klassOop class1, klassOop class2, TRAPS); |
duke@435 | 91 | |
duke@435 | 92 | static bool can_relax_access_check_for( |
duke@435 | 93 | klassOop accessor, klassOop accesee, bool classloader_only); |
duke@435 | 94 | |
duke@435 | 95 | // inner class reflection |
jrose@1100 | 96 | // raise an ICCE unless the required relationship can be proven to hold |
jrose@1100 | 97 | // If inner_is_member, require the inner to be a member of the outer. |
jrose@1100 | 98 | // If !inner_is_member, require the inner to be anonymous (a non-member). |
jrose@1100 | 99 | // Caller is responsible for figuring out in advance which case must be true. |
jrose@1100 | 100 | static void check_for_inner_class(instanceKlassHandle outer, instanceKlassHandle inner, |
jrose@1100 | 101 | bool inner_is_member, TRAPS); |
duke@435 | 102 | |
duke@435 | 103 | // |
duke@435 | 104 | // Support for reflection based on dynamic bytecode generation (JDK 1.4) |
duke@435 | 105 | // |
duke@435 | 106 | |
duke@435 | 107 | // Create a java.lang.reflect.Method object based on a method |
duke@435 | 108 | static oop new_method(methodHandle method, bool intern_name, bool for_constant_pool_access, TRAPS); |
duke@435 | 109 | // Create a java.lang.reflect.Constructor object based on a method |
duke@435 | 110 | static oop new_constructor(methodHandle method, TRAPS); |
duke@435 | 111 | // Create a java.lang.reflect.Field object based on a field descriptor |
duke@435 | 112 | static oop new_field(fieldDescriptor* fd, bool intern_name, TRAPS); |
duke@435 | 113 | |
duke@435 | 114 | //--------------------------------------------------------------------------- |
duke@435 | 115 | // |
duke@435 | 116 | // Support for old native code-based reflection (pre-JDK 1.4) |
duke@435 | 117 | // |
duke@435 | 118 | // NOTE: the method and constructor invocation code is still used |
duke@435 | 119 | // for startup time reasons; see reflectionCompat.hpp. |
duke@435 | 120 | // |
duke@435 | 121 | //--------------------------------------------------------------------------- |
duke@435 | 122 | |
duke@435 | 123 | #ifdef SUPPORT_OLD_REFLECTION |
duke@435 | 124 | private: |
duke@435 | 125 | // method resolution for invoke |
duke@435 | 126 | static methodHandle resolve_interface_call(instanceKlassHandle klass, methodHandle method, KlassHandle recv_klass, Handle receiver, TRAPS); |
duke@435 | 127 | // Method call (shared by invoke_method and invoke_constructor) |
duke@435 | 128 | static oop invoke(instanceKlassHandle klass, methodHandle method, Handle receiver, bool override, objArrayHandle ptypes, BasicType rtype, objArrayHandle args, bool is_method_invoke, TRAPS); |
duke@435 | 129 | |
duke@435 | 130 | // Narrowing of basic types. Used to create correct jvalues for |
duke@435 | 131 | // boolean, byte, char and short return return values from interpreter |
duke@435 | 132 | // which are returned as ints. Throws IllegalArgumentException. |
duke@435 | 133 | static void narrow(jvalue* value, BasicType narrow_type, TRAPS); |
duke@435 | 134 | |
duke@435 | 135 | // Conversion |
duke@435 | 136 | static BasicType basic_type_mirror_to_basic_type(oop basic_type_mirror, TRAPS); |
duke@435 | 137 | |
duke@435 | 138 | static bool match_parameter_types(methodHandle method, objArrayHandle types, int parameter_count, TRAPS); |
duke@435 | 139 | // Creating new java.lang.reflect.xxx wrappers |
duke@435 | 140 | static oop new_field(FieldStream* st, TRAPS); |
duke@435 | 141 | |
duke@435 | 142 | public: |
duke@435 | 143 | // Field lookup and verification. |
duke@435 | 144 | static bool resolve_field(Handle field_mirror, Handle& receiver, fieldDescriptor* fd, bool check_final, TRAPS); |
duke@435 | 145 | |
duke@435 | 146 | // Reflective field access. Returns type code. Throws IllegalArgumentException. |
duke@435 | 147 | static BasicType field_get(jvalue* value, fieldDescriptor* fd, Handle receiver); |
duke@435 | 148 | static void field_set(jvalue* value, fieldDescriptor* fd, Handle receiver, BasicType value_type, TRAPS); |
duke@435 | 149 | |
duke@435 | 150 | // Reflective lookup of fields. Returns java.lang.reflect.Field instances. |
duke@435 | 151 | static oop reflect_field(oop mirror, symbolOop field_name, jint which, TRAPS); |
duke@435 | 152 | static objArrayOop reflect_fields(oop mirror, jint which, TRAPS); |
duke@435 | 153 | |
duke@435 | 154 | // Reflective lookup of methods. Returns java.lang.reflect.Method instances. |
duke@435 | 155 | static oop reflect_method(oop mirror, symbolHandle method_name, objArrayHandle types, jint which, TRAPS); |
duke@435 | 156 | static objArrayOop reflect_methods(oop mirror, jint which, TRAPS); |
duke@435 | 157 | |
duke@435 | 158 | // Reflective lookup of constructors. Returns java.lang.reflect.Constructor instances. |
duke@435 | 159 | static oop reflect_constructor(oop mirror, objArrayHandle types, jint which, TRAPS); |
duke@435 | 160 | static objArrayOop reflect_constructors(oop mirror, jint which, TRAPS); |
duke@435 | 161 | |
duke@435 | 162 | // Method invokation through java.lang.reflect.Method |
duke@435 | 163 | static oop invoke_method(oop method_mirror, Handle receiver, objArrayHandle args, TRAPS); |
duke@435 | 164 | // Method invokation through java.lang.reflect.Constructor |
duke@435 | 165 | static oop invoke_constructor(oop method_mirror, objArrayHandle args, TRAPS); |
duke@435 | 166 | #endif /* SUPPORT_OLD_REFLECTION */ |
duke@435 | 167 | |
duke@435 | 168 | }; |