/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_RUNTIME_REFLECTION_HPP
#define SHARE_VM_RUNTIME_REFLECTION_HPP
#include "runtime/fieldDescriptor.hpp"
#include "utilities/accessFlags.hpp"
#include "utilities/growableArray.hpp"
// Class Reflection contains utility methods needed for implementing the
// reflection api.
//
// Used by functions in the JVM interface.
//
// NOTE that in JDK 1.4 most of reflection is now implemented in Java
// using dynamic bytecode generation. The Array class has not yet been
// rewritten using bytecodes; if it were, most of the rest of this
// class could go away, as well as a few more entry points in jvm.cpp.
class FieldStream;
private:
// Access checking
static bool reflect_check_access(klassOop field_class, AccessFlags acc, klassOop target_class, bool is_method_invoke, TRAPS);
// Conversion
static objArrayHandle get_parameter_types(methodHandle method, int parameter_count, oop* return_type, TRAPS);
// Creating new java.lang.reflect.xxx wrappers
public:
// Constants defined by java reflection api classes
enum SomeConstants {
PUBLIC = 0,
MEMBER_PUBLIC = 0,
};
// Boxing. Returns boxed value of appropriate type. Throws IllegalArgumentException.
// Unboxing. Returns type code and sets value.
// Widening of basic types. Throws IllegalArgumentException.
// Reflective array access. Returns type code. Throws ArrayIndexOutOfBoundsException.
// Returns mirror on array element type (NULL for basic type arrays and non-arrays).
// Object creation
// Verification
bool classloader_only,
bool protected_restriction = false);
static bool can_relax_access_check_for(
// inner class reflection
// raise an ICCE unless the required relationship can be proven to hold
// If inner_is_member, require the inner to be a member of the outer.
// If !inner_is_member, require the inner to be anonymous (a non-member).
// Caller is responsible for figuring out in advance which case must be true.
bool inner_is_member, TRAPS);
//
// Support for reflection based on dynamic bytecode generation (JDK 1.4)
//
// Create a java.lang.reflect.Method object based on a method
// Create a java.lang.reflect.Constructor object based on a method
// Create a java.lang.reflect.Field object based on a field descriptor
private:
// method resolution for invoke
static methodHandle resolve_interface_call(instanceKlassHandle klass, methodHandle method, KlassHandle recv_klass, Handle receiver, TRAPS);
// Method call (shared by invoke_method and invoke_constructor)
static oop invoke(instanceKlassHandle klass, methodHandle method, Handle receiver, bool override, objArrayHandle ptypes, BasicType rtype, objArrayHandle args, bool is_method_invoke, TRAPS);
// Narrowing of basic types. Used to create correct jvalues for
// boolean, byte, char and short return return values from interpreter
// which are returned as ints. Throws IllegalArgumentException.
// Conversion
public:
// Method invokation through java.lang.reflect.Method
// Method invokation through java.lang.reflect.Constructor
};
#endif // SHARE_VM_RUNTIME_REFLECTION_HPP