private short major;
final int flags;
- private String sourceFile;
private final Vector fields = new Vector();
private final Vector methods = new Vector();
if ((flags & ACC_TRANSIENT) != 0) ret += "transient ";
return ret;
}
-
+
+ public Type.Class getType() { return thisType; }
public String toString() { StringBuffer sb = new StringBuffer(); toString(sb); return sb.toString(); }
public void toString(StringBuffer sb) {
sb.append(flagsToString(flags));
for(int i=0; i<interfaces.length; i++) sb.append((i==0?" ":", ")+interfaces[i]);
sb.append(" {");
sb.append(" // [jcf v"+major+"."+minor+"]");
+ String sourceFile = (String)attributes.get("SourceFile");
if (sourceFile != null) sb.append(" from " + sourceFile);
sb.append("\n");
for(int i=0; i<fields.size(); i++) {
/** Sets the source value of the SourceFile attribute of this class
@param sourceFile The string to be uses as the SourceFile of this class
*/
- public void setSourceFile(String sourceFile) { this.sourceFile = sourceFile; }
+ public void setSourceFile(String sourceFile) { attributes.add("SourceFile", sourceFile); }
/** Writes the classfile data to the file specifed
@see ClassFile#dump(OutputStream)
cp.add(thisType);
cp.add(superType);
if(interfaces != null) for(int i=0;i<interfaces.length;i++) cp.add(interfaces[i]);
- if(sourceFile != null && !attributes.contains("SourceFile")) attributes.add("SourceFile", cp.addUtf8(sourceFile));
for(int i=0;i<methods.size();i++) ((MethodGen)methods.elementAt(i)).finish();
for(int i=0;i<fields.size();i++) ((FieldGen)fields.elementAt(i)).finish();
int numFields = i.readShort();
for(int j=0; j<numFields; j++) fields.add(new FieldGen(cp, i));
int numMethods = i.readShort();
- for(int j=0; j<numMethods; j++) methods.add(new MethodGen(cp, i));
+ for(int j=0; j<numMethods; j++) methods.add(new MethodGen(cp, i, this));
attributes = new AttrGen(cp, i);
- sourceFile = (String)attributes.get("SourceFile");
}
/** Thrown when class generation fails for a reason not under the control of the user
byte[] buf = (byte[]) val;
o.writeInt(buf.length);
o.write(buf);
- } else if(val instanceof CPGen.Ent) {
+ } else if (val instanceof CPGen.Ent) {
o.writeInt(2);
o.writeShort(cp.getIndex((CPGen.Ent)val));
} else {