GetJREPath(char *path, jint pathsize, char * arch, jboolean speculative)
{
char libjava[MAXPATHLEN];
if (GetApplicationHome(path, pathsize)) {
/* Is JRE co-located with the application? */
sprintf(libjava, "%s/lib/%s/" JAVA_DLL, path, arch);
if (access(libjava, F_OK) == 0) {
goto found;
}
/* Does the app ship a private JRE in <apphome>/jre directory? */
sprintf(libjava, "%s/jre/lib/%s/" JAVA_DLL, path, arch);
if (access(libjava, F_OK) == 0) {
strcat(path, "/jre");
goto found;
}
}
if (!speculative)
fprintf(stderr, "Error: could not find " JAVA_DLL "\n");
return JNI_FALSE;
found:
if (_launcher_debug)
printf("JRE path is %s\n", path);
return JNI_TRUE;
}
jboolean
LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
{
Dl_info dlinfo;
void *libjvm;
if (_launcher_debug) {
printf("JVM path is %s\n", jvmpath);
}
libjvm = dlopen(jvmpath, RTLD_NOW + RTLD_GLOBAL);
if (libjvm == NULL) {
#if defined(__sparc) && !defined(_LP64) /* i.e. 32-bit sparc */
FILE * fp;
Elf32_Ehdr elf_head;
int count;
int location;
fp = fopen(jvmpath, "r");
if(fp == NULL)
goto error;
/* read in elf header */
count = fread((void*)(&elf_head), sizeof(Elf32_Ehdr), 1, fp);
fclose(fp);
if(count < 1)
goto error;
/*
* Check for running a server vm (compiled with -xarch=v8plus)
* on a stock v8 processor. In this case, the machine type in
* the elf header would not be included the architecture list
* provided by the isalist command, which is turn is gotten from
* sysinfo. This case cannot occur on 64-bit hardware and thus
* does not have to be checked for in binaries with an LP64 data
* model.
*/
if(elf_head.e_machine == EM_SPARC32PLUS) {
char buf[257]; /* recommended buffer size from sysinfo man
page */
long length;
char* location;
length = sysinfo(SI_ISALIST, buf, 257);
if(length > 0) {
location = strstr(buf, "sparcv8plus ");
if(location == NULL) {
fprintf(stderr, "SPARC V8 processor detected; Server compiler requires V9 or better.\n");
fprintf(stderr, "Use Client compiler on V8 processors.\n");
fprintf(stderr, "Could not create the Java virtual machine.\n");
return JNI_FALSE;
}
}
}
#endif
fprintf(stderr, "dl failure on line %d", __LINE__);
goto error;
}
ifn->CreateJavaVM = (CreateJavaVM_t)
dlsym(libjvm, "JNI_CreateJavaVM");
if (ifn->CreateJavaVM == NULL)
goto error;
ifn->GetDefaultJavaVMInitArgs = (GetDefaultJavaVMInitArgs_t)
dlsym(libjvm, "JNI_GetDefaultJavaVMInitArgs");
if (ifn->GetDefaultJavaVMInitArgs == NULL)
goto error;
return JNI_TRUE;
=7= |