|
1 |
| package edu.rice.cs.dynamicjava.symbol; |
|
2 |
| |
|
3 |
| import java.lang.reflect.Method; |
|
4 |
| import edu.rice.cs.plt.iter.IterUtil; |
|
5 |
| import edu.rice.cs.dynamicjava.symbol.type.ClassType; |
|
6 |
| import edu.rice.cs.dynamicjava.symbol.type.Type; |
|
7 |
| import edu.rice.cs.dynamicjava.symbol.type.VariableType; |
|
8 |
| import edu.rice.cs.dynamicjava.symbol.type.Wildcard; |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| public class GetClassMethod extends SpecialMethod { |
|
15 |
| |
|
16 |
| private final DJClass CLASS = SymbolUtil.wrapClass(Class.class); |
|
17 |
| |
|
18 |
| private final DJClass _c; |
|
19 |
| private final Type _returnType; |
|
20 |
| |
|
21 |
0
| public GetClassMethod(ClassType t, TypeSystem ts) {
|
|
22 |
0
| _c = t.ofClass();
|
|
23 |
0
| Wildcard w = new Wildcard(new BoundedSymbol(new Object(), ts.erase(t), TypeSystem.NULL));
|
|
24 |
0
| Type returnType;
|
|
25 |
0
| try { returnType = ts.makeClassType(CLASS, IterUtil.singleton(w)); }
|
|
26 |
0
| catch (TypeSystem.InvalidTypeArgumentException e) { returnType = ts.makeClassType(CLASS); }
|
|
27 |
0
| _returnType = returnType;
|
|
28 |
| } |
|
29 |
| |
|
30 |
0
| public String declaredName() { return "getClass"; }
|
|
31 |
0
| public DJClass declaringClass() { return _c; }
|
|
32 |
| |
|
33 |
0
| public Iterable<VariableType> typeParameters() { return IterUtil.empty(); }
|
|
34 |
0
| public Iterable<LocalVariable> parameters() { return IterUtil.empty(); }
|
|
35 |
0
| public Type returnType() { return _returnType; }
|
|
36 |
0
| public Iterable<Type> thrownTypes() { return IterUtil.empty(); }
|
|
37 |
| |
|
38 |
0
| public boolean isStatic() { return false; }
|
|
39 |
0
| public boolean isAbstract() { return false; }
|
|
40 |
0
| public boolean isFinal() { return false; }
|
|
41 |
0
| public Access accessibility() { return Access.PUBLIC; }
|
|
42 |
0
| public Access.Module accessModule() { return _c.accessModule(); }
|
|
43 |
| |
|
44 |
0
| protected Method implementation() throws NoSuchMethodException {
|
|
45 |
0
| return Object.class.getDeclaredMethod("getClass");
|
|
46 |
| } |
|
47 |
| |
|
48 |
| } |