diff options
author | 2016-01-14 16:05:47 -0800 | |
---|---|---|
committer | 2016-01-27 13:14:10 -0800 | |
commit | c167ee9b65f05f7c6f007d587fd1655388edaee9 (patch) | |
tree | 57e846f6aaad969020972f55a082e3e22884592e /runtime/native/java_lang_Class.cc | |
parent | 2aaf58e90c9229610b2a16644e9866b6741ce9ca (diff) |
reflection: Add new 1.8 AnnotatedElement methods and tests
Also:
* Bump the size of the Class vtable size since 3 new virtuals were
added to java.lang.Class
* Refactor Method#isDefault test into a separate file within 048 test.
Change-Id: I8420a4d208bb60874a9cf996766313c7d5058c45
Diffstat (limited to 'runtime/native/java_lang_Class.cc')
-rw-r--r-- | runtime/native/java_lang_Class.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index 0ddd4a280c..a80585abca 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -469,14 +469,21 @@ static jobjectArray Class_getDeclaredMethodsUnchecked(JNIEnv* env, jobject javaT return soa.AddLocalReference<jobjectArray>(ret.Get()); } -static jobject Class_getDeclaredAnnotation(JNIEnv* env, jobject javaThis, jclass annotationType) { +static jobject Class_getDeclaredAnnotation(JNIEnv* env, jobject javaThis, jclass annotationClass) { ScopedFastNativeObjectAccess soa(env); StackHandleScope<2> hs(soa.Self()); Handle<mirror::Class> klass(hs.NewHandle(DecodeClass(soa, javaThis))); + + // Handle public contract to throw NPE if the "annotationClass" argument was null. + if (UNLIKELY(annotationClass == nullptr)) { + ThrowNullPointerException("annotationClass"); + return nullptr; + } + if (klass->IsProxyClass() || klass->GetDexCache() == nullptr) { return nullptr; } - Handle<mirror::Class> annotation_class(hs.NewHandle(soa.Decode<mirror::Class*>(annotationType))); + Handle<mirror::Class> annotation_class(hs.NewHandle(soa.Decode<mirror::Class*>(annotationClass))); return soa.AddLocalReference<jobject>( klass->GetDexFile().GetAnnotationForClass(klass, annotation_class)); } |