ART: Tolerate shallow call stack in VMStack_getCallingClassLoader

When the call stack does not have the three methods we expect,
the visitor will return a nullptr value.

Add a test to JniTest (and refactor the test a little for code reuse).

Bug: 16867274

(cherry picked from commit 61bf6a1c80bf797af5d7911ff71fc367fdb36742)

Change-Id: I5fb8f91f372a41e0bc11ef9f70640834591afa53
diff --git a/test/004-JniTest/src/Main.java b/test/004-JniTest/src/Main.java
index ae133be..6d7d647 100644
--- a/test/004-JniTest/src/Main.java
+++ b/test/004-JniTest/src/Main.java
@@ -30,6 +30,7 @@
         testBooleanMethod();
         testCharMethod();
         testIsAssignableFromOnPrimitiveTypes();
+        testShallowGetCallingClassLoader();
     }
 
     private static native void testFindClassOnAttachedNativeThread();
@@ -167,4 +168,10 @@
     }
 
     native static boolean nativeIsAssignableFrom(Class<?> from, Class<?> to);
+
+    static void testShallowGetCallingClassLoader() {
+        nativeTestShallowGetCallingClassLoader();
+    }
+
+    native static void nativeTestShallowGetCallingClassLoader();
 }