| LibJClass Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#include <jclass/field.h> enum JCVisibility; 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
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.
|
The field to check. |
|
The constant pool of the class. |
|
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.
|
The field/method to get its name. |
|
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.
|
The field/method to get its descriptor. |
|
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.
|
The field to get its code attribute. |
|
The constant pool of the class. |
Returns : |
A newly constructed CodeAttribute struct. |