77 using namespace cacao;
106 const char *p = name.
end() - 1;
107 const char *start = name.
begin();
109 if (name[0] ==
'[') {
112 for (; *start ==
'['; start++);
122 for (; (p > start) && (*p !=
'/'); --p);
153 if (classname == NULL)
154 classname = utf8::not_named_yet;
161 #if !defined(ENABLE_GC_BOEHM)
179 #if defined(ENABLE_JAVASE)
182 if (classname == utf8::java_lang_ref_SoftReference) {
185 else if (classname == utf8::java_lang_ref_WeakReference) {
188 else if (classname == utf8::java_lang_ref_PhantomReference) {
193 if (classname != utf8::not_named_yet)
222 for (; nmen; nmen = nmen->
hashlink) {
225 for (clsen = nmen->
classes; clsen; clsen = clsen->
next) {
260 #if defined(ENABLE_STATISTICS)
263 if (opt_getloadingtime)
279 #if defined(ENABLE_STATISTICS)
282 if (opt_getloadingtime)
296 #if defined(ENABLE_JAVASE)
297 # if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
300 c->protectiondomain = pd;
317 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK_7)
319 jlc.set_classLoader(cl);
351 if (attribute_length != 2) {
368 if (sourcefile == NULL)
390 #if defined(ENABLE_JAVASE)
407 if (attribute_length != 4) {
467 uint16_t attributes_count = cb.
read_u2();
469 for (
int i = 0;
i < attributes_count;
i++) {
475 uint16_t attribute_name_index = cb.
read_u2();
478 if (attribute_name == NULL)
481 if (attribute_name == utf8::InnerClasses) {
523 if (outer.
ref != NULL) {
548 else if (attribute_name == utf8::SourceFile) {
554 #if defined(ENABLE_JAVASE)
555 else if (attribute_name == utf8::EnclosingMethod) {
561 else if (attribute_name == utf8::Signature) {
577 #if defined(ENABLE_ANNOTATIONS)
578 else if (attribute_name == utf8::RuntimeVisibleAnnotations) {
583 else if (attribute_name == utf8::RuntimeInvisibleAnnotations) {
611 for (int32_t idx = 0; idx < c->
cpcount; idx++) {
684 if ((((int32_t)pos) >= c->
cpcount) || (c->
cptags[pos] != ctype)) {
688 if ((pos == 0) || (((int32_t)pos) >= c->
cpcount)) {
690 }
else if (c->
cptags[pos] != ctype) {
712 if (((int32_t)pos) >= c->
cpcount) {
724 if (c->
cptags[pos] != ctype) {
762 for (int32_t
i = 0;
i < v->interfacetablelength;
i++) {
765 MFREE(v->interfacevftbllength,
s4, v->interfacetablelength);
768 +
sizeof(
methodptr) * (v->vftbllength - 1)
769 +
sizeof(
methodptr*) * (v->interfacetablelength - (v->interfacetablelength > 0));
770 methodptr *m = ((
methodptr*) v) - (v->interfacetablelength - 1) * (v->interfacetablelength > 1);
845 namelen = component_name.
size();
847 if (component_name[0] ==
'[') {
849 namebuf =
MNEW(
char, namelen + 1);
851 MCOPY(namebuf + 1, component_name.
begin(), char, namelen);
856 namebuf =
MNEW(
char, namelen + 3);
859 MCOPY(namebuf + 2, component_name.
begin(), char, namelen);
860 namebuf[2 + namelen] =
';';
866 MFREE(namebuf,
char, namelen);
890 log_text(
"Invalid array dimension requested");
895 namelen = element_name.
size();
897 if (element_name[0] ==
'[') {
899 namebuf =
MNEW(
char, namelen + dim);
900 memcpy(namebuf + dim, element_name.
begin(), namelen);
905 namebuf =
MNEW(
char, namelen + 2 + dim);
907 memcpy(namebuf + dim + 1, element_name.
begin(), namelen);
908 namelen += (2 + dim);
909 namebuf[namelen - 1] =
';';
911 memset(namebuf,
'[', dim);
915 MFREE(namebuf,
char, namelen);
954 for (; count; --count, ++ref)
955 if (ref->
name == name)
1047 assert(dim >= 1 && dim <= 255);
1050 namelen = refname.
size();
1052 if (refname[0] ==
'[') {
1054 namebuf =
MNEW(
char, namelen + dim);
1055 memcpy(namebuf + dim, refname.
begin(), namelen);
1060 namebuf =
MNEW(
char, namelen + 2 + dim);
1062 memcpy(namebuf + dim + 1, refname.
begin(), namelen);
1063 namelen += (2 + dim);
1064 namebuf[namelen - 1] =
';';
1066 memset(namebuf,
'[', dim);
1070 MFREE(namebuf,
char, namelen);
1100 size_t end = name.
size() - 1;
1105 if (name[1] ==
'L') {
1109 else if (name[1] !=
'[') {
1129 if ((m->
name == name) && ((desc == NULL) || (m->
descriptor == desc)))
1160 if (name == utf8::init || name == utf8::clinit)
1212 classinfo *referer,
bool throwexception)
1262 classinfo *referer,
bool throwexception)
1305 if (c->
super != NULL)
1324 if (f->
name == name)
1365 if (c->
super != NULL)
1462 #if USES_NEW_SUBTYPE
1463 result = fast_subtype_check(sub->
vftbl, super->
vftbl);
1628 int declaredclasscount = 0;
1639 if (outer.
any == NULL)
1649 if ((outername == c->
name) &&
1651 declaredclasscount++;
1657 ClassArray declaredclasses(declaredclasscount);
1659 if (declaredclasses.
is_null())
1669 if (outer.
any == NULL)
1679 if ((outername == c->
name) &&
1707 #if defined(ENABLE_JAVASE)
1734 (m->
name == utf8::init)) {
1764 #if defined(ENABLE_JAVASE)
1787 if ((f->
flags & ACC_PUBLIC) || (publicOnly == 0)) {
1817 #if defined(ENABLE_JAVASE)
1838 ((m->
name != utf8::init) && (m->
name != utf8::clinit)) &&
1856 ((m->
name != utf8::init) && (m->
name != utf8::clinit)) &&
1961 #if defined(ENABLE_JAVASE)
1971 if (m->
name != utf8::init)
2035 #if defined(ENABLE_JAVASE)
2047 if (m->
name == utf8::init)
2102 #if defined(ENABLE_ANNOTATIONS)
2130 int32_t flags = c->
flags;
2148 if (innername == c->
name) {
2182 #if defined(ENABLE_JAVASE)
2201 #if !defined(NDEBUG)
2230 #if !defined(NDEBUG)
2250 #if !defined(NDEBUG)
2275 #if !defined(NDEBUG)
2290 #if !defined(NDEBUG)
2305 #if !defined(NDEBUG)
2308 if (c.
any == NULL) {
2309 printf(
"(classref_or_classinfo) NULL");
2326 #if !defined(NDEBUG)
2341 #if !defined(NDEBUG)
2344 printf (
"---- dump of constant pool ----\n");
2352 printf (
"Classreference -> ");
2360 printf (
"Methodref -> ");
2364 printf (
"InterfaceMethod -> ");
2372 printf (
"Integer -> %d", *reinterpret_cast<int32_t*>(
e));
2375 printf (
"Float -> %f", *reinterpret_cast<float*>(
e));
2378 printf (
"Double -> %f", *reinterpret_cast<double*>(
e));
2381 printf (
"Long -> %" PRId64, *reinterpret_cast<int64_t*>(
e));
2386 printf (
"NameAndType: ");
2399 printf (
"MethodType -> ");
2406 printf (
"MethodHandle -> ");
2414 printf (
"InvokeDynamic -> ");
2421 log_text(
"Invalid type of ConstantPool-Entry");
2438 #if !defined(NDEBUG)
2441 printf(
"--------- Fields and Methods ----------------\n");
2479 printf (
"Virtual function table:\n");
methodptr * interfacetable[1]
java_handle_objectarray_t * class_get_declaredfields(classinfo *c, bool publicOnly)
A MethodType constant stored in the constant pool.
classref_or_classinfo outer_class
bool builtin_instanceof(java_handle_t *o, classinfo *c)
jlong jlong jlong jlong jint jmethodID jint slot
constant_FMIref *const fmi
classinfo * classcache_lookup_defined_or_initiated(classloader_t *loader, Utf8String classname)
dummy_java_lang_Class object
ConstantPoolTag
Types for entries of a classes constant pool.
void method_free(methodinfo *m)
classinfo * class_java_lang_reflect_Field
Utf8String substring(size_t from) const
static void class_freecpool(classinfo *c)
#define STATISTICS(x)
Wrapper for statistics only code.
fieldinfo * class_resolvefield(classinfo *c, Utf8String name, Utf8String desc, classinfo *referer)
constant_classref * class_get_classref_component_of(constant_classref *ref)
classinfo * load_class_from_classbuffer(ClassBuffer &cb)
methodinfo * class_resolveclassmethod(classinfo *c, Utf8String name, Utf8String desc, classinfo *referer, bool throwexception)
official tags from JVM spec
virtual java_handle_t * get_handle() const
void * class_getconstant(classinfo *c, u4 pos, ConstantPoolTag ctype)
classinfo * classcache_lookup(classloader_t *initloader, Utf8String classname)
classinfo * load_newly_created_array(classinfo *c, classloader_t *loader)
void exceptions_throw_linkageerror(const char *message, classinfo *c)
java_handle_t * class_get_enclosingconstructor(classinfo *c)
Return the enclosing constructor as java.lang.reflect.Constructor object for the given class...
static classinfo * get_class_by_type(int type)
Returns the primitive class of the given type.
methodinfo * class_get_enclosingmethod_raw(classinfo *c)
virtual java_handle_array_t * get_handle() const
void exceptions_throw_nosuchmethoderror(classinfo *c, Utf8String name, Utf8String desc)
static Utf8String from_utf8_slash_to_dot(const char *, size_t)
byte_iterator end() const
void class_print(classinfo *c)
An invokedynamic call site.
classcache_class_entry * next
int32_t class_get_modifiers(classinfo *c, bool ignoreInnerClassesAttrib)
classinfo * class_array_of(classinfo *component, bool link)
static fieldinfo * class_resolvefield_int(classinfo *c, Utf8String name, Utf8String desc)
Utf8String class_get_signature(classinfo *c)
void * innerclass_getconstant(classinfo *c, u4 pos, ConstantPoolTag ctype)
classinfo * class_get_declaringclass(classinfo *c)
classloader_t * classloader
Actual implementation of access class for Java Object arrays.
void exceptions_throw_nosuchfielderror(classinfo *c, Utf8String name)
void class_classref_or_classinfo_print(classref_or_classinfo c)
static bool class_load_attribute_enclosingmethod(ClassBuffer &cb)
GNU Classpath java/lang/reflect/Field.
void field_println(fieldinfo *f)
hashtable hashtable_classcache
classref_or_classinfo enclosingclass
void class_classref_println(constant_classref *cr)
classinfo * classcache_store(classloader_t *initloader, classinfo *cls, bool mayfree)
bool class_is_instance(classinfo *c, java_handle_t *h)
void exceptions_throw_classformaterror(classinfo *c, const char *message,...)
classinfo * class_get_enclosingclass(classinfo *c)
classinfo * pseudo_class_Arraystub
static bool class_is_array(classinfo *c)
JNIEnv jclass jobject const char * name
void field_fieldref_print(constant_FMIref *fr)
void set_element(int32_t index, T value)
classinfo * class_java_lang_Object
constant_classref * classrefs
static bool class_load_attribute_sourcefile(ClassBuffer &cb)
methodinfo * class_findmethod(classinfo *c, Utf8String name, Utf8String desc)
bool class_is_arraycompatible(arraydescriptor *desc, arraydescriptor *target)
classinfo * class_multiarray_of(s4 dim, classinfo *element, bool link)
void class_set_packagename(classinfo *c)
bool loader_skip_attribute_body(ClassBuffer &cb)
constant_nameandtype * enclosingmethod
GNU Classpath java/lang/reflect/Constructor.
const uint16_t bootstrap_method_index
#define UNLOCK_CLASSRENUMBER_LOCK
#define MCOPY(dest, src, type, num)
void link(basicblock *v, basicblock *w)
java_handle_objectarray_t * class_get_declaredconstructors(classinfo *c, bool publicOnly)
Return an array of declared constructors of the given class.
java_handle_t * class_get_classname(classinfo *c)
Returns the classname of the class, where slashes ('/') are replaced by dots ('.
#define LLNI_classinfo_wrap(classinfo)
fieldinfo * class_findfield_by_name(classinfo *c, Utf8String name, bool throwexception)
void * heap_alloc_uncollectable(u4 size)
bool class_load_attributes(ClassBuffer &cb)
java_handle_objectarray_t * class_get_declaredclasses(classinfo *c, bool publicOnly)
constant_classref * class_lookup_classref(classinfo *cls, Utf8String name)
threadobject * initializing_thread
#define MFREE(ptr, type, num)
classcache_class_entry * classes
java_handle_objectarray_t * class_get_interfaces(classinfo *c)
void exceptions_throw_incompatibleclasschangeerror(classinfo *c, const char *message)
java_handle_bytearray_t * class_get_annotations(classinfo *c)
constant_classref * class_get_self_classref(classinfo *cls)
void mem_free(void *m, int32_t size)
void method_println(methodinfo *m)
java_handle_t * class_get_enclosingmethod(classinfo *c)
Return the enclosing method as java.lang.reflect.Method object for the given class.
bool class_initializing_thread_is_self(classinfo *c)
Helper function for the function class_is_or_almost_initialized.
java_handle_objectarray_t * class_get_declaredmethods(classinfo *c, bool publicOnly)
void field_free(fieldinfo *f)
This file contains the statistics framework.
void class_println(classinfo *c)
classinfo * class_java_lang_Class
methodinfo * class_resolvemethod(classinfo *c, Utf8String name, Utf8String desc)
void exceptions_throw_abstractmethoderror(void)
void class_showconstantpool(classinfo *c)
GNU Classpath java/lang/reflect/Method.
fieldinfo * class_findfield(classinfo *c, Utf8String name, Utf8String desc)
Simple stream class for formatted output.
void class_classref_print(constant_classref *cr)
void exceptions_throw_internalerror(const char *message,...)
classinfo * class_java_lang_reflect_Method
void class_printflags(classinfo *c)
classref_or_classinfo inner_class
const Utf8String descriptor
static Utf8String from_utf8(const char *, size_t)
constant_classref * class_get_classref(classinfo *cls, Utf8String name)
Fieldref, Methodref and InterfaceMethodref.
#define GCNEW_UNCOLLECTABLE(type, num)
bool class_isanysubclass(classinfo *sub, classinfo *super)
#define LLNI_classinfo_field_get(cls, field, variable)
bool builtin_arrayinstanceof(java_handle_t *h, classinfo *targetclass)
#define CLASSREF_OR_CLASSINFO_NAME(value)
const Utf8String descriptor
bool loader_load_attribute_signature(ClassBuffer &cb, Utf8String &signature)
bool class_issubclass(classinfo *sub, classinfo *super)
OStream & operator<<(OStream &OS, const std::string &t)
arraydescriptor * arraydesc
void utf_display_printable_ascii(Utf8String u)
void class_classref_or_classinfo_println(classref_or_classinfo c)
static JavaString from_utf8_slash_to_dot(Utf8String)
#define LOCK_CLASSRENUMBER_LOCK
const Utf8String descriptor
void loadingtime_stop(void)
classinfo * get_class() const
byte_iterator begin() const
bool annotation_load_class_attribute_runtimevisibleannotations(ClassBuffer &cb)
static threadobject * thread_get_current()
Return the threadobject for the current thread.
void class_showmethods(classinfo *c)
void class_free(classinfo *c)
void method_methodref_print(constant_FMIref *mr)
classinfo * link_class(classinfo *c)
#define STAT_DECLARE_GROUP(var)
Declare an external group (or subgroup).
static methodinfo * class_resolveinterfacemethod_intern(classinfo *c, Utf8String name, Utf8String desc)
void class_postset_header_vftbl(void)
java_handle_t * exceptions_get_exception(void)
bool class_is_assignable_from(classinfo *to, classinfo *from)
extra_classref * extclassrefs
classref_or_classinfo declaringclass
bool check_size(size_t sz)
Assert that at least <sz> bytes are left to read.
static classinfo * get_array_class(Utf8String name, classloader_t *initloader, classloader_t *defloader, bool link)
static bool class_is_primitive(classinfo *c)
classcache_name_entry * hashlink
classinfo * class_create_classinfo(Utf8String classname)
classinfo * resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool checkaccess)
GNU Classpath java/lang/Class.
classinfo * class_java_lang_reflect_Constructor
innerclassinfo * innerclass
classinfo * classcache_lookup_defined(classloader_t *defloader, Utf8String classname)
#define STAT_DECLARE_VAR(type, var, init)
Declare an external statistics variable.
void log_message_utf(const char *msg, Utf8String u)
Actual implementation of access class for java.lang.Class arrays.
const Utf8String descriptor
const char const void jint length
classinfo * class_define(Utf8String name, classloader_t *cl, int32_t length, uint8_t *data, java_handle_t *pd)
bool annotation_load_class_attribute_runtimeinvisibleannotations(ClassBuffer &cb)
classinfo * class_get_componenttype(classinfo *c)
constant_classref * class_get_classref_multiarray_of(s4 dim, constant_classref *ref)
void loadingtime_start(void)
methodinfo * class_resolveinterfacemethod(classinfo *c, Utf8String name, Utf8String desc, classinfo *referer, bool throwexception)