/** * Returns an interned string for the given UTF-8 string. * * @param s null-terminated string to intern * @returns interned Java string equivelent of s or NULL if s is null */ static jstring internString(JNIEnv* env, ParsingContext* parsingContext, const char* s) { if (s == NULL) return NULL; int hash = hashString(s); int bucketIndex = hash & (BUCKET_COUNT - 1); InternedString*** buckets = parsingContext->internedStrings; InternedString** bucket = buckets[bucketIndex]; InternedString* internedString; if (bucket) { // We have a bucket already. Look for the given string. jstring found = findInternedString(bucket, s, hash); if (found) { // We found it! return found; } // We didn't find it. :( // Create a new entry. internedString = newInternedString(env, s, hash); if (internedString == NULL) return NULL; // Expand the bucket. bucket = expandInternedStringBucket(bucket, internedString); if (bucket == NULL) { delete internedString; jniThrowOutOfMemoryError(env, NULL); return NULL; } buckets[bucketIndex] = bucket; return internedString->interned; } else { // We don't even have a bucket yet. Create an entry. internedString = newInternedString(env, s, hash); if (internedString == NULL) return NULL; // Create a new bucket with one entry. bucket = newInternedStringBucket(internedString); if (bucket == NULL) { delete internedString; jniThrowOutOfMemoryError(env, NULL); return NULL; } buckets[bucketIndex] = bucket; return internedString->interned; } }
Object *classlibCreateConstructorObject(MethodBlock *mb) { AnnotationData *annotations = mb->annotations == NULL ? NULL : mb->annotations->annotations; AnnotationData *parameters = mb->annotations == NULL ? NULL : mb->annotations->parameters; Object *reflect_ob; if((reflect_ob = allocObject(cons_reflect_class)) == NULL) return NULL; executeMethod(reflect_ob, cons_init_mb, mb->class, getMethodParameterTypes(mb), getMethodExceptionTypes(mb), mb->access_flags, mb - CLASS_CB(mb->class)->methods, mb->signature == NULL ? NULL : findInternedString(createString(mb->signature)), getAnnotationsAsArray(annotations), getAnnotationsAsArray(parameters)); return reflect_ob; }