KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > expr > PairClassType


1 // Copyright (c) 2001 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.expr;
5 import gnu.bytecode.*;
6
7 // Should be moved to some other package? FIXME
8

9 /** A class type implemented as a pair of an interface and a class.
10  * This is how true multiple inheritance can be implemented.
11  */

12
13 public class PairClassType extends ClassType
14 {
15   // FIXME should probably inherit from ObjectType or even Type
16
// rather than ClassType, and have an interfaceType field,
17
// which getImplementationType would return
18
/*
19   public ClassType interfaceType;
20   public Type getImplementationType()
21   {
22     return interfaceType;
23   }
24   String name;
25   */

26
27   Object JavaDoc staticLink;
28
29   public ClassType instanceType;
30
31   public PairClassType()
32   {
33   }
34
35   PairClassType(Class JavaDoc reflectInterface, Class JavaDoc reflectInstanceClass)
36   {
37     super(reflectInterface.getName());
38     setExisting(true);
39     reflectClass = reflectInterface;
40     Type.registerTypeForClass(reflectInterface, this);
41     this.instanceType = (ClassType) Type.make(reflectInstanceClass);
42   }
43
44   public static PairClassType make(Class JavaDoc reflectInterface,
45                    Class JavaDoc reflectInstanceClass)
46   {
47     return new PairClassType(reflectInterface, reflectInstanceClass);
48   }
49
50   public static PairClassType make(Class JavaDoc reflectInterface,
51                    Class JavaDoc reflectInstanceClass,
52                    Object JavaDoc staticLink)
53   {
54     PairClassType type
55       = new PairClassType(reflectInterface, reflectInstanceClass);
56     type.staticLink = staticLink;
57     return type;
58   }
59
60   public Object JavaDoc getStaticLink()
61   {
62     return staticLink;
63   }
64
65   /** This method is called from compiled code. */
66   public static Object JavaDoc extractStaticLink(ClassType type)
67   {
68     return ((PairClassType) type).staticLink;
69   }
70 }
71
Popular Tags