LibJClass Reference Manual |
---|
Fields/Methods — Functions for fields and methods.
#include <jclass/field.h> enum JCVisibility; typedef Field; int jclass_field_is_visible (Field *field, ConstantPool *cpool, JCVisibility visibility); char* jclass_field_get_name (Field *field, ConstantPool *cpool); char* jclass_field_get_descriptor (Field *field, ConstantPool *cpool); CodeAttribute* jclass_field_get_code_attribute (Field *field, ConstantPool *cpool);
libjclass treats fields and methods in the same way. This is because they are very similar in their representation.
typedef enum { V_PUBLIC, V_PACKAGE, V_PROTECTED, V_PRIVATE, V_SYNTHETIC } JCVisibility;
Visibility
V_PUBLIC | Public . |
V_PACKAGE | Package. |
V_PROTECTED | Protected. |
V_PRIVATE | Private. |
V_SYNTHETIC | Synthetic. |
typedef struct { /* A 16-bit integer with the access flags for this field/method */ uint16_t access_flags; /* The index in the constant pool for the UTF8Entry with the name of this field */ uint16_t name_index; /* The index in the constant pool for the UTF8Entry with the descriptor for this field */ uint16_t descriptor_index; /* The number of attributes for this field */ uint16_t attributes_count; /* The attributes for this field */ AttributeContainer* attributes; } Field;
Information for a field or method.
int jclass_field_is_visible (Field *field, ConstantPool *cpool, JCVisibility visibility);
Checks whether the field given is visible with the visibility given.
field : | The field to check. |
cpool : | The constant pool of the class. |
visibility : | The visibility to check. |
Returns : | 1 if the field is visible, 0 otherwise. |
char* jclass_field_get_name (Field *field, ConstantPool *cpool);
Gives the name of a field/method.
field : | The field/method to get its name. |
cpool : | The costant pool of the class. |
Returns : | A newly constructed string with the name. |
char* jclass_field_get_descriptor (Field *field, ConstantPool *cpool);
Gives the descriptor of a field/method. The descriptor is a string with a special format that describes the type and parameters for a field/method. You can get those as strings with the jclass_descriptor_get_type() and jclass_descriptor_get_parameters() functions.
field : | The field/method to get its descriptor. |
cpool : | The constant pool of the class. |
Returns : | A newly constructed string with the descriptor. |
CodeAttribute* jclass_field_get_code_attribute (Field *field, ConstantPool *cpool);
Returns the code attribute for a method. If the Field is a field or a method without code it returns NULL.
field : | The field to get its code attribute. |
cpool : | The constant pool of the class. |
Returns : | A newly constructed CodeAttribute struct. |
<< Constant pool | Attributes >> |