Java Reference
In-Depth Information
where accessFlags is a list of inner class access and property flags, innerClass is the name
of the inner class in internal form, outerClass is the name of the outer class in internal
form, and innerName is the simple name of the inner class.
Add Field
After a class is added, fields can be added to the class by sending to the CLEmitter instance
the following message:
publicvoidaddField(ArrayList<String>accessFlags,
Stringname,
Stringtype,
booleanisSynthetic)
where accessFlags is a list of field access and property flags, name is the name of the field,
type is the type descriptor for the field, and isSynthetic specifies whether the field is
created by the compiler.
A final field of type int , short , byte , char , long , float , double , or String with an
initialization must be added to the class by sending to the CLEmitter instance the respective
message from the list of messages below 8 :
publicvoidaddField(ArrayList<String>accessFlags,
Stringname,
Stringtype,
booleanisSynthetic,
inti)
publicvoidaddField(ArrayList<String>accessFlags,
Stringname,
Stringtype,
booleanisSynthetic,
floatf)
publicvoidaddField(ArrayList<String>accessFlags,
Stringname,
Stringtype,
booleanisSynthetic,
longl)
publicvoidaddField(ArrayList<String>accessFlags,
Stringname,
Stringtype,
booleanisSynthetic,
doubled)
publicvoidaddField(ArrayList<String>accessFlags,
Stringname,
Stringtype,
booleanisSynthetic,
Strings)
The last parameter in each of the above messages is the value of the field. Note that the
JVM treats short , byte , and char types as int .
Add Method
A method can be added to the class by sending to the CLEmitter instance the following
message:
8 The field_info structure for such fields must specify a ConstantValueAttribute reflecting the
value of the constant, and these addField() variants take care of that.
 
Search WWH ::




Custom Search