Skip to content

Instantly share code, notes, and snippets.

@ojacobson
Created April 14, 2015 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ojacobson/53ed91d919d5d71d5cf2 to your computer and use it in GitHub Desktop.
Save ojacobson/53ed91d919d5d71d5cf2 to your computer and use it in GitHub Desktop.
/*
* Loads a class, convert the '.' to '/'.
*/
static jclass
LoadClass(JNIEnv *env, char *name)
{
char *buf = MemAlloc(strlen(name) + 1);
char *s = buf, *t = name, c;
jclass cls;
jlong start, end;
if (_launcher_debug)
start = CounterGet();
do {
c = *t++;
*s++ = (c == '.') ? '/' : c;
} while (c != '\0');
cls = (*env)->FindClass(env, buf);
free(buf);
if (_launcher_debug) {
end = CounterGet();
printf("%ld micro seconds to load main class\n",
(long)(jint)Counter2Micros(end-start));
printf("----_JAVA_LAUNCHER_DEBUG----\n");
}
return cls;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment