Initial import
[jpf-core.git] / src / classes / java / lang / reflect / Field.java
1 /*
2  * Copyright (C) 2014, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The Java Pathfinder core (jpf-core) platform is licensed under the
7  * Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  * 
10  *        http://www.apache.org/licenses/LICENSE-2.0. 
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and 
16  * limitations under the License.
17  */
18 package java.lang.reflect;
19
20 import java.lang.annotation.Annotation;
21
22 public final class Field extends AccessibleObject implements Member {
23   int regIdx; // the link to the corresponding FieldInfo
24   String name; // deferred set by the NativePeer getName()
25
26   public String toGenericString() {
27           // TODO: return real generic string
28           return toString();
29   }
30   
31   public native boolean getBoolean (Object o) throws IllegalAccessException;
32   public native void setBoolean (Object o, boolean v) throws IllegalAccessException;
33
34   public native byte getByte (Object o) throws IllegalAccessException;
35   public native void setByte (Object o, byte v) throws IllegalAccessException;
36
37   public native short getShort (Object o) throws IllegalAccessException;
38   public native void setShort (Object o, short v) throws IllegalAccessException;
39   
40   public native char getChar (Object o) throws IllegalAccessException;
41   public native void setChar (Object o, char v) throws IllegalAccessException;
42
43   public native int getInt (Object o) throws IllegalAccessException;
44   public native void setInt (Object o, int val) throws IllegalAccessException;
45
46   public native long getLong (Object o) throws IllegalAccessException;
47   public native void setLong (Object o, long v) throws IllegalAccessException;
48
49   public native float getFloat (Object o) throws IllegalAccessException;
50   public native void setFloat (Object o, float v) throws IllegalAccessException;
51
52   public native double getDouble (Object o) throws IllegalAccessException;
53   public native void setDouble (Object o, double v) throws IllegalAccessException;
54
55   public native Class<?> getType ();
56   
57   public native Object get (Object o) throws IllegalAccessException;
58     
59   public native void set (Object o, Object v) throws IllegalArgumentException, IllegalAccessException;
60   // the member interface
61   @Override
62   public native String getName();
63   
64   @Override
65   public native int getModifiers();
66   
67   @Override
68   public native Annotation[] getAnnotations();
69
70   @Override
71   public native <T extends Annotation> T getAnnotation( Class<T> annotationCls);
72   
73   @Override
74   public native Class<?> getDeclaringClass ();
75   
76   @Override
77   public native boolean isSynthetic ();
78
79   @Override
80   public native boolean equals (Object obj);
81
82   @Override
83   public native String toString ();
84
85   public boolean isEnumConstant (){
86     return (getModifiers() & Modifier.ENUM) != 0;
87   }
88
89   @Override
90   public native int hashCode ();
91
92   @Override
93   public native Annotation[] getDeclaredAnnotations ();
94 }