Path: blob/master/src/java.base/share/classes/jdk/internal/reflect/UnsafeQualifiedStaticBooleanFieldAccessorImpl.java
41159 views
/*1* Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package jdk.internal.reflect;2627import java.lang.reflect.Field;2829class UnsafeQualifiedStaticBooleanFieldAccessorImpl30extends UnsafeQualifiedStaticFieldAccessorImpl31{32UnsafeQualifiedStaticBooleanFieldAccessorImpl(Field field, boolean isReadOnly) {33super(field, isReadOnly);34}3536public Object get(Object obj) throws IllegalArgumentException {37return Boolean.valueOf(getBoolean(obj));38}3940public boolean getBoolean(Object obj) throws IllegalArgumentException {41return unsafe.getBooleanVolatile(base, fieldOffset);42}4344public byte getByte(Object obj) throws IllegalArgumentException {45throw newGetByteIllegalArgumentException();46}4748public char getChar(Object obj) throws IllegalArgumentException {49throw newGetCharIllegalArgumentException();50}5152public short getShort(Object obj) throws IllegalArgumentException {53throw newGetShortIllegalArgumentException();54}5556public int getInt(Object obj) throws IllegalArgumentException {57throw newGetIntIllegalArgumentException();58}5960public long getLong(Object obj) throws IllegalArgumentException {61throw newGetLongIllegalArgumentException();62}6364public float getFloat(Object obj) throws IllegalArgumentException {65throw newGetFloatIllegalArgumentException();66}6768public double getDouble(Object obj) throws IllegalArgumentException {69throw newGetDoubleIllegalArgumentException();70}7172public void set(Object obj, Object value)73throws IllegalArgumentException, IllegalAccessException74{75if (isReadOnly) {76throwFinalFieldIllegalAccessException(value);77}78if (value == null) {79throwSetIllegalArgumentException(value);80}81if (value instanceof Boolean) {82unsafe.putBooleanVolatile(base, fieldOffset, ((Boolean) value).booleanValue());83return;84}85throwSetIllegalArgumentException(value);86}8788public void setBoolean(Object obj, boolean z)89throws IllegalArgumentException, IllegalAccessException90{91if (isReadOnly) {92throwFinalFieldIllegalAccessException(z);93}94unsafe.putBooleanVolatile(base, fieldOffset, z);95}9697public void setByte(Object obj, byte b)98throws IllegalArgumentException, IllegalAccessException99{100throwSetIllegalArgumentException(b);101}102103public void setChar(Object obj, char c)104throws IllegalArgumentException, IllegalAccessException105{106throwSetIllegalArgumentException(c);107}108109public void setShort(Object obj, short s)110throws IllegalArgumentException, IllegalAccessException111{112throwSetIllegalArgumentException(s);113}114115public void setInt(Object obj, int i)116throws IllegalArgumentException, IllegalAccessException117{118throwSetIllegalArgumentException(i);119}120121public void setLong(Object obj, long l)122throws IllegalArgumentException, IllegalAccessException123{124throwSetIllegalArgumentException(l);125}126127public void setFloat(Object obj, float f)128throws IllegalArgumentException, IllegalAccessException129{130throwSetIllegalArgumentException(f);131}132133public void setDouble(Object obj, double d)134throws IllegalArgumentException, IllegalAccessException135{136throwSetIllegalArgumentException(d);137}138}139140141