76 #if defined(ENABLE_JAVASE)
81 using namespace cacao;
116 static hashtable *hashtable_classloader;
150 for (SuckClasspath::iterator it = suckclasspath.begin(); it != suckclasspath.end(); it++) {
168 #if defined(ENABLE_JAVASE)
192 #if defined(ENABLE_JAVASE)
210 #if defined(ENABLE_JAVASE)
224 #if defined(ENABLE_JAVASE)
231 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
254 #if defined(ENABLE_JAVASE)
261 # if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
272 # if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
282 # if defined(ENABLE_ANNOTATIONS)
287 # if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
314 hashtable_classloader->mutex->lock();
322 slot = key & (hashtable_classloader->size - 1);
341 #if defined(ENABLE_GC_CACAO)
354 #ifdef LOADER_DEBUG_CLASSLOADER
355 printf(
"CLASSLOADER: adding new classloader entry %p for %p: ", cle, cl);
364 hashtable_classloader->ptr[slot] = cle;
368 hashtable_classloader->entries++;
371 hashtable_classloader->mutex->unlock();
373 #if defined(ENABLE_HANDLES)
402 slot = key & (hashtable_classloader->size - 1);
414 #ifdef LOADER_DEBUG_CLASSLOADER
416 printf(
"CLASSLOADER: unable to find classloader entry for %p: ", cl);
425 #if defined(ENABLE_HANDLES)
444 for (SuckClasspath::iterator it = suckclasspath.begin(); it != suckclasspath.end(); it++) {
447 #if defined(ENABLE_ZLIB)
460 if (!strncmp(filename.
begin(),
"META-INF", strlen(
"META-INF")) ||
461 strstr(filename.
begin(),
".properties") ||
462 strstr(filename.
begin(),
".png"))
468 err() <<
"Error loading class: '" << filename <<
"'" <<
nl;
480 #if defined(ENABLE_ZLIB)
596 void **cpinfos = c->
cpinfos =
MNEW(
void*, cpcount);
606 STATISTICS(count_const_pool_len += (
sizeof(
u1) +
sizeof(
void*)) * cpcount);
614 while (idx < cpcount) {
627 uint16_t name_index = cb.
read_u2();
642 uint16_t utf8_index = cb.
read_u2();
657 uint16_t name_index = cb.
read_u2();
660 uint16_t type_index = cb.
read_u2();
677 uint16_t class_index = cb.
read_u2();
680 uint16_t nameandtype_index = cb.
read_u2();
756 #ifdef ENABLE_VERIFIER
763 cpinfos[idx] = u.
c_ptr();
773 goto unsupported_tag;
778 uint8_t reference_kind = cb.
read_u1();
779 uint16_t reference_index = cb.
read_u2();
791 goto unsupported_tag;
796 uint16_t descriptor_index = cb.
read_u2();
808 goto unsupported_tag;
813 uint16_t bootstrap_method_attr_index = cb.
read_u2();
814 uint16_t name_and_type_index = cb.
read_u2();
837 end = fwd.
classes.end(); it != end; ++it) {
843 #ifdef ENABLE_VERIFIER
857 cpinfos[it->this_index] =
name;
861 end = fwd.
strings.end(); it != end; ++it) {
869 cpinfos[it->this_index] = text;
883 #ifdef ENABLE_VERIFIER
892 if (name[0] ==
'<' && name != utf8::init) {
897 #endif // ENABLE_VERIFIER
908 it->nameandtype_index,
959 #if defined(ENABLE_JAVASE)
968 if (signature != NULL) {
982 if (attribute_length != 2) {
993 return signature != NULL;
1011 #if defined(ENABLE_JAVASE)
1098 text = name.begin();
1099 namelen = name.size();
1102 if (text[0] ==
'[') {
1109 if (namelen < 4 || text[2] ==
'[' || text[namelen - 1] !=
';') {
1166 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
1171 utf8::loadClassInternal,
1172 utf8::java_lang_String__java_lang_Class,
1178 utf8::java_lang_String__java_lang_Class,
1221 #if !defined(NDEBUG)
1223 log_message_utf(
"load_class_from_classloader: Correcting faulty classloader behavior (PR126) for ", name);
1305 if (name[0] ==
'[') {
1320 #if defined(ENABLE_STATISTICS)
1323 if (opt_getcompilingtime)
1326 if (opt_getloadingtime)
1385 #if defined(ENABLE_STATISTICS)
1388 if (opt_getloadingtime)
1391 if (opt_getcompilingtime)
1437 if (ClassFileVersion::CACAO_VERSION < c->
version) {
1482 "Illegal class modifiers: 0x%X",
1494 "Illegal class modifiers: 0x%X",
1511 if (c->
name == utf8::not_named_yet) {
1516 else if (name != c->
name) {
1534 if (c->
name != utf8::java_lang_Object) {
1542 if (supername == NULL)
1547 if (c->
name == utf8::java_lang_Object) {
1554 if (supername == c->
name) {
1584 uint16_t index = cb.
read_u2();
1591 interfacesnames[
i] = u;
1640 #if defined(ENABLE_STATISTICS)
1641 size_t classrefsize, descsize;
1643 descpool.
get_sizes(&classrefsize, &descsize);
1644 count_classref_len += classrefsize;
1645 count_parsed_desc_len += descsize;
1653 end = fwd.
classes.end(); it != end; ++it) {
1687 if (supername != NULL) {
1829 c->
cptags[it->this_index] = it->tag;
1858 if (fmi->name == utf8::init || fmi->name == utf8::clinit) {
1870 if (fmi->name != utf8::init) {
1882 if (fmi->name == utf8::init || fmi->name == utf8::clinit) {
1899 #ifdef ENABLE_VERIFIER
1907 static int shift = 0;
1919 hashtab =
MNEW(
u2,(hashlen + len));
1920 next = hashtab + hashlen;
1932 memset(hashtab, 0,
sizeof(
u2) * (hashlen + len));
1941 if ((old = hashtab[index])) {
1950 }
while ((old = next[old]));
1956 memset(hashtab, 0,
sizeof(
u2) * (hashlen + hashlen/5));
1965 if ((old = hashtab[index])) {
1974 }
while ((old = next[old]));
1979 MFREE(hashtab,
u2, (hashlen + len));
1998 if (((ma == 45) && (mi > 3)) || (ma > 45)) {
2037 #if !defined(NDEBUG)
2052 if (result ==
false) {
2064 #if !defined(NDEBUG)
2106 text = name.
begin();
2107 namelen = name.
size();
2111 if ((namelen < 2) || (text[0] !=
'[')) {
2138 if ((namelen < 4) || (text[2] ==
'[') || (text[namelen - 1] !=
';')) {
2172 #if defined(ENABLE_JAVASE)
2181 #if defined(ENABLE_JAVASE)
2188 #elif defined(ENABLE_JAVAME_CLDC1_1)
2194 # error unknow Java configuration
2218 clonedesc->
params = NULL;
2231 clone->
name = utf8::clone;
2232 clone->
descriptor = utf8::void__java_lang_Object;
void exceptions_throw_verifyerror(methodinfo *m, const char *message,...)
A MethodType constant stored in the constant pool.
void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, Utf8String name)
jlong jlong jlong jlong jint jmethodID jint slot
classinfo * class_java_lang_ThreadGroup
ConstantPoolTag
Types for entries of a classes constant pool.
classinfo * class_java_lang_reflect_Field
JNIEnv jthread jmethodID jlocation jclass jobject jfieldID field
Utf8String substring(size_t from) const
#define STATISTICS(x)
Wrapper for statistics only code.
void get_sizes(size_t *classrefsize, size_t *descsize)
const char * get_path() const
uint16_t name_and_type_index
classinfo * load_class_from_classbuffer(ClassBuffer &cb)
static const size_t sizeof_utf
bool method_load(ClassBuffer &cb, methodinfo *m, DescriptorPool &descpool)
methodinfo * class_resolveclassmethod(classinfo *c, Utf8String name, Utf8String desc, classinfo *referer, bool throwexception)
official tags from JVM spec
void * class_getconstant(classinfo *c, u4 pos, ConstantPoolTag ctype)
#define STAT_REGISTER_SUM_SUBGROUP(var, name, description, group)
Register a statistics summary group.
classinfo * classcache_lookup(classloader_t *initloader, Utf8String classname)
uint16_t nameandtype_index
#define RT_TIMER_STOP(var)
Stop the timer var.
classinfo * class_java_lang_RuntimeException
classinfo * class_java_lang_Long
#define MSET(ptr, byte, type, num)
classinfo * load_newly_created_array(classinfo *c, classloader_t *loader)
void exceptions_throw_classnotfoundexception(Utf8String name)
classinfo * load_class_from_sysloader(Utf8String name)
classinfo * class_java_lang_Float
s4 rawexceptiontablelength
static const ClassFileVersion JDK_7
The class file format version used by JDK 7.
static bool load_class_from_classbuffer_intern(ClassBuffer &cb)
hashtable_classloader_entry * hashlink
classinfo * class_java_lang_Short
classinfo * class_java_lang_VMSystem
void class_print(classinfo *c)
CONSTANT_Fieldref, CONSTANT_Methodref or CONSTANT_InterfaceMethodref.
classinfo * class_sun_reflect_annotation_AnnotationParser
void utf_display_printable_ascii_classname(Utf8String u)
An invokedynamic call site.
classinfo * class_java_lang_Character
classinfo * class_array_of(classinfo *component, bool link)
classinfo * class_java_lang_Void
classinfo * class_java_lang_VMThrowable
classloader_t * classloader
void exceptions_throw_classcircularityerror(classinfo *c)
void resolve_handle_pending_exception(bool throwError)
classinfo * class_java_lang_reflect_VMMethod
void skip_nbytes(size_t num_bytes)
Skip block of classfile data.
#define RT_TIMER_START(var)
Start the timer var.
classinfo * load_class_bootstrap(Utf8String name)
classinfo * classcache_store(classloader_t *initloader, classinfo *cls, bool mayfree)
Dummy implementation of a mutex.
static int32_t heap_hashcode(java_object_t *obj)
#define LLNI_CRITICAL_END
java_handle_t * vm_call_method(methodinfo *m, java_handle_t *o,...)
void exceptions_throw_classformaterror(classinfo *c, const char *message,...)
classinfo * class_java_lang_VMThread
JNIEnv jclass jobject const char * name
Iterator begin()
Allows iteration over all entries in zip archive.
classinfo * class_java_lang_Object
constant_classref * classrefs
classref_or_classinfo catchtype
JNIEnv jthread jobject jclass jlong size
ClassFileVersion version() const
#define TRACESUBSYSTEMINITIALIZATION(text)
void class_set_packagename(classinfo *c)
#define MZERO(ptr, type, num)
classloader_t * loader_hashtable_classloader_add(java_handle_t *cl)
bool loader_skip_attribute_body(ClassBuffer &cb)
#define RT_REGISTER_GROUP(var, name, description)
Register a new (toplevel) group.
cacao::ClassFileVersion version
classinfo * class_sun_reflect_ConstantPool
uint16_t bootstrap_method_attr_index
raw_exception_entry * rawexceptiontable
#define LLNI_class_get(obj, variable)
uint16_t descriptor_index
constant_classref * lookup_classref(Utf8String classname)
bool add_field(Utf8String desc)
bool class_load_attributes(ClassBuffer &cb)
A version of the Java class file format.
classinfo * class_java_lang_Byte
#define RT_REGISTER_GROUP_TIMER(var, name, description, group)
Register a new timer.
JNIEnv jthread jmethodID method
void exceptions_print_current_exception(void)
classinfo * arrayclass_java_lang_Object
classinfo * class_java_lang_reflect_VMField
void exceptions_throw_incompatibleclasschangeerror(classinfo *c, const char *message)
constant_classref * class_get_self_classref(classinfo *cls)
static void version(bool opt_exit)
static JNINativeMethod methods[]
alloc::list< PassInfo::IDTy >::type & stack
This file contains the statistics framework.
classinfo * class_java_lang_ClassNotFoundException
classinfo * class_java_lang_Class
#define STAT_REGISTER_GROUP_VAR(type, var, init, name, description, group)
Register an statistics variable and add it to a group.
bool is_valid_name() const
classloader_t * loader_hashtable_classloader_find(java_handle_t *cl)
DumpList< ForwardNameAndType > nameandtypes
classinfo * class_java_lang_reflect_Method
void loader_load_all_classes(void)
static Utf8String from_utf8(const char *, size_t)
static bool load_constantpool(ClassBuffer &cb, ForwardReferences &fwd, DescriptorPool &descpool)
Fieldref, Methodref and InterfaceMethodref.
classinfo * class_java_io_Serializable
classinfo * class_java_lang_System
JNIEnv jclass jobject loader
void gc_reference_register(java_object_t **ref, int32_t reftype)
DumpList< ForwardMethodHandle > methodhandles
static java_handle_t * invoke_getSystemClassLoader()
Invokes the static Java method getSystemClassLoader().
bool loader_load_attribute_signature(ClassBuffer &cb, Utf8String &signature)
void params_from_paramtypes(s4 mflags)
void free()
Free memory held by this classbuffer.
This file contains the real-time timing utilities.
DumpList< ForwardFieldMethInt > fieldmethints
void compilingtime_start(void)
DumpList< ForwardInvokeDynamic > invokedynamics
static JavaString from_utf8_slash_to_dot(Utf8String)
typedesc * parse_field_descriptor(Utf8String desc)
void loadingtime_stop(void)
classinfo * class_java_lang_String
#define LLNI_vftbl_direct(obj)
classinfo * get_class() const
byte_iterator begin() const
ssize_t add_method(Utf8String desc)
STAT_REGISTER_GROUP_VAR_EXTERN(int, size_classinfo, 0,"size classinfo","classinfo", info_struct_stat) STAT_REGISTER_GROUP_VAR(int
DumpList< ForwardClass > classes
void loader_preinit(void)
void class_free(classinfo *c)
jmethodID jint const void jint const jvmtiAddrLocationMap * map
classinfo * class_java_lang_Exception
classinfo * class_java_lang_Integer
#define STAT_DECLARE_GROUP(var)
Declare an external group (or subgroup).
size_t remaining()
The number of unread bytes in the buffer.
classref_or_classinfo * thrownexceptions
static void * allocate(size_t size)
SuckClasspath & get_suckclasspath()
methoddesc * parse_method_descriptor(Utf8String desc, s4 mflags, constant_classref *thisclass)
#define LLNI_CRITICAL_START
void exceptions_throw_unsupportedclassversionerror(classinfo *c)
classinfo * class_java_lang_SecurityManager
java_handle_t * exceptions_get_exception(void)
#define RT_TIMER_STOPSTART(var1, var2)
Stop the timer var1 and start the timer var2.
static classref_or_classinfo to_classref_or_classinfo(classinfo *c)
Functions for casting a classref/classinfo to a classref_or_classinfo.
classinfo * load_class_from_classloader(Utf8String name, classloader_t *cl)
static java_object_t * next
bool field_load(ClassBuffer &cb, fieldinfo *f, DescriptorPool &descpool)
bool check_size(size_t sz)
Assert that at least <sz> bytes are left to read.
classinfo * class_java_lang_Double
classinfo * class_java_lang_reflect_VMConstructor
static const ClassFileVersion CACAO_VERSION
The class file format version supported by CACAO.
classinfo * class_java_lang_Thread
#define LLNI_classinfo_unwrap(clazz)
bool add_class(Utf8String name)
const uint8_t * get_data() const
static classinfo * get_class_by_char(char ch)
Returns the primitive class of the given type.
DumpList< ForwardMethodType > methodtypes
classinfo * class_java_lang_StackTraceElement
classinfo * class_create_classinfo(Utf8String classname)
classinfo * class_java_util_HashMap
classinfo * resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool checkaccess)
static codeinfo * generate(methodinfo *m, functionptr f)
Wrapper for codegen_emit_stub_native.
classinfo * class_java_util_Vector
void hashtable_create(hashtable *hash, u4 size)
classinfo * class_java_lang_reflect_Constructor
constant_classref * create_classrefs(s4 *count)
classinfo * class_java_lang_Boolean
#define STAT_REGISTER_VAR(type, var, init, name, description)
Register an external statistics variable.
MethodHandleKind
The kinds of methodhandles that can appear in a class file.
void log_message_utf(const char *msg, Utf8String u)
const Utf8String descriptor
#define MFREE(ptr, type, num)
classinfo * class_java_security_PrivilegedAction
void * mem_alloc(int32_t size)
const char const void jint length
classinfo * class_java_lang_Throwable
constant_classref * classref
static void add(Utf8String packagename)
Add a package to the boot-package list.
void log_message_class(const char *msg, classinfo *c)
DumpList< ForwardString > strings
classinfo * class_java_lang_Cloneable
void alloc_parsed_descriptors()
classinfo * class_java_lang_ClassLoader
void compilingtime_stop(void)
void loadingtime_start(void)
static VM * get_current()
void class_loaded(classinfo *c)