001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Alexey V. Varlamov
019: * @version $Revision$
020: */package java.lang.reflect;
021:
022: final class VMField {
023:
024: /**
025: * This class is not supposed to be instantiated.
026: */
027: private VMField() {
028: }
029:
030: /**
031: * Obtaines a value of the field with specified identifier. If the
032: * <code>id</code> argument corresponds to a static field then the
033: * <code>object</code> argument must be null. The value of a static field
034: * will be returned in this case. If the <code>id</code> argument
035: * corresponds to non-static field then object's field value will be
036: * returned.
037: * <p>
038: * This method is used for the {@link Field#get(Object) Field.get(Object obj)}
039: * method implementation.
040: * <p>
041: *
042: * @param object the object to get a field value from.
043: * @param id an identifier of the caller class.
044: * @return a value of the object. The values of primitive type are wrapped
045: * by corresponding object from the <code>java.lang</code> package.
046: * @throws ExceptionInInitializerError if initialization fails.
047: * @api2vm
048: */
049: static native Object getObject(Object object, long field_id);
050:
051: static native boolean getBoolean(Object object, long field_id);
052:
053: static native char getChar(Object object, long field_id);
054:
055: static native byte getByte(Object object, long field_id);
056:
057: static native short getShort(Object object, long field_id);
058:
059: static native int getInt(Object object, long field_id);
060:
061: static native long getLong(Object object, long field_id);
062:
063: static native float getFloat(Object object, long field_id);
064:
065: static native double getDouble(Object object, long field_id);
066:
067: /**
068: * Sets a value for the field with specified identifier. If the
069: * <code>id</code> argument corresponds to a static field then the
070: * <code>object</code> argument must be null. An attempt to set a new value
071: * to a static field will be made in this case. If the <code>id</code>
072: * argument corresponds to a non-static field then an attempt to assign new
073: * value to object's field will be made.
074: * <p>
075: * This method is used for the {@link Field#set(Object, Object)
076: * Field.set(Object obj, Object value)} method implementation.
077: * <p>
078: *
079: * @param object the object to set a field value in.
080: * @param id an identifier of the caller class.
081: * @param value a new field value. If the field has primitive type then the
082: * value argument should be unwrapped.
083: * @throws ExceptionInInitializerError if initialization fails.
084: * @api2vm
085: */
086: static native void setObject(Object object, long field_id,
087: Object value);
088:
089: static native void setBoolean(Object object, long field_id,
090: boolean value);
091:
092: static native void setChar(Object object, long field_id, char value);
093:
094: static native void setByte(Object object, long field_id, byte value);
095:
096: static native void setShort(Object object, long field_id,
097: short value);
098:
099: static native void setInt(Object object, long field_id, int value);
100:
101: static native void setLong(Object object, long field_id, long value);
102:
103: static native void setFloat(Object object, long field_id,
104: float value);
105:
106: static native void setDouble(Object object, long field_id,
107: double value);
108: }
|