| 1 | /* |
| 2 | * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
| 3 | * Copyright (c) 2018, SAP SE. All rights reserved. |
| 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 5 | * |
| 6 | * This code is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 only, as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 | * version 2 for more details (a copy is included in the LICENSE file that |
| 14 | * accompanied this code). |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License version |
| 17 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 18 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | * |
| 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 21 | * or visit www.oracle.com if you need additional information or have any |
| 22 | * questions. |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #ifndef SHARE_OOPS_REFLECTIONACCESSORIMPLKLASSHELPER_HPP |
| 27 | #define SHARE_OOPS_REFLECTIONACCESSORIMPLKLASSHELPER_HPP |
| 28 | |
| 29 | #include "memory/allocation.hpp" |
| 30 | |
| 31 | class InstanceKlass; |
| 32 | |
| 33 | // Helper for classes derived from jdk/internal/reflect/{Method|Constructor}AccessorImpl: |
| 34 | // offers convenience functions to extract the names of target class/method/signature |
| 35 | // from the constant pool of these classes. |
| 36 | class ReflectionAccessorImplKlassHelper: public AllStatic { |
| 37 | |
| 38 | // Returns true if k is of type jdk/internal/reflect/GeneratedMethodAccessorXXX. |
| 39 | static bool is_generated_method_accessor(const InstanceKlass* k); |
| 40 | |
| 41 | // Returns true if k is of type jdk/internal/reflect/GeneratedConstructorAccessorXXX. |
| 42 | static bool is_generated_constructor_accessor(const InstanceKlass* k); |
| 43 | |
| 44 | // Returns true if k is of type jdk/internal/reflect/GeneratedSerializationConstructorAccessorXXX. |
| 45 | static bool is_generated_method_serialization_constructor_accessor(const InstanceKlass* k); |
| 46 | |
| 47 | // Assuming k is of type jdk/internal/reflect/Generated{SerializationConstructor|Constructor|Method}AccessorXXX, |
| 48 | // the name of the target class as resource-area allocated string. |
| 49 | static const char* get_target_class_name(const InstanceKlass* k); |
| 50 | |
| 51 | // Assuming k is of type jdk/internal/reflect/Generated{SerializationConstructor|Constructor|Method}AccessorXXX, |
| 52 | // the name of the target method as resource-area allocated string. |
| 53 | static const char* get_target_method_name(const InstanceKlass* k); |
| 54 | |
| 55 | // Assuming k is of type jdk/internal/reflect/Generated{SerializationConstructor|Constructor|Method}AccessorXXX, |
| 56 | // the signature of the target method as resource-area allocated string. |
| 57 | static const char* get_target_method_signature(const InstanceKlass* k); |
| 58 | |
| 59 | public: |
| 60 | |
| 61 | // Returns true if k is of type jdk/internal/reflect/Generated{SerializationConstructor|Constructor|Method}AccessorXXX |
| 62 | // and it is safe to call print_invocation_target(k) |
| 63 | static bool is_generated_accessor(const Klass* k); |
| 64 | |
| 65 | // Assuming k is of type jdk/internal/reflect/Generated{SerializationConstructor|Constructor|Method}AccessorXXX, |
| 66 | // print out target class, method, signature in one line. |
| 67 | static void print_invocation_target(outputStream* out, Klass* k); |
| 68 | |
| 69 | }; |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | #endif // SHARE_OOPS_REFLECTIONACCESSORIMPLKLASSHELPER_HPP |
| 75 | |