FieldInfopublic class FieldInfo extends ClassMemberInfo
Fields Summary |
---|
private Attribute[] | fieldAttributes | public ConstantObject | value | private ConstantValueAttribute | valueAttribute | public int | instanceOffset | public int | nSlots | private static Hashtable | fieldAttributeTypes |
Constructors Summary |
---|
public FieldInfo(int name, int sig, int access, ClassInfo p) // ditto
super( name, sig, access, p );
|
Methods Summary |
---|
public void | countConstantReferences(boolean isRelocatable)
super.countConstantReferences();
Attribute.countConstantReferences( fieldAttributes, isRelocatable );
| public void | externalize(ConstantPool p)
super.externalize( p );
Attribute.externalizeAttributes( fieldAttributes, p );
if ( value != null ){
value = valueAttribute.data;
}
| private void | readAttributes(java.io.DataInput in)
fieldAttributeTypes.put("ConstantValue", ConstantValueAttributeFactory.instance );
fieldAttributes = Attribute.readAttributes( in, parent.constants, parent.symbols, fieldAttributeTypes, false );
| public static components.FieldInfo | readField(java.io.DataInput in, ClassInfo p)
int acc = in.readUnsignedShort();
int name = in.readUnsignedShort();
int sig = in.readUnsignedShort();
FieldInfo fi = new FieldInfo( name, sig, acc, p );
fi.readAttributes(in );
fi.resolve( p.symbols );
return fi;
| public void | resolve(ConstantObject[] table)
if ( resolved ) return;
super.resolve( table );
/*
* Parse attributes.
* If we find a value attribute, pick it out
* for special handling.
*/
if ( fieldAttributes != null ) {
for ( int i = 0; i < fieldAttributes.length; i++ ){
Attribute a = fieldAttributes[i];
if (a.name.string.equals("ConstantValue") ) {
valueAttribute = (ConstantValueAttribute)a;
value = valueAttribute.data;
}
}
}
switch( type.string.charAt(0) ){
case 'D":
case 'J":
nSlots = 2; access |= Const.ACC_DOUBLEWORD; break;
case 'L":
case '[":
nSlots = 1; access |= Const.ACC_REFERENCE; break;
default:
nSlots = 1; break;
}
resolved = true;
| public java.lang.String | toString()
String r = "Field: "+super.toString();
if ( value != null ){
r += " Value: "+value.toString();
}
return r;
| public void | write(java.io.DataOutput o)
o.writeShort( access );
if ( resolved ){
o.writeShort( name.index );
o.writeShort( type.index );
Attribute.writeAttributes( fieldAttributes, o, false );
} else {
o.writeShort( nameIndex );
o.writeShort( typeIndex );
o.writeShort( 0 ); // no attribute!
}
|
|