158 const uint8_t* utf8_className, int32_t utf8_len);
169 #define DEBUG_REPORT_INSTRUCTION_ERROR \ 170 printf("\nAbortion request by instruction at %s:%u.\n", __FILE__, __LINE__); \ 171 printf("Check at the source file what the cause could be.\n"); \ 172 printf("It could be an exception that was supposed to be thrown or an unsupported feature.\n"); \ 173 printf("Execution will proceed, but others instruction will surely request abortion.\n\n");
uint8_t initClass(JavaVirtualMachine *jvm, LoadedClasses *lc)
Initializes a class.
Definition: jvm.c:784
ClassInstance ci
Definition: jvm.h:64
ReferenceType
Definition: jvm.h:52
Reference * newObjectMultiArray(JavaVirtualMachine *jvm, int32_t *dimensions, uint8_t dimensionsSize, const uint8_t *utf8_className, int32_t utf8_len)
Definition: jvm.c:1102
void executeJVM(JavaVirtualMachine *jvm, LoadedClasses *mainClass)
Executes the main method of a given class.
Definition: jvm.c:94
ReferenceTable * objects
Linked list of all objects that have been created during the execution of the JVM.
Definition: jvm.h:119
Opcode_newarray_type
Definition: opcodes.h:80
int32_t * staticFieldsData
Array containing the data for the static fields of the class.
Definition: jvm.h:95
uint32_t length
Definition: jvm.h:46
uint8_t runMethod(JavaVirtualMachine *jvm, JavaClass *jc, method_info *method, uint8_t numberOfParameters)
Executes the bytecode of a given method.
Definition: jvm.c:469
String str
Definition: jvm.h:67
int32_t utf8_len
Definition: jvm.h:48
Reference * newObjectArray(JavaVirtualMachine *jvm, uint32_t length, const uint8_t *utf8_className, int32_t utf8_len)
Definition: jvm.c:1023
uint32_t len
Definition: jvm.h:34
Linked list data struct that holds information about a class that has already been resolved...
Definition: jvm.h:79
Opcode_newarray_type type
Definition: jvm.h:41
Reference * obj
Definition: jvm.h:73
Definition: constantpool.h:9
void deinitJVM(JavaVirtualMachine *jvm)
Deallocates all memory used by the JavaVirtualMachine structure.
Definition: jvm.c:42
uint8_t * utf8_bytes
Definition: jvm.h:33
uint8_t resolveMethod(JavaVirtualMachine *jvm, JavaClass *jc, cp_info *cp_method, LoadedClasses **outClass)
Resolves a method.
Definition: jvm.c:326
Reference * newArray(JavaVirtualMachine *jvm, uint32_t length, Opcode_newarray_type type)
Definition: jvm.c:945
uint8_t status
Status of the execution of the JVM, indicating whether there are errors or not.
Definition: jvm.h:108
LoadedClasses * isClassLoaded(JavaVirtualMachine *jvm, const uint8_t *utf8_bytes, int32_t utf8_len)
Checks if a class has already been loaded by its name.
Definition: jvm.c:691
uint8_t * data
Definition: jvm.h:40
LoadedClasses * classes
Linked list containing all classes that have been resolved by the JVM.
Definition: jvm.h:126
ReferenceType type
Definition: jvm.h:61
uint8_t resolveField(JavaVirtualMachine *jvm, JavaClass *jc, cp_info *cp_field, LoadedClasses **outClass)
Resolves a field.
Definition: jvm.c:406
int32_t * data
Definition: jvm.h:28
Reference ** elements
Definition: jvm.h:49
void setClassPath(JavaVirtualMachine *jvm, const char *path)
Will set the path to look for classes when opening them.
Definition: jvm.c:133
void initJVM(JavaVirtualMachine *jvm)
Initializes a JavaVirtualMachine structure.
Definition: jvm.c:17
struct ReferenceTable * next
Definition: jvm.h:74
Reference * newString(JavaVirtualMachine *jvm, const uint8_t *str, int32_t strlen)
Definition: jvm.c:853
struct ObjectArray ObjectArray
uint8_t getMethodDescriptorParameterCount(const uint8_t *descriptor_utf8, int32_t utf8_len)
Gets how many operands a method descriptor requires.
Definition: jvm.c:596
uint32_t length
Definition: jvm.h:39
uint8_t isClassSuperOf(JavaVirtualMachine *jvm, JavaClass *super, JavaClass *jc)
Check if one class is a super class of another.
Definition: jvm.c:741
JVMStatus
Definition: jvm.h:12
A java virtual machine, storing all loaded classes, created objects and frames for methods being exec...
Definition: jvm.h:104
uint8_t simulatingSystemAndStringClasses
Boolean telling if the System/String classes are to be simulated instead of being loaded from their a...
Definition: jvm.h:115
JavaClass * getSuperClass(JavaVirtualMachine *jvm, JavaClass *jc)
Gets the super class of a given class.
Definition: jvm.c:717
uint8_t resolveClass(JavaVirtualMachine *jvm, const uint8_t *className_utf8_bytes, int32_t utf8_len, LoadedClasses **outClass)
Loads a .class file without initializing it.
Definition: jvm.c:174
Reference * newClassInstance(JavaVirtualMachine *jvm, LoadedClasses *jc)
Definition: jvm.c:898
ObjectArray oar
Definition: jvm.h:66
Definition: javaclass.h:96
JavaClass * jc
Pointer to the JavaClass struct of the resolved class.
Definition: jvm.h:82
uint8_t requiresInit
Boolean telling if the class has already been initialized or if it still needs to be...
Definition: jvm.h:92
Array arr
Definition: jvm.h:65
struct LoadedClasses LoadedClasses
Linked list data struct that holds information about a class that has already been resolved...
FrameStack * frames
Stack of all frames created by method calls.
Definition: jvm.h:122
struct ClassInstance ClassInstance
struct ReferenceTable ReferenceTable
void deleteReference(Reference *obj)
Definition: jvm.c:1175
struct LoadedClasses * next
Pointer to the next node of the linked list.
Definition: jvm.h:98
Stack of frames to store all frames created by method calling during execution of the JVM...
Definition: framestack.h:44
JavaClass * c
Definition: jvm.h:27
uint8_t * utf8_className
Definition: jvm.h:47
LoadedClasses * addClassToLoadedClasses(JavaVirtualMachine *jvm, JavaClass *jc)
Adds a class to the list of all loaded classes by the JVM.
Definition: jvm.c:666