1 /**********************************************************************/
2 /* FieldInfo class for J2CPS */
4 /* (c) copyright QUT */
5 /**********************************************************************/
8 import java
.io
.DataInputStream
;
9 import java
.io
.IOException
;
12 public class FieldInfo
extends MemberInfo
{
16 public int typeFixUp
= 0;
18 public FieldInfo(ConstantPool cp
, DataInputStream stream
,
19 ClassDesc thisClass
) throws IOException
{
21 super(cp
,stream
,thisClass
);
22 type
= TypeDesc
.GetType(signature
,0);
23 thisClass
.TryImport(type
);
26 public FieldInfo(ClassDesc cl
,int acc
,String nam
,TypeDesc typ
,Object cVal
) {
33 // public void AddImport(ClassDesc thisClass) {
34 // if (type instanceof ClassDesc) { thisClass.AddImport((ClassDesc)type); }
37 public void GetConstValueAttribute (ConstantPool cp
, DataInputStream stream
)
39 int attLen
= stream
.readInt();
40 constVal
= cp
.Get(stream
.readUnsignedShort());
41 if (constVal
instanceof StringRef
) {
42 constVal
= ((StringRef
)constVal
).GetString();
46 public Object
GetConstVal() {
50 public boolean isConstant() {
51 return ((constVal
!= null) && ConstantPool
.isFinal(accessFlags
) &&
52 ConstantPool
.isStatic(accessFlags
) &&
53 (ConstantPool
.isPublic(accessFlags
) ||
54 ConstantPool
.isProtected(accessFlags
)));
58 public String
toString() {
59 if (constVal
== null) {
60 return ConstantPool
.GetAccessString(accessFlags
) + " " +
61 signature
+ " " + name
;
63 return ConstantPool
.GetAccessString(accessFlags
) + " " +
64 signature
+ " " + name
+ " = " + constVal
.toString();