Save This Page
Home » openjdk-7 » java » lang » reflect » [javadoc | source]
    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   /**
   18    * @author Alexey V. Varlamov 
   19    */
   20   package java.lang.reflect;
   21   
   22   final class VMField {
   23       
   24       /**
   25        * This class is not supposed to be instantiated.
   26        */
   27       private VMField() {
   28       }
   29   
   30       /**
   31        * Obtaines a value of the field with specified identifier. If the
   32        * <code>id</code> argument corresponds to a static field then the
   33        * <code>object</code> argument must be null. The value of a static field
   34        * will be returned in this case. If the <code>id</code> argument
   35        * corresponds to non-static field then object's field value will be
   36        * returned.
   37        * <p>
   38        * This method is used for the {@link Field#get(Object) Field.get(Object obj)}
   39        * method implementation.
   40        * <p>
   41        * 
   42        * @param object the object to get a field value from.
   43        * @param id an identifier of the caller class.
   44        * @return a value of the object. The values of primitive type are wrapped
   45        *         by corresponding object from the <code>java.lang</code> package.
   46        * @throws ExceptionInInitializerError if initialization fails.
   47        * @api2vm
   48        */
   49       static native Object getObject(Object object, long field_id);
   50       
   51       static native boolean getBoolean(Object object, long field_id);
   52       static native char getChar(Object object, long field_id);
   53       static native byte getByte(Object object, long field_id);
   54       static native short getShort(Object object, long field_id);
   55       static native int getInt(Object object, long field_id);
   56       static native long getLong(Object object, long field_id);
   57       static native float getFloat(Object object, long field_id);
   58       static native double getDouble(Object object, long field_id);
   59       
   60   
   61       /**
   62        * Sets a value for the field with specified identifier. If the
   63        * <code>id</code> argument corresponds to a static field then the
   64        * <code>object</code> argument must be null. An attempt to set a new value
   65        * to a static field will be made in this case. If the <code>id</code>
   66        * argument corresponds to a non-static field then an attempt to assign new 
   67        * value to object's field will be made.
   68        * <p>
   69        * This method is used for the {@link Field#set(Object, Object)
   70        * Field.set(Object obj, Object value)} method implementation.
   71        * <p>
   72        * 
   73        * @param object the object to set a field value in.
   74        * @param id an identifier of the caller class.
   75        * @param value a new field value. If the field has primitive type then the
   76        *        value argument should be unwrapped.
   77        * @throws ExceptionInInitializerError if initialization fails.
   78        * @api2vm
   79        */
   80       static native void setObject(Object object, long field_id, Object value);
   81       
   82       static native void setBoolean(Object object, long field_id, boolean value);
   83       static native void setChar(Object object, long field_id, char value);
   84       static native void setByte(Object object, long field_id, byte value);
   85       static native void setShort(Object object, long field_id, short value);
   86       static native void setInt(Object object, long field_id, int value);
   87       static native void setLong(Object object, long field_id, long value);
   88       static native void setFloat(Object object, long field_id, float value);
   89       static native void setDouble(Object object, long field_id, double value);
   90   }

Save This Page
Home » openjdk-7 » java » lang » reflect » [javadoc | source]