ART: Fix null dereference for JSR45

Avoid dereferencing DEX cache pointer if it is null. Arrays and
primitive types do not have DEX cache's installed.

Test: art/tools/run-jdwp-tests.sh --mode=host
Bug: 38126955
Change-Id: I151c18f428d040a4cd9f2fb497c731440bb9fda3
diff --git a/runtime/dex_file_annotations.cc b/runtime/dex_file_annotations.cc
index 1397916..f21f1a2 100644
--- a/runtime/dex_file_annotations.cc
+++ b/runtime/dex_file_annotations.cc
@@ -1421,11 +1421,20 @@
 }
 
 const char* GetSourceDebugExtension(Handle<mirror::Class> klass) {
+  // Before instantiating ClassData, check that klass has a DexCache
+  // assigned.  The ClassData constructor indirectly dereferences it
+  // when calling klass->GetDexFile().
+  if (klass->GetDexCache() == nullptr) {
+    DCHECK(klass->IsPrimitive() || klass->IsArrayClass());
+    return nullptr;
+  }
+
   ClassData data(klass);
   const DexFile::AnnotationSetItem* annotation_set = FindAnnotationSetForClass(data);
   if (annotation_set == nullptr) {
     return nullptr;
   }
+
   const DexFile::AnnotationItem* annotation_item = SearchAnnotationSet(
       data.GetDexFile(),
       annotation_set,
@@ -1434,6 +1443,7 @@
   if (annotation_item == nullptr) {
     return nullptr;
   }
+
   const uint8_t* annotation =
       SearchEncodedAnnotation(data.GetDexFile(), annotation_item->annotation_, "value");
   if (annotation == nullptr) {