8305104: Remove the old core reflection implementation
Reviewed-by: dholmes, alanb
This commit is contained in:
parent
bfef3c3e80
commit
9bfe415f66
@ -3622,21 +3622,6 @@ ConstantPool* reflect_ConstantPool::get_cp(oop reflect) {
|
||||
return InstanceKlass::cast(k)->constants();
|
||||
}
|
||||
|
||||
int reflect_UnsafeStaticFieldAccessorImpl::_base_offset;
|
||||
|
||||
#define UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(macro) \
|
||||
macro(_base_offset, k, "base", object_signature, false)
|
||||
|
||||
void reflect_UnsafeStaticFieldAccessorImpl::compute_offsets() {
|
||||
InstanceKlass* k = vmClasses::reflect_UnsafeStaticFieldAccessorImpl_klass();
|
||||
UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
void reflect_UnsafeStaticFieldAccessorImpl::serialize_offsets(SerializeClosure* f) {
|
||||
UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Support for java_lang_ref_Reference
|
||||
|
||||
@ -4633,7 +4618,8 @@ bool java_lang_ClassLoader::is_trusted_loader(oop loader) {
|
||||
}
|
||||
|
||||
// Return true if this is one of the class loaders associated with
|
||||
// the generated bytecodes for reflection.
|
||||
// the generated bytecodes for serialization constructor returned
|
||||
// by sun.reflect.ReflectionFactory::newConstructorForSerialization
|
||||
bool java_lang_ClassLoader::is_reflection_class_loader(oop loader) {
|
||||
if (loader != nullptr) {
|
||||
Klass* delegating_cl_class = vmClasses::reflect_DelegatingClassLoader_klass();
|
||||
@ -5223,7 +5209,6 @@ void java_lang_InternalError::serialize_offsets(SerializeClosure* f) {
|
||||
f(java_lang_reflect_Field) \
|
||||
f(java_lang_reflect_RecordComponent) \
|
||||
f(reflect_ConstantPool) \
|
||||
f(reflect_UnsafeStaticFieldAccessorImpl) \
|
||||
f(java_lang_reflect_Parameter) \
|
||||
f(java_lang_Module) \
|
||||
f(java_lang_StackTraceElement) \
|
||||
|
@ -884,20 +884,6 @@ class reflect_ConstantPool {
|
||||
friend class JavaClasses;
|
||||
};
|
||||
|
||||
// Interface to jdk.internal.reflect.UnsafeStaticFieldAccessorImpl objects
|
||||
class reflect_UnsafeStaticFieldAccessorImpl {
|
||||
private:
|
||||
static int _base_offset;
|
||||
static void compute_offsets();
|
||||
|
||||
public:
|
||||
static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
|
||||
|
||||
static int base_offset() { CHECK_INIT(_base_offset); }
|
||||
|
||||
// Debugging
|
||||
friend class JavaClasses;
|
||||
};
|
||||
|
||||
// Interface to java.lang primitive type boxing objects:
|
||||
// - java.lang.Boolean
|
||||
@ -1494,7 +1480,8 @@ class java_lang_ClassLoader : AllStatic {
|
||||
static bool is_trusted_loader(oop loader);
|
||||
|
||||
// Return true if this is one of the class loaders associated with
|
||||
// the generated bytecodes for reflection.
|
||||
// the generated bytecodes for serialization constructor returned
|
||||
// by sun.reflect.ReflectionFactory::newConstructorForSerialization
|
||||
static bool is_reflection_class_loader(oop loader);
|
||||
|
||||
// Fix for 4474172
|
||||
|
@ -268,9 +268,10 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) {
|
||||
|
||||
bool Verifier::is_eligible_for_verification(InstanceKlass* klass, bool should_verify_class) {
|
||||
Symbol* name = klass->name();
|
||||
Klass* refl_magic_klass = vmClasses::reflect_MagicAccessorImpl_klass();
|
||||
Klass* refl_serialization_ctor_klass = vmClasses::reflect_SerializationConstructorAccessorImpl_klass();
|
||||
|
||||
bool is_reflect = refl_magic_klass != nullptr && klass->is_subtype_of(refl_magic_klass);
|
||||
bool is_reflect_accessor = refl_serialization_ctor_klass != nullptr &&
|
||||
klass->is_subtype_of(refl_serialization_ctor_klass);
|
||||
|
||||
return (should_verify_for(klass->class_loader(), should_verify_class) &&
|
||||
// return if the class is a bootstrapping class
|
||||
@ -290,13 +291,9 @@ bool Verifier::is_eligible_for_verification(InstanceKlass* klass, bool should_ve
|
||||
!(klass->is_shared() && klass->is_rewritten()) &&
|
||||
|
||||
// As of the fix for 4486457 we disable verification for all of the
|
||||
// dynamically-generated bytecodes associated with the 1.4
|
||||
// reflection implementation, not just those associated with
|
||||
// dynamically-generated bytecodes associated with
|
||||
// jdk/internal/reflect/SerializationConstructorAccessor.
|
||||
// NOTE: this is called too early in the bootstrapping process to be
|
||||
// guarded by Universe::is_gte_jdk14x_version().
|
||||
// Also for lambda generated code, gte jdk8
|
||||
(!is_reflect));
|
||||
(!is_reflect_accessor));
|
||||
}
|
||||
|
||||
Symbol* Verifier::inference_verify(
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -105,14 +105,12 @@
|
||||
do_klass(Continuation_klass, jdk_internal_vm_Continuation ) \
|
||||
do_klass(StackChunk_klass, jdk_internal_vm_StackChunk ) \
|
||||
\
|
||||
do_klass(reflect_MagicAccessorImpl_klass, reflect_MagicAccessorImpl ) \
|
||||
do_klass(reflect_MethodAccessorImpl_klass, reflect_MethodAccessorImpl ) \
|
||||
do_klass(reflect_ConstructorAccessorImpl_klass, reflect_ConstructorAccessorImpl ) \
|
||||
do_klass(reflect_DelegatingClassLoader_klass, reflect_DelegatingClassLoader ) \
|
||||
do_klass(reflect_ConstantPool_klass, reflect_ConstantPool ) \
|
||||
do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, reflect_UnsafeStaticFieldAccessorImpl ) \
|
||||
do_klass(reflect_CallerSensitive_klass, reflect_CallerSensitive ) \
|
||||
do_klass(reflect_NativeConstructorAccessorImpl_klass, reflect_NativeConstructorAccessorImpl ) \
|
||||
do_klass(reflect_DirectConstructorHandleAccessor_NativeAccessor_klass, reflect_DirectConstructorHandleAccessor_NativeAccessor) \
|
||||
do_klass(reflect_SerializationConstructorAccessorImpl_klass, reflect_SerializationConstructorAccessorImpl ) \
|
||||
\
|
||||
/* support for dynamic typing */ \
|
||||
do_klass(DirectMethodHandle_klass, java_lang_invoke_DirectMethodHandle ) \
|
||||
|
@ -271,14 +271,13 @@
|
||||
/* Support for reflection based on dynamic bytecode generation (JDK 1.4 and above) */ \
|
||||
\
|
||||
template(jdk_internal_reflect, "jdk/internal/reflect") \
|
||||
template(reflect_MagicAccessorImpl, "jdk/internal/reflect/MagicAccessorImpl") \
|
||||
template(reflect_MethodAccessorImpl, "jdk/internal/reflect/MethodAccessorImpl") \
|
||||
template(reflect_ConstructorAccessorImpl, "jdk/internal/reflect/ConstructorAccessorImpl") \
|
||||
template(reflect_DelegatingClassLoader, "jdk/internal/reflect/DelegatingClassLoader") \
|
||||
template(reflect_Reflection, "jdk/internal/reflect/Reflection") \
|
||||
template(reflect_CallerSensitive, "jdk/internal/reflect/CallerSensitive") \
|
||||
template(reflect_CallerSensitive_signature, "Ljdk/internal/reflect/CallerSensitive;") \
|
||||
template(reflect_NativeConstructorAccessorImpl, "jdk/internal/reflect/NativeConstructorAccessorImpl")\
|
||||
template(reflect_DirectConstructorHandleAccessor_NativeAccessor, "jdk/internal/reflect/DirectConstructorHandleAccessor$NativeAccessor") \
|
||||
template(reflect_SerializationConstructorAccessorImpl, "jdk/internal/reflect/SerializationConstructorAccessorImpl") \
|
||||
template(checkedExceptions_name, "checkedExceptions") \
|
||||
template(clazz_name, "clazz") \
|
||||
template(exceptionTypes_name, "exceptionTypes") \
|
||||
@ -307,7 +306,6 @@
|
||||
template(parameter_annotations_name, "parameterAnnotations") \
|
||||
template(annotation_default_name, "annotationDefault") \
|
||||
template(reflect_ConstantPool, "jdk/internal/reflect/ConstantPool") \
|
||||
template(reflect_UnsafeStaticFieldAccessorImpl, "jdk/internal/reflect/UnsafeStaticFieldAccessorImpl")\
|
||||
template(base_name, "base") \
|
||||
/* Type Annotations (JDK 8 and above) */ \
|
||||
template(type_annotations_name, "typeAnnotations") \
|
||||
|
@ -1447,7 +1447,7 @@ bool BytecodeUtils::get_NPE_message_at(outputStream* ss, Method* method, int bci
|
||||
|
||||
// If this NPE was created via reflection, we have no real NPE.
|
||||
if (method->method_holder() ==
|
||||
vmClasses::reflect_NativeConstructorAccessorImpl_klass()) {
|
||||
vmClasses::reflect_DirectConstructorHandleAccessor_NativeAccessor_klass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1169,9 +1169,10 @@ Method* LinkResolver::linktime_resolve_special_method(const LinkInfo& link_info,
|
||||
Klass* current_klass = link_info.current_klass();
|
||||
if (current_klass != nullptr && resolved_klass->is_interface()) {
|
||||
InstanceKlass* klass_to_check = InstanceKlass::cast(current_klass);
|
||||
// Disable verification for the dynamically-generated reflection bytecodes.
|
||||
// Disable verification for the dynamically-generated reflection bytecodes
|
||||
// for serialization constructor accessor.
|
||||
bool is_reflect = klass_to_check->is_subclass_of(
|
||||
vmClasses::reflect_MagicAccessorImpl_klass());
|
||||
vmClasses::reflect_SerializationConstructorAccessorImpl_klass());
|
||||
|
||||
if (!is_reflect &&
|
||||
!klass_to_check->is_same_or_direct_interface(resolved_klass)) {
|
||||
|
@ -722,7 +722,7 @@ JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env))
|
||||
//
|
||||
// The call stack at this point looks something like this:
|
||||
//
|
||||
// [0] [ @CallerSensitive public sun.reflect.Reflection.getCallerClass ]
|
||||
// [0] [ @CallerSensitive public jdk.internal.reflect.Reflection.getCallerClass ]
|
||||
// [1] [ @CallerSensitive API.method ]
|
||||
// [.] [ (skipped intermediate frames) ]
|
||||
// [n] [ caller ]
|
||||
@ -3294,8 +3294,7 @@ JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env))
|
||||
oop loader = ik->class_loader();
|
||||
if (loader != nullptr && !SystemDictionary::is_platform_class_loader(loader)) {
|
||||
// Skip reflection related frames
|
||||
if (!ik->is_subclass_of(vmClasses::reflect_MethodAccessorImpl_klass()) &&
|
||||
!ik->is_subclass_of(vmClasses::reflect_ConstructorAccessorImpl_klass())) {
|
||||
if (!ik->is_subclass_of(vmClasses::reflect_SerializationConstructorAccessorImpl_klass())) {
|
||||
return JNIHandles::make_local(THREAD, loader);
|
||||
}
|
||||
}
|
||||
|
@ -448,10 +448,10 @@ Reflection::VerifyClassAccessResults Reflection::verify_class_access(
|
||||
is_same_class_package(current_class, new_class)) {
|
||||
return ACCESS_OK;
|
||||
}
|
||||
// Allow all accesses from jdk/internal/reflect/MagicAccessorImpl subclasses to
|
||||
// Allow all accesses from jdk/internal/reflect/SerializationConstructorAccessorImpl subclasses to
|
||||
// succeed trivially.
|
||||
if (vmClasses::reflect_MagicAccessorImpl_klass_is_loaded() &&
|
||||
current_class->is_subclass_of(vmClasses::reflect_MagicAccessorImpl_klass())) {
|
||||
if (vmClasses::reflect_SerializationConstructorAccessorImpl_klass_is_loaded() &&
|
||||
current_class->is_subclass_of(vmClasses::reflect_SerializationConstructorAccessorImpl_klass())) {
|
||||
return ACCESS_OK;
|
||||
}
|
||||
|
||||
@ -664,9 +664,9 @@ bool Reflection::verify_member_access(const Klass* current_class,
|
||||
}
|
||||
}
|
||||
|
||||
// Allow all accesses from jdk/internal/reflect/MagicAccessorImpl subclasses to
|
||||
// Allow all accesses from jdk/internal/reflect/SerializationConstructorAccessorImpl subclasses to
|
||||
// succeed trivially.
|
||||
if (current_class->is_subclass_of(vmClasses::reflect_MagicAccessorImpl_klass())) {
|
||||
if (current_class->is_subclass_of(vmClasses::reflect_SerializationConstructorAccessorImpl_klass())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,6 @@ GrowableArray<FilteredField*> *FilteredFieldsMap::_filtered_fields =
|
||||
void FilteredFieldsMap::initialize() {
|
||||
int offset = reflect_ConstantPool::oop_offset();
|
||||
_filtered_fields->append(new FilteredField(vmClasses::reflect_ConstantPool_klass(), offset));
|
||||
offset = reflect_UnsafeStaticFieldAccessorImpl::base_offset();
|
||||
_filtered_fields->append(new FilteredField(vmClasses::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset));
|
||||
}
|
||||
|
||||
int FilteredFieldStream::field_count() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -43,8 +43,7 @@ class AccessorGenerator implements ClassFileConstants {
|
||||
protected static final short S5 = (short) 5;
|
||||
protected static final short S6 = (short) 6;
|
||||
|
||||
// Instance variables for shared functionality between
|
||||
// FieldAccessorGenerator and MethodAccessorGenerator
|
||||
// Instance variables for shared functionality
|
||||
protected ClassFileAssembler asm;
|
||||
protected int modifiers;
|
||||
protected short thisClass;
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
/** Uses Unsafe.allocateObject() to instantiate classes; only used for
|
||||
bootstrapping. */
|
||||
|
||||
class BootstrapConstructorAccessorImpl extends ConstructorAccessorImpl {
|
||||
private final Constructor<?> constructor;
|
||||
|
||||
BootstrapConstructorAccessorImpl(Constructor<?> c) {
|
||||
this.constructor = c;
|
||||
}
|
||||
|
||||
public Object newInstance(Object[] args)
|
||||
throws IllegalArgumentException, InvocationTargetException
|
||||
{
|
||||
try {
|
||||
return UnsafeFieldAccessorImpl.unsafe.
|
||||
allocateInstance(constructor.getDeclaringClass());
|
||||
} catch (InstantiationException e) {
|
||||
throw new InvocationTargetException(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,8 +32,11 @@ import jdk.internal.access.JavaLangAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
|
||||
/** Utility class which assists in calling defineClass() by
|
||||
creating a new class loader which delegates to the one needed in
|
||||
order for proper resolution of the given bytecodes to occur. */
|
||||
* creating a new class loader which delegates to the one needed in
|
||||
* order for proper resolution of the given bytecodes to occur.
|
||||
*
|
||||
* This is only used to define SerializationConstructorAccessor.
|
||||
*/
|
||||
|
||||
class ClassDefiner {
|
||||
static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Delegates its invocation to another ConstructorAccessorImpl and can
|
||||
change its delegate at run time. */
|
||||
|
||||
class DelegatingConstructorAccessorImpl extends ConstructorAccessorImpl {
|
||||
// initial non-null delegate
|
||||
private final ConstructorAccessorImpl initialDelegate;
|
||||
// alternative delegate: starts as null;
|
||||
// only single change from null -> non-null is guaranteed
|
||||
@Stable
|
||||
private ConstructorAccessorImpl altDelegate;
|
||||
|
||||
DelegatingConstructorAccessorImpl(ConstructorAccessorImpl delegate) {
|
||||
initialDelegate = Objects.requireNonNull(delegate);
|
||||
}
|
||||
|
||||
public Object newInstance(Object[] args)
|
||||
throws InstantiationException,
|
||||
IllegalArgumentException,
|
||||
InvocationTargetException
|
||||
{
|
||||
return delegate().newInstance(args);
|
||||
}
|
||||
|
||||
private ConstructorAccessorImpl delegate() {
|
||||
var d = altDelegate;
|
||||
return d != null ? d : initialDelegate;
|
||||
}
|
||||
|
||||
void setDelegate(ConstructorAccessorImpl delegate) {
|
||||
altDelegate = Objects.requireNonNull(delegate);
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Delegates its invocation to another MethodAccessorImpl and can
|
||||
change its delegate at run time. */
|
||||
|
||||
class DelegatingMethodAccessorImpl extends MethodAccessorImpl {
|
||||
// initial non-null delegate
|
||||
private final MethodAccessorImpl initialDelegate;
|
||||
// alternative delegate: starts as null;
|
||||
// only single change from null -> non-null is guaranteed
|
||||
@Stable
|
||||
private MethodAccessorImpl altDelegate;
|
||||
|
||||
DelegatingMethodAccessorImpl(MethodAccessorImpl delegate) {
|
||||
initialDelegate = Objects.requireNonNull(delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(Object obj, Object[] args)
|
||||
throws IllegalArgumentException, InvocationTargetException
|
||||
{
|
||||
return delegate().invoke(obj, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(Object obj, Object[] args, Class<?> caller)
|
||||
throws IllegalArgumentException, InvocationTargetException
|
||||
{
|
||||
return delegate().invoke(obj, args, caller);
|
||||
}
|
||||
|
||||
private MethodAccessorImpl delegate() {
|
||||
var d = altDelegate;
|
||||
return d != null ? d : initialDelegate;
|
||||
}
|
||||
|
||||
void setDelegate(MethodAccessorImpl delegate) {
|
||||
altDelegate = Objects.requireNonNull(delegate);
|
||||
}
|
||||
}
|
@ -303,6 +303,17 @@ final class MethodHandleAccessorFactory {
|
||||
|
||||
/*
|
||||
* Returns true if NativeAccessor should be used.
|
||||
*
|
||||
* Native accessor, i.e. VM reflection implementation, is used if one of
|
||||
* the following conditions is met:
|
||||
* 1. during VM early startup before method handle support is fully initialized
|
||||
* 2. a Java native method
|
||||
* 3. -Djdk.reflect.useNativeAccessorOnly=true is set
|
||||
* 4. the member takes a variable number of arguments and the last parameter
|
||||
* is not an array (see details below)
|
||||
* 5. the member's method type has an arity >= 255
|
||||
*
|
||||
* Otherwise, direct invocation of method handles is used.
|
||||
*/
|
||||
private static boolean useNativeAccessor(Executable member) {
|
||||
if (!VM.isJavaLangInvokeInited())
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/** Used only for the first few invocations of a Constructor;
|
||||
afterward, switches to bytecode-based implementation */
|
||||
|
||||
class NativeConstructorAccessorImpl extends ConstructorAccessorImpl {
|
||||
private static final Unsafe U = Unsafe.getUnsafe();
|
||||
private static final long GENERATED_OFFSET
|
||||
= U.objectFieldOffset(NativeConstructorAccessorImpl.class, "generated");
|
||||
|
||||
private final Constructor<?> c;
|
||||
private final DelegatingConstructorAccessorImpl parent;
|
||||
private int numInvocations;
|
||||
private volatile int generated;
|
||||
|
||||
NativeConstructorAccessorImpl(Constructor<?> c) {
|
||||
this.c = c;
|
||||
this.parent = new DelegatingConstructorAccessorImpl(this);
|
||||
}
|
||||
|
||||
public Object newInstance(Object[] args)
|
||||
throws InstantiationException,
|
||||
IllegalArgumentException,
|
||||
InvocationTargetException
|
||||
{
|
||||
// We can't inflate a constructor belonging to a hidden class
|
||||
// because that kind of class can't be referred to by name, hence can't
|
||||
// be found from the generated bytecode.
|
||||
if (++numInvocations > ReflectionFactory.inflationThreshold()
|
||||
&& !c.getDeclaringClass().isHidden()
|
||||
&& generated == 0
|
||||
&& U.compareAndSetInt(this, GENERATED_OFFSET, 0, 1)) {
|
||||
try {
|
||||
ConstructorAccessorImpl acc = (ConstructorAccessorImpl)
|
||||
new MethodAccessorGenerator().
|
||||
generateConstructor(c.getDeclaringClass(),
|
||||
c.getParameterTypes(),
|
||||
c.getModifiers());
|
||||
parent.setDelegate(acc);
|
||||
} catch (Throwable t) {
|
||||
// Throwable happens in generateConstructor, restore generated to 0
|
||||
generated = 0;
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
return newInstance0(c, args);
|
||||
}
|
||||
|
||||
DelegatingConstructorAccessorImpl getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
private static native Object newInstance0(Constructor<?> c, Object[] args)
|
||||
throws InstantiationException,
|
||||
IllegalArgumentException,
|
||||
InvocationTargetException;
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/** Used only for the first few invocations of a Method; afterward,
|
||||
switches to bytecode-based implementation */
|
||||
|
||||
class NativeMethodAccessorImpl extends MethodAccessorImpl {
|
||||
private static final Unsafe U = Unsafe.getUnsafe();
|
||||
private static final long GENERATED_OFFSET
|
||||
= U.objectFieldOffset(NativeMethodAccessorImpl.class, "generated");
|
||||
|
||||
private final Method method;
|
||||
private final DelegatingMethodAccessorImpl parent;
|
||||
private int numInvocations;
|
||||
private volatile int generated;
|
||||
|
||||
NativeMethodAccessorImpl(Method method) {
|
||||
this.method = method;
|
||||
this.parent = new DelegatingMethodAccessorImpl(this);
|
||||
}
|
||||
|
||||
public Object invoke(Object obj, Object[] args)
|
||||
throws IllegalArgumentException, InvocationTargetException
|
||||
{
|
||||
// We can't inflate methods belonging to hidden classes because
|
||||
// that kind of class can't be referred to by name, hence can't be
|
||||
// found from the generated bytecode.
|
||||
if (++numInvocations > ReflectionFactory.inflationThreshold()
|
||||
&& !method.getDeclaringClass().isHidden()
|
||||
&& generated == 0
|
||||
&& U.compareAndSetInt(this, GENERATED_OFFSET, 0, 1)) {
|
||||
try {
|
||||
MethodAccessorImpl acc = (MethodAccessorImpl)
|
||||
new MethodAccessorGenerator().
|
||||
generateMethod(method.getDeclaringClass(),
|
||||
method.getName(),
|
||||
method.getParameterTypes(),
|
||||
method.getReturnType(),
|
||||
method.getModifiers());
|
||||
parent.setDelegate(acc);
|
||||
} catch (Throwable t) {
|
||||
// Throwable happens in generateMethod, restore generated to 0
|
||||
generated = 0;
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
return invoke0(method, obj, args);
|
||||
}
|
||||
|
||||
DelegatingMethodAccessorImpl getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
private static native Object invoke0(Method m, Object obj, Object[] args);
|
||||
}
|
@ -141,11 +141,7 @@ public class ReflectionFactory {
|
||||
}
|
||||
boolean isFinal = Modifier.isFinal(field.getModifiers());
|
||||
boolean isReadOnly = isFinal && (!override || langReflectAccess.isTrustedFinalField(field));
|
||||
if (useFieldHandleAccessor()) {
|
||||
return MethodHandleAccessorFactory.newFieldAccessor(field, isReadOnly);
|
||||
} else {
|
||||
return UnsafeFieldAccessorFactory.newFieldAccessor(field, isReadOnly);
|
||||
}
|
||||
return MethodHandleAccessorFactory.newFieldAccessor(field, isReadOnly);
|
||||
}
|
||||
|
||||
public MethodAccessor newMethodAccessor(Method method, boolean callerSensitive) {
|
||||
@ -155,29 +151,7 @@ public class ReflectionFactory {
|
||||
method = root;
|
||||
}
|
||||
|
||||
if (useMethodHandleAccessor()) {
|
||||
return MethodHandleAccessorFactory.newMethodAccessor(method, callerSensitive);
|
||||
} else {
|
||||
if (noInflation() && !method.getDeclaringClass().isHidden()) {
|
||||
return generateMethodAccessor(method);
|
||||
} else {
|
||||
NativeMethodAccessorImpl acc = new NativeMethodAccessorImpl(method);
|
||||
return acc.getParent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the MethodAccessor that invokes the given method with
|
||||
* bytecode invocation.
|
||||
*/
|
||||
static MethodAccessorImpl generateMethodAccessor(Method method) {
|
||||
return (MethodAccessorImpl)new MethodAccessorGenerator()
|
||||
.generateMethod(method.getDeclaringClass(),
|
||||
method.getName(),
|
||||
method.getParameterTypes(),
|
||||
method.getReturnType(),
|
||||
method.getModifiers());
|
||||
return MethodHandleAccessorFactory.newMethodAccessor(method, callerSensitive);
|
||||
}
|
||||
|
||||
public ConstructorAccessor newConstructorAccessor(Constructor<?> c) {
|
||||
@ -196,26 +170,7 @@ public class ReflectionFactory {
|
||||
c = root;
|
||||
}
|
||||
|
||||
if (useMethodHandleAccessor()) {
|
||||
return MethodHandleAccessorFactory.newConstructorAccessor(c);
|
||||
} else {
|
||||
// Bootstrapping issue: since we use Class.newInstance() in
|
||||
// the ConstructorAccessor generation process, we have to
|
||||
// break the cycle here.
|
||||
if (Reflection.isSubclassOf(declaringClass, ConstructorAccessorImpl.class)) {
|
||||
return new BootstrapConstructorAccessorImpl(c);
|
||||
}
|
||||
|
||||
if (noInflation() && !c.getDeclaringClass().isHidden()) {
|
||||
return new MethodAccessorGenerator().
|
||||
generateConstructor(c.getDeclaringClass(),
|
||||
c.getParameterTypes(),
|
||||
c.getModifiers());
|
||||
} else {
|
||||
NativeConstructorAccessorImpl acc = new NativeConstructorAccessorImpl(c);
|
||||
return acc.getParent();
|
||||
}
|
||||
}
|
||||
return MethodHandleAccessorFactory.newConstructorAccessor(c);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@ -416,7 +371,7 @@ public class ReflectionFactory {
|
||||
Constructor<?> constructorToCall) {
|
||||
|
||||
|
||||
ConstructorAccessor acc = new MethodAccessorGenerator().
|
||||
ConstructorAccessor acc = new SerializationConstructorAccessorGenerator().
|
||||
generateSerializationConstructor(cl,
|
||||
constructorToCall.getParameterTypes(),
|
||||
constructorToCall.getModifiers(),
|
||||
@ -585,24 +540,10 @@ public class ReflectionFactory {
|
||||
// Internals only below this point
|
||||
//
|
||||
|
||||
// Package-private to be accessible to NativeMethodAccessorImpl
|
||||
// and NativeConstructorAccessorImpl
|
||||
static int inflationThreshold() {
|
||||
return config().inflationThreshold;
|
||||
}
|
||||
|
||||
static boolean noInflation() {
|
||||
return config().noInflation;
|
||||
}
|
||||
|
||||
static boolean useMethodHandleAccessor() {
|
||||
return (config().useDirectMethodHandle & METHOD_MH_ACCESSOR) == METHOD_MH_ACCESSOR;
|
||||
}
|
||||
|
||||
static boolean useFieldHandleAccessor() {
|
||||
return (config().useDirectMethodHandle & FIELD_MH_ACCESSOR) == FIELD_MH_ACCESSOR;
|
||||
}
|
||||
|
||||
/*
|
||||
* If -Djdk.reflect.useNativeAccessorOnly is set, use the native accessor only.
|
||||
* For testing purpose only.
|
||||
*/
|
||||
static boolean useNativeAccessorOnly() {
|
||||
return config().useNativeAccessorOnly;
|
||||
}
|
||||
@ -611,11 +552,6 @@ public class ReflectionFactory {
|
||||
return config().disableSerialConstructorChecks;
|
||||
}
|
||||
|
||||
// New implementation uses direct invocation of method handles
|
||||
private static final int METHOD_MH_ACCESSOR = 0x1;
|
||||
private static final int FIELD_MH_ACCESSOR = 0x2;
|
||||
private static final int ALL_MH_ACCESSORS = METHOD_MH_ACCESSOR | FIELD_MH_ACCESSOR;
|
||||
|
||||
/**
|
||||
* The configuration is lazily initialized after the module system is initialized. The
|
||||
* default config would be used before the proper config is loaded.
|
||||
@ -627,21 +563,7 @@ public class ReflectionFactory {
|
||||
*/
|
||||
private static @Stable Config config;
|
||||
|
||||
// "Inflation" mechanism. Loading bytecodes to implement
|
||||
// Method.invoke() and Constructor.newInstance() currently costs
|
||||
// 3-4x more than an invocation via native code for the first
|
||||
// invocation (though subsequent invocations have been benchmarked
|
||||
// to be over 20x faster). Unfortunately this cost increases
|
||||
// startup time for certain applications that use reflection
|
||||
// intensively (but only once per class) to bootstrap themselves.
|
||||
// To avoid this penalty we reuse the existing JVM entry points
|
||||
// for the first few invocations of Methods and Constructors and
|
||||
// then switch to the bytecode-based implementations.
|
||||
|
||||
private static final Config DEFAULT_CONFIG = new Config(false, // noInflation
|
||||
15, // inflationThreshold
|
||||
ALL_MH_ACCESSORS, // useDirectMethodHandle
|
||||
false, // useNativeAccessorOnly
|
||||
private static final Config DEFAULT_CONFIG = new Config(false, // useNativeAccessorOnly
|
||||
false); // disableSerialConstructorChecks
|
||||
|
||||
/**
|
||||
@ -655,10 +577,7 @@ public class ReflectionFactory {
|
||||
* are currently not called, but should they be needed, a workaround
|
||||
* is to override them.
|
||||
*/
|
||||
private record Config(boolean noInflation,
|
||||
int inflationThreshold,
|
||||
int useDirectMethodHandle,
|
||||
boolean useNativeAccessorOnly,
|
||||
private record Config(boolean useNativeAccessorOnly,
|
||||
boolean disableSerialConstructorChecks) {
|
||||
}
|
||||
|
||||
@ -668,9 +587,7 @@ public class ReflectionFactory {
|
||||
return c;
|
||||
}
|
||||
|
||||
// Defer initialization until module system is initialized so as
|
||||
// to avoid inflation and spinning bytecode in unnamed modules
|
||||
// during early startup.
|
||||
// Always use the default configuration until the module system is initialized.
|
||||
if (!VM.isModuleSystemInited()) {
|
||||
return DEFAULT_CONFIG;
|
||||
}
|
||||
@ -681,49 +598,13 @@ public class ReflectionFactory {
|
||||
private static Config loadConfig() {
|
||||
assert VM.isModuleSystemInited();
|
||||
|
||||
boolean noInflation = DEFAULT_CONFIG.noInflation;
|
||||
int inflationThreshold = DEFAULT_CONFIG.inflationThreshold;
|
||||
int useDirectMethodHandle = DEFAULT_CONFIG.useDirectMethodHandle;
|
||||
boolean useNativeAccessorOnly = DEFAULT_CONFIG.useNativeAccessorOnly;
|
||||
boolean disableSerialConstructorChecks = DEFAULT_CONFIG.disableSerialConstructorChecks;
|
||||
|
||||
Properties props = GetPropertyAction.privilegedGetProperties();
|
||||
String val = props.getProperty("sun.reflect.noInflation");
|
||||
if (val != null && val.equals("true")) {
|
||||
noInflation = true;
|
||||
}
|
||||
|
||||
val = props.getProperty("sun.reflect.inflationThreshold");
|
||||
if (val != null) {
|
||||
try {
|
||||
inflationThreshold = Integer.parseInt(val);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RuntimeException("Unable to parse property sun.reflect.inflationThreshold", e);
|
||||
}
|
||||
}
|
||||
val = props.getProperty("jdk.reflect.useDirectMethodHandle");
|
||||
if (val != null) {
|
||||
if (val.equals("false")) {
|
||||
useDirectMethodHandle = 0;
|
||||
} else if (val.equals("methods")) {
|
||||
useDirectMethodHandle = METHOD_MH_ACCESSOR;
|
||||
} else if (val.equals("fields")) {
|
||||
useDirectMethodHandle = FIELD_MH_ACCESSOR;
|
||||
}
|
||||
}
|
||||
val = props.getProperty("jdk.reflect.useNativeAccessorOnly");
|
||||
if (val != null && val.equals("true")) {
|
||||
useNativeAccessorOnly = true;
|
||||
}
|
||||
|
||||
disableSerialConstructorChecks =
|
||||
boolean useNativeAccessorOnly =
|
||||
"true".equals(props.getProperty("jdk.reflect.useNativeAccessorOnly"));
|
||||
boolean disableSerialConstructorChecks =
|
||||
"true".equals(props.getProperty("jdk.disableSerialConstructorChecks"));
|
||||
|
||||
return new Config(noInflation,
|
||||
inflationThreshold,
|
||||
useDirectMethodHandle,
|
||||
useNativeAccessorOnly,
|
||||
disableSerialConstructorChecks);
|
||||
return new Config(useNativeAccessorOnly, disableSerialConstructorChecks);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,15 +28,12 @@ package jdk.internal.reflect;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/** Generator for jdk.internal.reflect.MethodAccessor and
|
||||
jdk.internal.reflect.ConstructorAccessor objects using bytecodes to
|
||||
implement reflection. A java.lang.reflect.Method or
|
||||
java.lang.reflect.Constructor object can delegate its invoke or
|
||||
newInstance method to an accessor using native code or to one
|
||||
generated by this class. (Methods and Constructors were merged
|
||||
together in this class to ensure maximum code sharing.) */
|
||||
|
||||
class MethodAccessorGenerator extends AccessorGenerator {
|
||||
/** Generator for jdk.internal.reflect.SerializationConstructorAccessorImpl
|
||||
objects using bytecodes to implement a constructor for serialization
|
||||
returned by ReflectionFactory::newConstructorForSerialization. */
|
||||
|
||||
class SerializationConstructorAccessorGenerator extends AccessorGenerator {
|
||||
|
||||
private static final short NUM_BASE_CPOOL_ENTRIES = (short) 12;
|
||||
// One for invoke() plus one for constructor
|
||||
@ -61,39 +58,7 @@ class MethodAccessorGenerator extends AccessorGenerator {
|
||||
// non-primitive parameter type. Should be incremented by 2.
|
||||
private short nonPrimitiveParametersBaseIdx;
|
||||
|
||||
MethodAccessorGenerator() {
|
||||
}
|
||||
|
||||
/** This routine is not thread-safe */
|
||||
public MethodAccessor generateMethod(Class<?> declaringClass,
|
||||
String name,
|
||||
Class<?>[] parameterTypes,
|
||||
Class<?> returnType,
|
||||
int modifiers)
|
||||
{
|
||||
return (MethodAccessor) generate(declaringClass,
|
||||
name,
|
||||
parameterTypes,
|
||||
returnType,
|
||||
modifiers,
|
||||
false,
|
||||
false,
|
||||
null);
|
||||
}
|
||||
|
||||
/** This routine is not thread-safe */
|
||||
public ConstructorAccessor generateConstructor(Class<?> declaringClass,
|
||||
Class<?>[] parameterTypes,
|
||||
int modifiers)
|
||||
{
|
||||
return (ConstructorAccessor) generate(declaringClass,
|
||||
"<init>",
|
||||
parameterTypes,
|
||||
Void.TYPE,
|
||||
modifiers,
|
||||
true,
|
||||
false,
|
||||
null);
|
||||
SerializationConstructorAccessorGenerator() {
|
||||
}
|
||||
|
||||
/** This routine is not thread-safe */
|
@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeBooleanFieldAccessorImpl extends UnsafeFieldAccessorImpl {
|
||||
UnsafeBooleanFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Boolean.valueOf(getBoolean(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getBoolean(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
throw newGetDoubleIllegalArgumentException();
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Boolean) {
|
||||
unsafe.putBoolean(obj, fieldOffset, ((Boolean) value).booleanValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(z);
|
||||
}
|
||||
unsafe.putBoolean(obj, fieldOffset, z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeByteFieldAccessorImpl extends UnsafeFieldAccessorImpl {
|
||||
UnsafeByteFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Byte.valueOf(getByte(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getByte(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putByte(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(b);
|
||||
}
|
||||
unsafe.putByte(obj, fieldOffset, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeCharacterFieldAccessorImpl extends UnsafeFieldAccessorImpl {
|
||||
UnsafeCharacterFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Character.valueOf(getChar(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getChar(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putChar(obj, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(c);
|
||||
}
|
||||
unsafe.putChar(obj, fieldOffset, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,164 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeDoubleFieldAccessorImpl extends UnsafeFieldAccessorImpl {
|
||||
UnsafeDoubleFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Double.valueOf(getDouble(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getDouble(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putDouble(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putDouble(obj, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putDouble(obj, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putDouble(obj, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putDouble(obj, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
unsafe.putDouble(obj, fieldOffset, ((Float) value).floatValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Double) {
|
||||
unsafe.putDouble(obj, fieldOffset, ((Double) value).doubleValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(d);
|
||||
}
|
||||
unsafe.putDouble(obj, fieldOffset, d);
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
class UnsafeFieldAccessorFactory {
|
||||
static FieldAccessor newFieldAccessor(Field field, boolean isReadOnly) {
|
||||
Class<?> type = field.getType();
|
||||
boolean isStatic = Modifier.isStatic(field.getModifiers());
|
||||
boolean isFinal = Modifier.isFinal(field.getModifiers());
|
||||
boolean isVolatile = Modifier.isVolatile(field.getModifiers());
|
||||
boolean isQualified = isFinal || isVolatile;
|
||||
if (isStatic) {
|
||||
// This code path does not guarantee that the field's
|
||||
// declaring class has been initialized, but it must be
|
||||
// before performing reflective operations.
|
||||
UnsafeFieldAccessorImpl.unsafe.ensureClassInitialized(field.getDeclaringClass());
|
||||
|
||||
if (!isQualified) {
|
||||
if (type == Boolean.TYPE) {
|
||||
return new UnsafeStaticBooleanFieldAccessorImpl(field);
|
||||
} else if (type == Byte.TYPE) {
|
||||
return new UnsafeStaticByteFieldAccessorImpl(field);
|
||||
} else if (type == Short.TYPE) {
|
||||
return new UnsafeStaticShortFieldAccessorImpl(field);
|
||||
} else if (type == Character.TYPE) {
|
||||
return new UnsafeStaticCharacterFieldAccessorImpl(field);
|
||||
} else if (type == Integer.TYPE) {
|
||||
return new UnsafeStaticIntegerFieldAccessorImpl(field);
|
||||
} else if (type == Long.TYPE) {
|
||||
return new UnsafeStaticLongFieldAccessorImpl(field);
|
||||
} else if (type == Float.TYPE) {
|
||||
return new UnsafeStaticFloatFieldAccessorImpl(field);
|
||||
} else if (type == Double.TYPE) {
|
||||
return new UnsafeStaticDoubleFieldAccessorImpl(field);
|
||||
} else {
|
||||
return new UnsafeStaticObjectFieldAccessorImpl(field);
|
||||
}
|
||||
} else {
|
||||
if (type == Boolean.TYPE) {
|
||||
return new UnsafeQualifiedStaticBooleanFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Byte.TYPE) {
|
||||
return new UnsafeQualifiedStaticByteFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Short.TYPE) {
|
||||
return new UnsafeQualifiedStaticShortFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Character.TYPE) {
|
||||
return new UnsafeQualifiedStaticCharacterFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Integer.TYPE) {
|
||||
return new UnsafeQualifiedStaticIntegerFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Long.TYPE) {
|
||||
return new UnsafeQualifiedStaticLongFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Float.TYPE) {
|
||||
return new UnsafeQualifiedStaticFloatFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Double.TYPE) {
|
||||
return new UnsafeQualifiedStaticDoubleFieldAccessorImpl(field, isReadOnly);
|
||||
} else {
|
||||
return new UnsafeQualifiedStaticObjectFieldAccessorImpl(field, isReadOnly);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!isQualified) {
|
||||
if (type == Boolean.TYPE) {
|
||||
return new UnsafeBooleanFieldAccessorImpl(field);
|
||||
} else if (type == Byte.TYPE) {
|
||||
return new UnsafeByteFieldAccessorImpl(field);
|
||||
} else if (type == Short.TYPE) {
|
||||
return new UnsafeShortFieldAccessorImpl(field);
|
||||
} else if (type == Character.TYPE) {
|
||||
return new UnsafeCharacterFieldAccessorImpl(field);
|
||||
} else if (type == Integer.TYPE) {
|
||||
return new UnsafeIntegerFieldAccessorImpl(field);
|
||||
} else if (type == Long.TYPE) {
|
||||
return new UnsafeLongFieldAccessorImpl(field);
|
||||
} else if (type == Float.TYPE) {
|
||||
return new UnsafeFloatFieldAccessorImpl(field);
|
||||
} else if (type == Double.TYPE) {
|
||||
return new UnsafeDoubleFieldAccessorImpl(field);
|
||||
} else {
|
||||
return new UnsafeObjectFieldAccessorImpl(field);
|
||||
}
|
||||
} else {
|
||||
if (type == Boolean.TYPE) {
|
||||
return new UnsafeQualifiedBooleanFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Byte.TYPE) {
|
||||
return new UnsafeQualifiedByteFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Short.TYPE) {
|
||||
return new UnsafeQualifiedShortFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Character.TYPE) {
|
||||
return new UnsafeQualifiedCharacterFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Integer.TYPE) {
|
||||
return new UnsafeQualifiedIntegerFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Long.TYPE) {
|
||||
return new UnsafeQualifiedLongFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Float.TYPE) {
|
||||
return new UnsafeQualifiedFloatFieldAccessorImpl(field, isReadOnly);
|
||||
} else if (type == Double.TYPE) {
|
||||
return new UnsafeQualifiedDoubleFieldAccessorImpl(field, isReadOnly);
|
||||
} else {
|
||||
return new UnsafeQualifiedObjectFieldAccessorImpl(field, isReadOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors. The
|
||||
observation is that there are only nine types of fields from the
|
||||
standpoint of reflection code: the eight primitive types and
|
||||
Object. Using class Unsafe instead of generated bytecodes saves
|
||||
memory and loading time for the dynamically-generated
|
||||
FieldAccessors. */
|
||||
|
||||
abstract class UnsafeFieldAccessorImpl extends FieldAccessorImpl {
|
||||
static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
|
||||
protected final long fieldOffset;
|
||||
protected final boolean isFinal;
|
||||
|
||||
UnsafeFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
int mods = field.getModifiers();
|
||||
this.isFinal = Modifier.isFinal(mods);
|
||||
if (Modifier.isStatic(mods))
|
||||
fieldOffset = unsafe.staticFieldOffset(field);
|
||||
else
|
||||
fieldOffset = unsafe.objectFieldOffset(field);
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeFloatFieldAccessorImpl extends UnsafeFieldAccessorImpl {
|
||||
UnsafeFloatFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Float.valueOf(getFloat(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getFloat(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getFloat(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putFloat(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putFloat(obj, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putFloat(obj, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putFloat(obj, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putFloat(obj, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
unsafe.putFloat(obj, fieldOffset, ((Float) value).floatValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(f);
|
||||
}
|
||||
unsafe.putFloat(obj, fieldOffset, f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeIntegerFieldAccessorImpl extends UnsafeFieldAccessorImpl {
|
||||
UnsafeIntegerFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Integer.valueOf(getInt(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getInt(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putInt(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putInt(obj, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putInt(obj, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putInt(obj, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(i);
|
||||
}
|
||||
unsafe.putInt(obj, fieldOffset, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeLongFieldAccessorImpl extends UnsafeFieldAccessorImpl {
|
||||
UnsafeLongFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Long.valueOf(getLong(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getLong(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getLong(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getLong(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putLong(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putLong(obj, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putLong(obj, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putLong(obj, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putLong(obj, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(l);
|
||||
}
|
||||
unsafe.putLong(obj, fieldOffset, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeObjectFieldAccessorImpl extends UnsafeFieldAccessorImpl {
|
||||
UnsafeObjectFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getReference(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
throw newGetDoubleIllegalArgumentException();
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value != null) {
|
||||
if (!field.getType().isInstance(value)) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
}
|
||||
unsafe.putReference(obj, fieldOffset, value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedBooleanFieldAccessorImpl
|
||||
extends UnsafeQualifiedFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedBooleanFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Boolean.valueOf(getBoolean(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getBooleanVolatile(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
throw newGetDoubleIllegalArgumentException();
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Boolean) {
|
||||
unsafe.putBooleanVolatile(obj, fieldOffset, ((Boolean) value).booleanValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(z);
|
||||
}
|
||||
unsafe.putBooleanVolatile(obj, fieldOffset, z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedByteFieldAccessorImpl
|
||||
extends UnsafeQualifiedFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedByteFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Byte.valueOf(getByte(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getByteVolatile(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putByteVolatile(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(b);
|
||||
}
|
||||
unsafe.putByteVolatile(obj, fieldOffset, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedCharacterFieldAccessorImpl
|
||||
extends UnsafeQualifiedFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedCharacterFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Character.valueOf(getChar(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getCharVolatile(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putCharVolatile(obj, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(c);
|
||||
}
|
||||
unsafe.putCharVolatile(obj, fieldOffset, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,166 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedDoubleFieldAccessorImpl
|
||||
extends UnsafeQualifiedFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedDoubleFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Double.valueOf(getDouble(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getDoubleVolatile(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putDoubleVolatile(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putDoubleVolatile(obj, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putDoubleVolatile(obj, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putDoubleVolatile(obj, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putDoubleVolatile(obj, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
unsafe.putDoubleVolatile(obj, fieldOffset, ((Float) value).floatValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Double) {
|
||||
unsafe.putDoubleVolatile(obj, fieldOffset, ((Double) value).doubleValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(d);
|
||||
}
|
||||
unsafe.putDoubleVolatile(obj, fieldOffset, d);
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/**
|
||||
* Base class for jdk.internal.misc.Unsafe-based FieldAccessors for fields with
|
||||
* final or volatile qualifiers. These differ from unqualified
|
||||
* versions in that (1) they check for read-only status (2) they use
|
||||
* the volatile forms of Unsafe get/put methods. (When accessed via
|
||||
* reflection, finals act as slightly "lighter" forms of volatiles. So
|
||||
* the volatile forms are heavier than necessary in terms of
|
||||
* underlying reordering rules and memory barriers, but preserve
|
||||
* correctness.)
|
||||
*/
|
||||
|
||||
abstract class UnsafeQualifiedFieldAccessorImpl
|
||||
extends UnsafeFieldAccessorImpl
|
||||
{
|
||||
protected final boolean isReadOnly;
|
||||
|
||||
UnsafeQualifiedFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field);
|
||||
this.isReadOnly = isReadOnly;
|
||||
}
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedFloatFieldAccessorImpl
|
||||
extends UnsafeQualifiedFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedFloatFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Float.valueOf(getFloat(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getFloatVolatile(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getFloat(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putFloatVolatile(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putFloatVolatile(obj, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putFloatVolatile(obj, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putFloatVolatile(obj, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putFloatVolatile(obj, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
unsafe.putFloatVolatile(obj, fieldOffset, ((Float) value).floatValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(f);
|
||||
}
|
||||
unsafe.putFloatVolatile(obj, fieldOffset, f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedIntegerFieldAccessorImpl
|
||||
extends UnsafeQualifiedFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedIntegerFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Integer.valueOf(getInt(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getIntVolatile(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putIntVolatile(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putIntVolatile(obj, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putIntVolatile(obj, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putIntVolatile(obj, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(i);
|
||||
}
|
||||
unsafe.putIntVolatile(obj, fieldOffset, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedLongFieldAccessorImpl
|
||||
extends UnsafeQualifiedFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedLongFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Long.valueOf(getLong(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getLongVolatile(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getLong(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getLong(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putLongVolatile(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putLongVolatile(obj, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putLongVolatile(obj, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putLongVolatile(obj, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putLongVolatile(obj, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(l);
|
||||
}
|
||||
unsafe.putLongVolatile(obj, fieldOffset, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedObjectFieldAccessorImpl
|
||||
extends UnsafeQualifiedFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedObjectFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getReferenceVolatile(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
throw newGetDoubleIllegalArgumentException();
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value != null) {
|
||||
if (!field.getType().isInstance(value)) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
}
|
||||
unsafe.putReferenceVolatile(obj, fieldOffset, value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedShortFieldAccessorImpl
|
||||
extends UnsafeQualifiedFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedShortFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Short.valueOf(getShort(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getShortVolatile(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putShortVolatile(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putShortVolatile(obj, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setShort(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(s);
|
||||
}
|
||||
unsafe.putShortVolatile(obj, fieldOffset, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedStaticBooleanFieldAccessorImpl
|
||||
extends UnsafeQualifiedStaticFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedStaticBooleanFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Boolean.valueOf(getBoolean(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getBooleanVolatile(base, fieldOffset);
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
throw newGetDoubleIllegalArgumentException();
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Boolean) {
|
||||
unsafe.putBooleanVolatile(base, fieldOffset, ((Boolean) value).booleanValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(z);
|
||||
}
|
||||
unsafe.putBooleanVolatile(base, fieldOffset, z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedStaticByteFieldAccessorImpl
|
||||
extends UnsafeQualifiedStaticFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedStaticByteFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Byte.valueOf(getByte(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getByteVolatile(base, fieldOffset);
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putByteVolatile(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(b);
|
||||
}
|
||||
unsafe.putByteVolatile(base, fieldOffset, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedStaticCharacterFieldAccessorImpl
|
||||
extends UnsafeQualifiedStaticFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedStaticCharacterFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Character.valueOf(getChar(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getCharVolatile(base, fieldOffset);
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putCharVolatile(base, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(c);
|
||||
}
|
||||
unsafe.putCharVolatile(base, fieldOffset, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,163 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedStaticDoubleFieldAccessorImpl
|
||||
extends UnsafeQualifiedStaticFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedStaticDoubleFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Double.valueOf(getDouble(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getDoubleVolatile(base, fieldOffset);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putDoubleVolatile(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putDoubleVolatile(base, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putDoubleVolatile(base, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putDoubleVolatile(base, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putDoubleVolatile(base, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
unsafe.putDoubleVolatile(base, fieldOffset, ((Float) value).floatValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Double) {
|
||||
unsafe.putDoubleVolatile(base, fieldOffset, ((Double) value).doubleValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(d);
|
||||
}
|
||||
unsafe.putDoubleVolatile(base, fieldOffset, d);
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.security.AccessController;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors for final or
|
||||
static volatile fields. */
|
||||
|
||||
abstract class UnsafeQualifiedStaticFieldAccessorImpl
|
||||
extends UnsafeStaticFieldAccessorImpl
|
||||
{
|
||||
protected final boolean isReadOnly;
|
||||
|
||||
UnsafeQualifiedStaticFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field);
|
||||
this.isReadOnly = isReadOnly;
|
||||
}
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedStaticFloatFieldAccessorImpl
|
||||
extends UnsafeQualifiedStaticFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedStaticFloatFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Float.valueOf(getFloat(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getFloatVolatile(base, fieldOffset);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getFloat(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putFloatVolatile(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putFloatVolatile(base, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putFloatVolatile(base, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putFloatVolatile(base, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putFloatVolatile(base, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
unsafe.putFloatVolatile(base, fieldOffset, ((Float) value).floatValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(f);
|
||||
}
|
||||
unsafe.putFloatVolatile(base, fieldOffset, f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedStaticIntegerFieldAccessorImpl
|
||||
extends UnsafeQualifiedStaticFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedStaticIntegerFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Integer.valueOf(getInt(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getIntVolatile(base, fieldOffset);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putIntVolatile(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putIntVolatile(base, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putIntVolatile(base, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putIntVolatile(base, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(i);
|
||||
}
|
||||
unsafe.putIntVolatile(base, fieldOffset, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,155 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedStaticLongFieldAccessorImpl
|
||||
extends UnsafeQualifiedStaticFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedStaticLongFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Long.valueOf(getLong(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getLongVolatile(base, fieldOffset);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getLong(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getLong(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putLongVolatile(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putLongVolatile(base, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putLongVolatile(base, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putLongVolatile(base, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putLongVolatile(base, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(l);
|
||||
}
|
||||
unsafe.putLongVolatile(base, fieldOffset, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedStaticObjectFieldAccessorImpl
|
||||
extends UnsafeQualifiedStaticFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedStaticObjectFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getReferenceVolatile(base, fieldOffset);
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
throw newGetDoubleIllegalArgumentException();
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value != null) {
|
||||
if (!field.getType().isInstance(value)) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
}
|
||||
unsafe.putReferenceVolatile(base, fieldOffset, value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeQualifiedStaticShortFieldAccessorImpl
|
||||
extends UnsafeQualifiedStaticFieldAccessorImpl
|
||||
{
|
||||
UnsafeQualifiedStaticShortFieldAccessorImpl(Field field, boolean isReadOnly) {
|
||||
super(field, isReadOnly);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Short.valueOf(getShort(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getShortVolatile(base, fieldOffset);
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putShortVolatile(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putShortVolatile(base, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setShort(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isReadOnly) {
|
||||
throwFinalFieldIllegalAccessException(s);
|
||||
}
|
||||
unsafe.putShortVolatile(base, fieldOffset, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeShortFieldAccessorImpl extends UnsafeFieldAccessorImpl {
|
||||
UnsafeShortFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Short.valueOf(getShort(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
ensureObj(obj);
|
||||
return unsafe.getShort(obj, fieldOffset);
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putShort(obj, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putShort(obj, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setShort(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
ensureObj(obj);
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(s);
|
||||
}
|
||||
unsafe.putShort(obj, fieldOffset, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeStaticBooleanFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
|
||||
UnsafeStaticBooleanFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Boolean.valueOf(getBoolean(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getBoolean(base, fieldOffset);
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
throw newGetDoubleIllegalArgumentException();
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Boolean) {
|
||||
unsafe.putBoolean(base, fieldOffset, ((Boolean) value).booleanValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(z);
|
||||
}
|
||||
unsafe.putBoolean(base, fieldOffset, z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeStaticByteFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
|
||||
UnsafeStaticByteFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Byte.valueOf(getByte(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getByte(base, fieldOffset);
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getByte(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putByte(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(b);
|
||||
}
|
||||
unsafe.putByte(base, fieldOffset, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeStaticCharacterFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
|
||||
UnsafeStaticCharacterFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Character.valueOf(getChar(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getChar(base, fieldOffset);
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getChar(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putChar(base, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(c);
|
||||
}
|
||||
unsafe.putChar(base, fieldOffset, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeStaticDoubleFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
|
||||
UnsafeStaticDoubleFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Double.valueOf(getDouble(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getDouble(base, fieldOffset);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putDouble(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putDouble(base, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putDouble(base, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putDouble(base, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putDouble(base, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
unsafe.putDouble(base, fieldOffset, ((Float) value).floatValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Double) {
|
||||
unsafe.putDouble(base, fieldOffset, ((Double) value).doubleValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setDouble(obj, f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(d);
|
||||
}
|
||||
unsafe.putDouble(base, fieldOffset, d);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Set;
|
||||
|
||||
/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors for static
|
||||
fields. The observation is that there are only nine types of
|
||||
fields from the standpoint of reflection code: the eight primitive
|
||||
types and Object. Using class Unsafe instead of generated
|
||||
bytecodes saves memory and loading time for the
|
||||
dynamically-generated FieldAccessors. */
|
||||
|
||||
abstract class UnsafeStaticFieldAccessorImpl extends UnsafeFieldAccessorImpl {
|
||||
static {
|
||||
Reflection.registerFieldsToFilter(UnsafeStaticFieldAccessorImpl.class,
|
||||
Set.of("base"));
|
||||
}
|
||||
|
||||
protected final Object base; // base
|
||||
|
||||
UnsafeStaticFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
base = unsafe.staticFieldBase(field);
|
||||
}
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeStaticFloatFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
|
||||
UnsafeStaticFloatFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Float.valueOf(getFloat(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getFloat(base, fieldOffset);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getFloat(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putFloat(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putFloat(base, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putFloat(base, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putFloat(base, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putFloat(base, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
unsafe.putFloat(base, fieldOffset, ((Float) value).floatValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setFloat(obj, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(f);
|
||||
}
|
||||
unsafe.putFloat(base, fieldOffset, f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeStaticIntegerFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
|
||||
UnsafeStaticIntegerFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Integer.valueOf(getInt(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getInt(base, fieldOffset);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getInt(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putInt(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putInt(base, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putInt(base, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putInt(base, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setInt(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(i);
|
||||
}
|
||||
unsafe.putInt(base, fieldOffset, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,153 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeStaticLongFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
|
||||
UnsafeStaticLongFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Long.valueOf(getLong(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getLong(base, fieldOffset);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getLong(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getLong(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putLong(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putLong(base, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
unsafe.putLong(base, fieldOffset, ((Character) value).charValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
unsafe.putLong(base, fieldOffset, ((Integer) value).intValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
unsafe.putLong(base, fieldOffset, ((Long) value).longValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setLong(obj, i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(l);
|
||||
}
|
||||
unsafe.putLong(base, fieldOffset, l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeStaticObjectFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
|
||||
UnsafeStaticObjectFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getReference(base, fieldOffset);
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
throw newGetShortIllegalArgumentException();
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
throw newGetIntIllegalArgumentException();
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
throw newGetLongIllegalArgumentException();
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
throw newGetFloatIllegalArgumentException();
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
throw newGetDoubleIllegalArgumentException();
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value != null) {
|
||||
if (!field.getType().isInstance(value)) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
}
|
||||
unsafe.putReference(base, fieldOffset, value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.internal.reflect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
class UnsafeStaticShortFieldAccessorImpl extends UnsafeStaticFieldAccessorImpl {
|
||||
UnsafeStaticShortFieldAccessorImpl(Field field) {
|
||||
super(field);
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException {
|
||||
return Short.valueOf(getShort(obj));
|
||||
}
|
||||
|
||||
public boolean getBoolean(Object obj) throws IllegalArgumentException {
|
||||
throw newGetBooleanIllegalArgumentException();
|
||||
}
|
||||
|
||||
public byte getByte(Object obj) throws IllegalArgumentException {
|
||||
throw newGetByteIllegalArgumentException();
|
||||
}
|
||||
|
||||
public char getChar(Object obj) throws IllegalArgumentException {
|
||||
throw newGetCharIllegalArgumentException();
|
||||
}
|
||||
|
||||
public short getShort(Object obj) throws IllegalArgumentException {
|
||||
return unsafe.getShort(base, fieldOffset);
|
||||
}
|
||||
|
||||
public int getInt(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public long getLong(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public float getFloat(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public double getDouble(Object obj) throws IllegalArgumentException {
|
||||
return getShort(obj);
|
||||
}
|
||||
|
||||
public void set(Object obj, Object value)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(value);
|
||||
}
|
||||
if (value == null) {
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
unsafe.putShort(base, fieldOffset, ((Byte) value).byteValue());
|
||||
return;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
unsafe.putShort(base, fieldOffset, ((Short) value).shortValue());
|
||||
return;
|
||||
}
|
||||
throwSetIllegalArgumentException(value);
|
||||
}
|
||||
|
||||
public void setBoolean(Object obj, boolean z)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(z);
|
||||
}
|
||||
|
||||
public void setByte(Object obj, byte b)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
setShort(obj, b);
|
||||
}
|
||||
|
||||
public void setChar(Object obj, char c)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(c);
|
||||
}
|
||||
|
||||
public void setShort(Object obj, short s)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
if (isFinal) {
|
||||
throwFinalFieldIllegalAccessException(s);
|
||||
}
|
||||
unsafe.putShort(base, fieldOffset, s);
|
||||
}
|
||||
|
||||
public void setInt(Object obj, int i)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(i);
|
||||
}
|
||||
|
||||
public void setLong(Object obj, long l)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(l);
|
||||
}
|
||||
|
||||
public void setFloat(Object obj, float f)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(f);
|
||||
}
|
||||
|
||||
public void setDouble(Object obj, double d)
|
||||
throws IllegalArgumentException, IllegalAccessException
|
||||
{
|
||||
throwSetIllegalArgumentException(d);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,23 +24,9 @@
|
||||
*/
|
||||
|
||||
#include "jvm.h"
|
||||
#include "jdk_internal_reflect_NativeConstructorAccessorImpl.h"
|
||||
#include "jdk_internal_reflect_NativeMethodAccessorImpl.h"
|
||||
#include "jdk_internal_reflect_DirectMethodHandleAccessor_NativeAccessor.h"
|
||||
#include "jdk_internal_reflect_DirectConstructorHandleAccessor_NativeAccessor.h"
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_jdk_internal_reflect_NativeMethodAccessorImpl_invoke0
|
||||
(JNIEnv *env, jclass unused, jobject m, jobject obj, jobjectArray args)
|
||||
{
|
||||
return JVM_InvokeMethod(env, m, obj, args);
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_jdk_internal_reflect_NativeConstructorAccessorImpl_newInstance0
|
||||
(JNIEnv *env, jclass unused, jobject c, jobjectArray args)
|
||||
{
|
||||
return JVM_NewInstanceFromConstructor(env, c, args);
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_jdk_internal_reflect_DirectMethodHandleAccessor_00024NativeAccessor_invoke0
|
||||
(JNIEnv *env, jclass unused, jobject m, jobject obj, jobjectArray args)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -81,7 +81,7 @@ public class MethodIsIgnoredBySecurityStackWalkTest {
|
||||
testCases.put(aClass.getMethod("invoke", Object.class,
|
||||
Object[].class), true);
|
||||
|
||||
aClass = Class.forName("jdk.internal.reflect.NativeMethodAccessorImpl");
|
||||
aClass = Class.forName("jdk.internal.reflect.DirectMethodHandleAccessor$NativeAccessor");
|
||||
testCases.put(aClass.getMethod("invoke", Object.class,
|
||||
Object[].class), true);
|
||||
testCases.put(aClass.getDeclaredMethod("invoke0", Method.class,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,7 +31,6 @@
|
||||
* PB_A_PI.jcod \
|
||||
* PB_PA_I.jcod
|
||||
* @run main TestInterfaceMethodSelection
|
||||
* @run main/othervm -Dsun.reflect.noInflation=true TestInterfaceMethodSelection
|
||||
*/
|
||||
|
||||
// The first run will use NativeMethodAccessor and due to the limited number
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,7 +31,6 @@
|
||||
* PC_B_PA.jcod \
|
||||
* PC_PB_A.jcod
|
||||
* @run main/othervm TestMethodSelection
|
||||
* @run main/othervm -Dsun.reflect.noInflation=true TestMethodSelection
|
||||
*/
|
||||
|
||||
// The first run will use NativeMethodAccessor and due to the limited number
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,6 @@
|
||||
* @summary Test access to private constructors between nestmates and nest-host
|
||||
* using different flavours of named nested types using core reflection
|
||||
* @run main TestReflection
|
||||
* @run main/othervm -Dsun.reflect.noInflation=true TestReflection
|
||||
*/
|
||||
|
||||
// The first run will use NativeConstructorAccessor and due to the limited
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,6 @@
|
||||
* @summary Test access to private methods between nestmates and nest-host
|
||||
* using different flavours of named nested types using core reflection
|
||||
* @run main TestReflection
|
||||
* @run main/othervm -Dsun.reflect.noInflation=true TestReflection
|
||||
*/
|
||||
|
||||
// The first run will use NativeMethodAccessor and due to the limited number
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,7 +28,6 @@
|
||||
* is an inheritance hierarchy and we invoke private methods that
|
||||
* exist in specific classes in the hierarchy.
|
||||
* @run main TestReflectionHierarchy
|
||||
* @run main/othervm -Dsun.reflect.noInflation=true TestReflectionHierarchy
|
||||
*/
|
||||
|
||||
// The first run will use NativeMethodAccessor and due to the limited number
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,6 @@
|
||||
* @summary Test access to private static methods between nestmates and nest-host
|
||||
* using different flavours of named nested types using core reflection
|
||||
* @run main TestReflection
|
||||
* @run main/othervm -Dsun.reflect.noInflation=true TestReflection
|
||||
*/
|
||||
|
||||
// The first run will use NativeMethodAccessor and due to the limited number
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -46,8 +46,6 @@ import static java.lang.StackWalker.Option.*;
|
||||
public class MultiThreadStackWalk {
|
||||
|
||||
static Set<String> infrastructureClasses = new TreeSet<>(Arrays.asList(
|
||||
"jdk.internal.reflect.NativeMethodAccessorImpl",
|
||||
"jdk.internal.reflect.DelegatingMethodAccessorImpl",
|
||||
"java.lang.reflect.Method",
|
||||
"com.sun.javatest.regtest.MainWrapper$MainThread",
|
||||
"java.lang.Thread"
|
||||
|
@ -55,8 +55,6 @@ public class StackWalkTest {
|
||||
private static final int MAX_RANDOM_DEPTH = 1000;
|
||||
|
||||
static final Set<String> infrastructureClasses = new TreeSet<>(Arrays.asList(
|
||||
"jdk.internal.reflect.NativeMethodAccessorImpl",
|
||||
"jdk.internal.reflect.DelegatingMethodAccessorImpl",
|
||||
"java.lang.reflect.Method",
|
||||
"com.sun.javatest.regtest.MainWrapper$MainThread",
|
||||
"com.sun.javatest.regtest.agent.MainWrapper$MainThread",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,6 @@
|
||||
* @summary Lambda serialization fails once reflection proxy generation kicks in
|
||||
* @author Robert Field
|
||||
* @run main/othervm RepetitiveLambdaSerialization
|
||||
* @run main/othervm -Dsun.reflect.noInflation=true RepetitiveLambdaSerialization
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,7 +29,6 @@
|
||||
* @summary Restriction on reflective call to MethodHandles.lookup method
|
||||
* @run main java.base/java.lang.LookupTest
|
||||
* @run main ReflectiveLookupTest
|
||||
* @run main/othervm -Dsun.reflect.noInflation=true ReflectiveLookupTest
|
||||
*/
|
||||
|
||||
import java.lang.invoke.*;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,8 +24,7 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 8277451
|
||||
* @run testng/othervm -Djdk.reflect.useDirectMethodHandle=true NegativeTest
|
||||
* @run testng/othervm -Djdk.reflect.useDirectMethodHandle=false NegativeTest
|
||||
* @run testng NegativeTest
|
||||
* @summary Test exception thrown due to bad receiver and bad value on
|
||||
* Field with and without setAccessible(true)
|
||||
*/
|
||||
|
@ -25,7 +25,6 @@
|
||||
* @test
|
||||
* @bug 8304585
|
||||
* @run junit CallerSensitiveMethodInvoke
|
||||
* @run junit/othervm -Djdk.reflect.useDirectMethodHandle=false CallerSensitiveMethodInvoke
|
||||
* @summary Test Method::invoke that wraps exception in InvocationTargetException properly
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,8 +28,7 @@
|
||||
* makes use of the same caching mechanism as used for autoboxing
|
||||
* when wrapping returned values of the primitive types.
|
||||
* @author Andrej Golovnin
|
||||
* @run main/othervm -Dsun.reflect.noInflation=true TestMethodReflectValueOf
|
||||
* @run main/othervm -Dsun.reflect.noInflation=false -Dsun.reflect.inflationThreshold=500 TestMethodReflectValueOf
|
||||
* @run main/othervm TestMethodReflectValueOf
|
||||
*/
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@ -26,16 +26,9 @@
|
||||
* @bug 8271820 8300924
|
||||
* @modules java.base/jdk.internal.reflect
|
||||
* @summary Test compliance of ConstructorAccessor, FieldAccessor, MethodAccessor implementations
|
||||
* @run testng/othervm --add-exports java.base/jdk.internal.reflect=ALL-UNNAMED -Djdk.reflect.useDirectMethodHandle=true -XX:-ShowCodeDetailsInExceptionMessages MethodHandleAccessorsTest
|
||||
* @run testng/othervm --add-exports java.base/jdk.internal.reflect=ALL-UNNAMED -XX:-ShowCodeDetailsInExceptionMessages MethodHandleAccessorsTest
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @modules java.base/jdk.internal.reflect
|
||||
* @run testng/othervm --add-exports java.base/jdk.internal.reflect=ALL-UNNAMED -Djdk.reflect.useDirectMethodHandle=false -XX:-ShowCodeDetailsInExceptionMessages MethodHandleAccessorsTest
|
||||
*/
|
||||
|
||||
|
||||
import jdk.internal.reflect.ConstructorAccessor;
|
||||
import jdk.internal.reflect.FieldAccessor;
|
||||
import jdk.internal.reflect.MethodAccessor;
|
||||
@ -55,9 +48,6 @@ import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class MethodHandleAccessorsTest {
|
||||
static final boolean newImpl = Boolean.getBoolean("jdk.reflect.useDirectMethodHandle");
|
||||
|
||||
|
||||
public static void public_static_V() {}
|
||||
|
||||
public static int public_static_I() { return 42; }
|
||||
@ -494,21 +484,16 @@ public class MethodHandleAccessorsTest {
|
||||
|
||||
new Object[] {"public_static_I_I", int.class, null, new Object[]{"a"}, null, mismatched_argument_type},
|
||||
new Object[] {"public_I_I", int.class, inst, new Object[]{"a"}, null, mismatched_argument_type},
|
||||
new Object[] {"public_static_I_I", int.class, null, new Object[]{12, 13}, null,
|
||||
newImpl ? wrong_argument_count_no_details : wrong_argument_count},
|
||||
new Object[] {"public_I_I", int.class, inst, new Object[]{12, 13}, null,
|
||||
newImpl ? wrong_argument_count_no_details : wrong_argument_count},
|
||||
new Object[] {"public_static_I_I", int.class, null, new Object[]{12, 13}, null, wrong_argument_count_no_details},
|
||||
new Object[] {"public_I_I", int.class, inst, new Object[]{12, 13}, null, wrong_argument_count_no_details},
|
||||
new Object[] {"public_I_I", int.class, wrongInst, new Object[]{12}, 12, mismatched_target_type},
|
||||
new Object[] {"public_I_I", int.class, null, new Object[]{12}, 12, null_target},
|
||||
|
||||
new Object[] {"public_static_I_V", int.class, null, null, null,
|
||||
newImpl ? wrong_argument_count_no_details : null_argument},
|
||||
new Object[] {"public_static_I_V", int.class, null, new Object[]{null}, null,
|
||||
newImpl ? null_argument_value_npe : null_argument_value},
|
||||
new Object[] {"public_static_I_V", int.class, null, null, null, wrong_argument_count_no_details},
|
||||
new Object[] {"public_static_I_V", int.class, null, new Object[]{null}, null, null_argument_value_npe},
|
||||
new Object[] {"public_I_I", int.class, inst, null, null, null_argument},
|
||||
|
||||
new Object[] {"public_I_I", int.class, inst, new Object[]{null}, null,
|
||||
newImpl ? null_argument_value_npe : null_argument_value},
|
||||
new Object[] {"public_I_I", int.class, inst, new Object[]{null}, null, null_argument_value_npe},
|
||||
};
|
||||
}
|
||||
|
||||
@ -524,12 +509,9 @@ public class MethodHandleAccessorsTest {
|
||||
new Object[]{"public_static_V_L4", params_L4, null, new Object[4], null, noException},
|
||||
new Object[]{"public_V_L5", params_L5, inst, new Object[5], null, noException},
|
||||
// wrong arguments
|
||||
new Object[]{"public_static_V_L3", params_L3, null, null, null,
|
||||
newImpl ? wrong_argument_count_zero_args : wrong_argument_count_no_details},
|
||||
new Object[]{"public_static_V_L4", params_L4, null, new Object[0], null,
|
||||
newImpl ? wrong_argument_count_zero_args : wrong_argument_count_no_details},
|
||||
new Object[]{"public_V_L5", params_L5, inst, null, null,
|
||||
newImpl ? wrong_argument_count_zero_args : wrong_argument_count_no_details},
|
||||
new Object[]{"public_static_V_L3", params_L3, null, null, null, wrong_argument_count_zero_args},
|
||||
new Object[]{"public_static_V_L4", params_L4, null, new Object[0], null, wrong_argument_count_zero_args},
|
||||
new Object[]{"public_V_L5", params_L5, inst, null, null, wrong_argument_count_zero_args},
|
||||
};
|
||||
}
|
||||
|
||||
@ -615,10 +597,8 @@ public class MethodHandleAccessorsTest {
|
||||
return new Object[][]{
|
||||
new Object[]{params_L3, new Object[3], new Public(o, o, o), noException},
|
||||
new Object[]{params_L4, new Object[4], new Public(o, o, o, o), noException},
|
||||
new Object[]{params_L3, new Object[]{}, null,
|
||||
newImpl ? wrong_argument_count_zero_args : wrong_argument_count_no_details},
|
||||
new Object[]{params_L4, null, null,
|
||||
newImpl ? wrong_argument_count_zero_args : wrong_argument_count_no_details},
|
||||
new Object[]{params_L3, new Object[]{}, null, wrong_argument_count_zero_args},
|
||||
new Object[]{params_L4, null, null, wrong_argument_count_zero_args},
|
||||
};
|
||||
}
|
||||
|
||||
@ -668,16 +648,13 @@ public class MethodHandleAccessorsTest {
|
||||
|
||||
@DataProvider(name = "readAccess")
|
||||
private Object[][] readAccess() {
|
||||
boolean newImpl = Boolean.getBoolean("jdk.reflect.useDirectMethodHandle");
|
||||
String wrongInst = new String();
|
||||
return new Object[][]{
|
||||
new Object[]{"i", new Public(100), 100, noException},
|
||||
new Object[]{"s", new Public("test"), "test", noException},
|
||||
new Object[]{"s", null, "test", null_target},
|
||||
new Object[]{"s", wrongInst, "test",
|
||||
newImpl ? cannot_get_field : cannot_set_field},
|
||||
new Object[]{"b", wrongInst, 0,
|
||||
newImpl ? cannot_get_field : cannot_set_field},
|
||||
new Object[]{"s", wrongInst, "test", cannot_get_field},
|
||||
new Object[]{"b", wrongInst, 0, cannot_get_field},
|
||||
};
|
||||
}
|
||||
@DataProvider(name = "writeAccess")
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,7 +28,6 @@
|
||||
* @modules jdk.compiler
|
||||
* @build CustomLoaderTest jdk.test.lib.compiler.CompilerUtils
|
||||
* @run testng/othervm CustomLoaderTest
|
||||
* @run testng/othervm -Dsun.reflect.noInflation=true CustomLoaderTest
|
||||
*
|
||||
* @summary Test method whose parameter types and return type are not visible to the caller.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,7 +31,7 @@
|
||||
* @modules java.base/jdk.internal.reflect
|
||||
* @build SetupGetCallerClass boot.GetCallerClass
|
||||
* @run driver SetupGetCallerClass
|
||||
* @run main/othervm -Xbootclasspath/a:bcp -Djdk.reflect.useDirectMethodHandle=true GetCallerClassTest
|
||||
* @run main/othervm -Xbootclasspath/a:bcp GetCallerClassTest
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -40,25 +40,7 @@
|
||||
* @modules java.base/jdk.internal.reflect
|
||||
* @build SetupGetCallerClass boot.GetCallerClass
|
||||
* @run driver SetupGetCallerClass
|
||||
* @run main/othervm -Xbootclasspath/a:bcp -Djdk.reflect.useDirectMethodHandle=true -Djdk.reflect.useNativeAccessorOnly=true GetCallerClassTest
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Verify NativeMethodAccessorImpl
|
||||
* @modules java.base/jdk.internal.reflect
|
||||
* @build SetupGetCallerClass boot.GetCallerClass
|
||||
* @run driver SetupGetCallerClass
|
||||
* @run main/othervm -Xbootclasspath/a:bcp -Djdk.reflect.useDirectMethodHandle=false -Dsun.reflect.noInflation=false GetCallerClassTest
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Verify the old generated MethodAccessor
|
||||
* @modules java.base/jdk.internal.reflect
|
||||
* @build SetupGetCallerClass boot.GetCallerClass
|
||||
* @run driver SetupGetCallerClass
|
||||
* @run main/othervm -Xbootclasspath/a:bcp -Djdk.reflect.useDirectMethodHandle=false -Dsun.reflect.noInflation=true GetCallerClassTest
|
||||
* @run main/othervm -Xbootclasspath/a:bcp -Djdk.reflect.useNativeAccessorOnly=true GetCallerClassTest
|
||||
*/
|
||||
|
||||
import boot.GetCallerClass;
|
||||
|
Loading…
x
Reference in New Issue
Block a user