Replace a custom AndroidRuntime::findClass with a more targeted fix.
This seems simpler and more contained, and I think the comment explaining
why hoop-jumping is necessary is a bit clearer now.
Change-Id: Ief4afd7cbb42188ed835fce23e497520bdb753a8
diff --git a/include/android_runtime/AndroidRuntime.h b/include/android_runtime/AndroidRuntime.h
index de2d50b..b02a057 100644
--- a/include/android_runtime/AndroidRuntime.h
+++ b/include/android_runtime/AndroidRuntime.h
@@ -46,14 +46,10 @@
const char* className, const JNINativeMethod* gMethods, int numMethods);
/**
- * Call a static Java function that takes no arguments and returns void.
- */
- status_t callStatic(const char* className, const char* methodName);
-
- /**
* Call a class's static main method with the given arguments,
*/
- status_t callMain(const char* className, int argc, const char* const argv[]);
+ status_t callMain(const char* className, jclass clazz, int argc,
+ const char* const argv[]);
/**
* Find a class, with the input either of the form
@@ -69,6 +65,13 @@
static AndroidRuntime* getRuntime();
/**
+ * This gets called after the VM has been created, but before we
+ * run any code. Override it to make any FindClass calls that need
+ * to use CLASSPATH.
+ */
+ virtual void onVmCreated(JNIEnv* env);
+
+ /**
* This gets called after the JavaVM has initialized. Override it
* with the system's native entry point.
*/
@@ -98,6 +101,9 @@
/** return a pointer to the JNIEnv pointer for this thread */
static JNIEnv* getJNIEnv();
+ /** return a new string corresponding to 'className' with all '.'s replaced by '/'s. */
+ static char* toSlashClassName(const char* className);
+
private:
static int startReg(JNIEnv* env);
void parseExtraOpts(char* extraOptsBuf);