001: /*
002: * Copyright 2001-2005 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package sun.reflect;
027:
028: import java.lang.reflect.Field;
029:
030: class UnsafeObjectFieldAccessorImpl extends UnsafeFieldAccessorImpl {
031: UnsafeObjectFieldAccessorImpl(Field field) {
032: super (field);
033: }
034:
035: public Object get(Object obj) throws IllegalArgumentException {
036: ensureObj(obj);
037: return unsafe.getObject(obj, fieldOffset);
038: }
039:
040: public boolean getBoolean(Object obj)
041: throws IllegalArgumentException {
042: throw newGetBooleanIllegalArgumentException();
043: }
044:
045: public byte getByte(Object obj) throws IllegalArgumentException {
046: throw newGetByteIllegalArgumentException();
047: }
048:
049: public char getChar(Object obj) throws IllegalArgumentException {
050: throw newGetCharIllegalArgumentException();
051: }
052:
053: public short getShort(Object obj) throws IllegalArgumentException {
054: throw newGetShortIllegalArgumentException();
055: }
056:
057: public int getInt(Object obj) throws IllegalArgumentException {
058: throw newGetIntIllegalArgumentException();
059: }
060:
061: public long getLong(Object obj) throws IllegalArgumentException {
062: throw newGetLongIllegalArgumentException();
063: }
064:
065: public float getFloat(Object obj) throws IllegalArgumentException {
066: throw newGetFloatIllegalArgumentException();
067: }
068:
069: public double getDouble(Object obj) throws IllegalArgumentException {
070: throw newGetDoubleIllegalArgumentException();
071: }
072:
073: public void set(Object obj, Object value)
074: throws IllegalArgumentException, IllegalAccessException {
075: ensureObj(obj);
076: if (isFinal) {
077: throwFinalFieldIllegalAccessException(value);
078: }
079: if (value != null) {
080: if (!field.getType().isAssignableFrom(value.getClass())) {
081: throwSetIllegalArgumentException(value);
082: }
083: }
084: unsafe.putObject(obj, fieldOffset, value);
085: }
086:
087: public void setBoolean(Object obj, boolean z)
088: throws IllegalArgumentException, IllegalAccessException {
089: throwSetIllegalArgumentException(z);
090: }
091:
092: public void setByte(Object obj, byte b)
093: throws IllegalArgumentException, IllegalAccessException {
094: throwSetIllegalArgumentException(b);
095: }
096:
097: public void setChar(Object obj, char c)
098: throws IllegalArgumentException, IllegalAccessException {
099: throwSetIllegalArgumentException(c);
100: }
101:
102: public void setShort(Object obj, short s)
103: throws IllegalArgumentException, IllegalAccessException {
104: throwSetIllegalArgumentException(s);
105: }
106:
107: public void setInt(Object obj, int i)
108: throws IllegalArgumentException, IllegalAccessException {
109: throwSetIllegalArgumentException(i);
110: }
111:
112: public void setLong(Object obj, long l)
113: throws IllegalArgumentException, IllegalAccessException {
114: throwSetIllegalArgumentException(l);
115: }
116:
117: public void setFloat(Object obj, float f)
118: throws IllegalArgumentException, IllegalAccessException {
119: throwSetIllegalArgumentException(f);
120: }
121:
122: public void setDouble(Object obj, double d)
123: throws IllegalArgumentException, IllegalAccessException {
124: throwSetIllegalArgumentException(d);
125: }
126: }
|