Mercurial > hg > truffle
comparison src/share/vm/graal/graalCompilerToVM.cpp @ 7027:58dbea9fb973
CompilerToVM.lookupType() now fails with an exception if eagerResolve is true and resolution fails
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 26 Nov 2012 16:51:43 +0100 |
parents | 6838696d54ac |
children | dd81042f4eb1 |
comparison
equal
deleted
inserted
replaced
7026:f31d374e8195 | 7027:58dbea9fb973 |
---|---|
299 C2V_VMENTRY(jobject, lookupType, (JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve)) | 299 C2V_VMENTRY(jobject, lookupType, (JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve)) |
300 ResourceMark rm; | 300 ResourceMark rm; |
301 | 301 |
302 Symbol* nameSymbol = VmIds::toSymbol(jname); | 302 Symbol* nameSymbol = VmIds::toSymbol(jname); |
303 Handle name = JNIHandles::resolve(jname); | 303 Handle name = JNIHandles::resolve(jname); |
304 | 304 assert(nameSymbol != NULL, "name to symbol creation failed"); |
305 oop result; | 305 |
306 oop result = NULL; | |
306 if (nameSymbol == vmSymbols::int_signature()) { | 307 if (nameSymbol == vmSymbols::int_signature()) { |
307 result = VMToCompiler::createPrimitiveJavaType((int) T_INT, THREAD); | 308 result = VMToCompiler::createPrimitiveJavaType((int) T_INT, THREAD); |
308 } else if (nameSymbol == vmSymbols::long_signature()) { | 309 } else if (nameSymbol == vmSymbols::long_signature()) { |
309 result = VMToCompiler::createPrimitiveJavaType((int) T_LONG, THREAD); | 310 result = VMToCompiler::createPrimitiveJavaType((int) T_LONG, THREAD); |
310 } else if (nameSymbol == vmSymbols::bool_signature()) { | 311 } else if (nameSymbol == vmSymbols::bool_signature()) { |
321 result = VMToCompiler::createPrimitiveJavaType((int) T_FLOAT, THREAD); | 322 result = VMToCompiler::createPrimitiveJavaType((int) T_FLOAT, THREAD); |
322 } else if (nameSymbol == vmSymbols::void_signature()) { | 323 } else if (nameSymbol == vmSymbols::void_signature()) { |
323 result = VMToCompiler::createPrimitiveJavaType((int) T_VOID, THREAD); | 324 result = VMToCompiler::createPrimitiveJavaType((int) T_VOID, THREAD); |
324 } else { | 325 } else { |
325 Klass* resolved_type = NULL; | 326 Klass* resolved_type = NULL; |
326 // if the name isn't in the symbol table then the class isn't loaded anyway... | 327 Handle classloader; |
327 if (nameSymbol != NULL) { | 328 Handle protectionDomain; |
328 Handle classloader; | 329 if (JNIHandles::resolve(accessingClass) != NULL) { |
329 Handle protectionDomain; | 330 classloader = java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(accessingClass))->class_loader(); |
330 if (JNIHandles::resolve(accessingClass) != NULL) { | 331 protectionDomain = java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(accessingClass))->protection_domain(); |
331 classloader = java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(accessingClass))->class_loader(); | 332 } |
332 protectionDomain = java_lang_Class::as_Klass(HotSpotResolvedJavaType::javaMirror(accessingClass))->protection_domain(); | 333 |
334 if (eagerResolve) { | |
335 resolved_type = SystemDictionary::resolve_or_fail(nameSymbol, classloader, protectionDomain, true, THREAD); | |
336 } else { | |
337 resolved_type = SystemDictionary::resolve_or_null(nameSymbol, classloader, protectionDomain, THREAD); | |
338 } | |
339 | |
340 if (!HAS_PENDING_EXCEPTION) { | |
341 if (resolved_type == NULL) { | |
342 assert(!eagerResolve, "failed eager resolution should have caused an exception"); | |
343 Handle type = VMToCompiler::createUnresolvedJavaType(name, THREAD); | |
344 result = type(); | |
345 } else { | |
346 Handle type = GraalCompiler::createHotSpotResolvedJavaType(resolved_type, name, CHECK_NULL); | |
347 result = type(); | |
333 } | 348 } |
334 if (eagerResolve) { | |
335 resolved_type = SystemDictionary::resolve_or_null(nameSymbol, classloader, protectionDomain, THREAD); | |
336 } else { | |
337 if (FieldType::is_obj(nameSymbol)) { | |
338 ResourceMark rm(THREAD); | |
339 // Ignore wrapping L and ;. | |
340 TempNewSymbol tmp_name = SymbolTable::new_symbol(nameSymbol->as_C_string() + 1, | |
341 nameSymbol->utf8_length() - 2, CHECK_NULL); | |
342 resolved_type = SystemDictionary::find_instance_or_array_klass(tmp_name, classloader, protectionDomain, THREAD); | |
343 } else { | |
344 resolved_type = SystemDictionary::find_instance_or_array_klass(nameSymbol, classloader, protectionDomain, THREAD); | |
345 } | |
346 } | |
347 if (HAS_PENDING_EXCEPTION) { | |
348 CLEAR_PENDING_EXCEPTION; | |
349 resolved_type = NULL; | |
350 } | |
351 } | |
352 if (resolved_type != NULL) { | |
353 Handle type = GraalCompiler::createHotSpotResolvedJavaType(resolved_type, name, CHECK_NULL); | |
354 result = type(); | |
355 } else { | |
356 Handle type = VMToCompiler::createUnresolvedJavaType(name, THREAD); | |
357 result = type(); | |
358 } | 349 } |
359 } | 350 } |
360 | 351 |
361 return JNIHandles::make_local(THREAD, result); | 352 return JNIHandles::make_local(THREAD, result); |
362 C2V_END | 353 C2V_END |