mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8305104: Remove the old core reflection implementation
Reviewed-by: dholmes, alanb
This commit is contained in:
parent
bfef3c3e80
commit
9bfe415f66
79 changed files with 99 additions and 6336 deletions
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue