Skip to content

Commit 91f5509

Browse files
author
gkbrown
committed
Ensure that JavaAppLauncher handles missing JRE properly.
git-svn-id: https://svn.java.net/svn/appbundler~svn@29 07572b26-92e5-4d45-f66a-c18421440a21
1 parent f5065c3 commit 91f5509

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

appbundler/native/main.m

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,16 @@ int launch(char *commandName) {
8989
// Locate the JLI_Launch() function
9090
NSString *runtime = [infoDictionary objectForKey:@JVM_RUNTIME_KEY];
9191

92-
JLI_Launch_t jli_LaunchFxnPtr;
92+
JLI_Launch_t jli_LaunchFxnPtr = NULL;
9393
if (runtime != nil) {
9494
NSURL *runtimeBundleURL = [[[NSBundle mainBundle] builtInPlugInsURL] URLByAppendingPathComponent:runtime];
9595
CFBundleRef runtimeBundle = CFBundleCreate(NULL, (CFURLRef)runtimeBundleURL);
9696

9797
NSError *bundleLoadError = nil;
9898
Boolean runtimeBundleLoaded = CFBundleLoadExecutableAndReturnError(runtimeBundle, (CFErrorRef *)&bundleLoadError);
99-
if (bundleLoadError != nil || !runtimeBundleLoaded) {
100-
[[NSException exceptionWithName:@JAVA_LAUNCH_ERROR
101-
reason:NSLocalizedString(@"JRELoadError", @UNSPECIFIED_ERROR)
102-
userInfo:nil] raise];
99+
if (bundleLoadError == nil && runtimeBundleLoaded) {
100+
jli_LaunchFxnPtr = CFBundleGetFunctionPointerForName(runtimeBundle, CFSTR("JLI_Launch"));
103101
}
104-
105-
jli_LaunchFxnPtr = CFBundleGetFunctionPointerForName(runtimeBundle, CFSTR("JLI_Launch"));
106102
} else {
107103
void *libJLI = dlopen(LIBJLI_DYLIB, RTLD_LAZY);
108104
if (libJLI != NULL) {
@@ -112,7 +108,7 @@ int launch(char *commandName) {
112108

113109
if (jli_LaunchFxnPtr == NULL) {
114110
[[NSException exceptionWithName:@JAVA_LAUNCH_ERROR
115-
reason:NSLocalizedString(@"JRENotFound", @UNSPECIFIED_ERROR)
111+
reason:NSLocalizedString(@"JRELoadError", @UNSPECIFIED_ERROR)
116112
userInfo:nil] raise];
117113
}
118114

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
"JRELoadError" = "Could not load JRE.";
2-
"JRENotFound" = "A Java runtime environment could not be located.";
1+
"JRELoadError" = "Unable to load Java Runtime Environment.";
32
"MainClassNameRequired" = "Main class name is required.";
4-
"JavaDirectoryNotFound" = "Could not enumerate Java directory contents.";
3+
"JavaDirectoryNotFound" = "Unable to enumerate Java directory contents.";

0 commit comments

Comments
 (0)