1
2
3
4 package joeq.Class;
5
6 import java.util.HashMap;
7 import java.util.StringTokenizer;
8 import joeq.UTF.Utf8;
9
10
11
12
13
14 public class jq_FakeStaticMethod extends jq_StaticMethod {
15 private static final String FAKE_POSTFIX = "_fake";
16 private static HashMap cache = new HashMap();
17
18 public static jq_Member read(StringTokenizer st) {
19 jq_Class c = (jq_Class) jq_Type.read(st);
20 if (c == null) return null;
21 c.load();
22 String name = st.nextToken();
23 String desc = st.nextToken();
24 return fakeMethod(c, name, desc);
25 }
26
27 protected jq_FakeStaticMethod(jq_Class clazz, jq_NameAndDesc nd) {
28 super(clazz,
29 new jq_NameAndDesc(
30 Utf8.get((nd.getName() + FAKE_POSTFIX)), nd.getDesc()));
31 parseMethodSignature();
32 state = STATE_PREPARED;
33 }
34
35 public static jq_StaticMethod fakeMethod(jq_Class clazz, jq_NameAndDesc nd) {
36 return fakeMethod(clazz, nd, true);
37 }
38
39 public static jq_StaticMethod fakeMethod(jq_Class clazz, jq_NameAndDesc nd, boolean create) {
40 jq_MemberReference mr = new jq_MemberReference(clazz, nd);
41 jq_FakeStaticMethod m = (jq_FakeStaticMethod)cache.get(mr);
42 if (m == null && create) {
43 cache.put(mr, m = new jq_FakeStaticMethod(clazz, nd));
44 }
45 return m;
46 }
47
48 public static jq_StaticMethod fakeMethod(jq_Class clazz, String name, String desc) {
49 return fakeMethod(clazz, new jq_NameAndDesc(name, desc));
50 }
51
52 public static final jq_Class _class = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("Ljoeq/Class/jq_FakeInstanceMethod;");
53 }