| LibJClass Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#include <jclass/class.h>
JavaClass;
#define JAVA_CLASS_MAGIC
#define ACC_PUBLIC
#define ACC_PRIVATE
#define ACC_PROTECTED
#define ACC_STATIC
#define ACC_FINAL
#define ACC_SYNCHRONIZED
#define ACC_VOLATILE
#define ACC_TRANSIENT
#define ACC_NATIVE
#define ACC_INTERFACE
#define ACC_ABSTRACT
#define ACC_STRICTFP
JavaClass* jclass_class_new (const char *filename,
const ClassPath *classpath);
JavaClass* jclass_class_new_from_buffer (const char *data);
JavaClass* jclass_class_new_from_file (FILE *classfile);
void jclass_class_free (JavaClass *javaclass);
const char* jclass_class_get_vm_spec (JavaClass *javaclass);
char* jclass_class_get_class_name (JavaClass *javaclass);
char* jclass_class_get_super_class_name (JavaClass *javaclass);
char* jclass_class_get_package_name (JavaClass *javaclass);
char ** jclass_class_get_interfaces (JavaClass *class_struct);
char* jclass_class_get_sourcefile_name (JavaClass *javaclass);
typedef struct {
uint16_t minor_version;
uint16_t major_version;
ConstantPool *constant_pool;
uint16_t access_flags;
uint16_t interfaces_count;
uint16_t *interfaces;
uint16_t fields_count;
Field *fields;
uint16_t methods_count;
Field *methods;
uint16_t attributes_count;
AttributeContainer *attributes;
} JavaClass;
Holds information about a class. Everything is stored in native order with the exception of the of attributes. They are stored big-endian inside their AttributeContainer.
uint16_t |
Minor version of the class file specification. |
uint16_t |
Major version of the class file specification. |
ConstantPool * |
The constant pool. |
uint16_t |
A 16-bit access flag. |
uint16_t |
The number of interfaces implemented by the class. |
uint16_t * |
An array with the constant pool indices of the ClassEntry entries for the interfaces implemented by the class. |
uint16_t |
The number of fields in the class. |
Field * |
An array with the fields in this class. |
uint16_t |
The number of methods in this class. |
Field * |
An array with the method in this class. |
uint16_t |
The number of attributes for this class. |
AttributeContainer * |
An array with the attributes for this class. |
#define ACC_SYNCHRONIZED 0x0020
Mask for synchronized.
#define ACC_STRICTFP 0x0800
Mask to indicate that strict IEEE-754 floating point behavior is required.
JavaClass* jclass_class_new (const char *filename, const ClassPath *classpath);
Initializes a new JavaClass struct with info from the given file/class.
If parsing fails it returns NULL.
Use jclass_class_free() to free the class.
|
The filename or classname for the class. |
|
The classpath to use to locate the class. |
Returns : |
A JavaClass struct allocated with malloc. |
JavaClass* jclass_class_new_from_buffer (const char *data);
Creates a JavaClass struct from the given buffer. The buffer should be in the same format as a class file.
|
The buffer containing the class. |
Returns : |
A JavaClass struct allocated with malloc. |
JavaClass* jclass_class_new_from_file (FILE *classfile);
Creates a JavaClass struct from the given class file. The file must be opened with "rb" permissions. The file will always be closed when the function returns.
|
The file containing the class. |
Returns : |
A JavaClass struct allocated with malloc. |
void jclass_class_free (JavaClass *javaclass);
Frees a JavaClass struct.
|
The JavaClass struct to free. |
const char* jclass_class_get_vm_spec (JavaClass *javaclass);
Gives the minimum VM spec needed to run this class. The function returns a pointer to a constant string. Do not free it!
|
The class to get the VM spec for. |
Returns : |
A statically allocated string. |
char* jclass_class_get_class_name (JavaClass *javaclass);
Gives the fully qualified name of the class.
|
The JavaClass that we want the class name for. |
Returns : |
A string allocated with malloc. |
char* jclass_class_get_super_class_name (JavaClass *javaclass);
Gives the fully qualified name of the super class for the given class.
|
The class that we want the super class name for. |
Returns : |
A string allocated with malloc. |
char* jclass_class_get_package_name (JavaClass *javaclass);
Gives the name of the package this class is part of. If the class is not in a package it returns NULL.
|
The class to get its package name. |
Returns : |
A string allocated with malloc. |
char ** jclass_class_get_interfaces (JavaClass *class_struct);
Gives a null terminated array with the names of all interfaces implemented by the given class. If the class does not implement anything it returns NULL.
Since: 0.4
|
The class to get its interfaces. |
Returns : |
A string allocated with malloc. |
char* jclass_class_get_sourcefile_name (JavaClass *javaclass);
Gives the name of the source file used to compile this class. If the class does not have a SourceFile attribute it returns NULL.
|
The class. |
Returns : |
A string allocated with malloc. |