cc6f57bd58d2ebc5058843ec222d27dd452f000b
[jpf-core.git] / src / classes / java / lang / reflect / Method.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 /**
23  * minimal Method reflection support.
24  * Note that we share peer code between Method and Constructor (which aren't
25  * really different on the JPF side), so don't change field names!
26  */
27 public final class Method extends AccessibleObject implements Member {
28   int regIdx; // the link to the corresponding MethodInfo
29   String name; // deferred set by the NativePeer getName()
30
31   @Override
32   public native String getName();
33   public String toGenericString() {
34           // TODO: return real generic string
35           return toString();
36   }
37   public native Object invoke (Object object, Object... args)
38         throws IllegalAccessException, InvocationTargetException;
39
40   @Override
41   public native int getModifiers();
42   public native Class<?> getReturnType();
43   public native Class<?>[] getParameterTypes();
44   public native Type[] getGenericParameterTypes();
45   public native Class<?>[] getExceptionTypes();
46   // TODO: Fix for Groovy's model-checking
47   public native Type getGenericReturnType();
48
49   @Override
50   public native Class<?> getDeclaringClass();
51
52   @Override
53   public native Annotation[] getAnnotations();
54   @Override
55   public native Annotation[] getDeclaredAnnotations();
56   @Override
57   public native <T extends Annotation> T getAnnotation( Class<T> annotationCls);
58   public native Annotation[][] getParameterAnnotations();
59
60   @Override
61   public boolean isSynthetic (){
62     return Modifier.isSynthetic(getModifiers());
63   }
64
65   @Override
66   public native String toString();
67
68   // for Annotations - return the default value of the annotation member
69   // represented by this method
70   public native Object getDefaultValue();
71
72   @Override
73   public native boolean equals (Object obj);
74
75   public boolean isVarArgs (){
76     return (getModifiers() & Modifier.VARARGS) != 0;
77   }
78
79   @Override
80   public native int hashCode ();
81
82   public boolean isBridge (){
83     return (getModifiers() & Modifier.BRIDGE) != 0;
84   }
85 }