35
35
#define JVM_OPTIONS_KEY " JVMOptions"
36
36
#define JVM_ARGUMENTS_KEY " JVMArguments"
37
37
38
+ #define UNSPECIFIED_ERROR " An unknown error occurred."
39
+
38
40
#define APP_ROOT_PREFIX " $APP_ROOT"
39
41
40
42
#define LIBJLI_DYLIB " /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/jli/libjli.dylib"
@@ -61,7 +63,11 @@ int main(int argc, char *argv[]) {
61
63
launch (argv[0 ]);
62
64
result = 0 ;
63
65
} @catch (NSException *exception) {
64
- NSLog (@" %@ : %@ " , exception, [exception callStackSymbols ]);
66
+ NSAlert *alert = [[NSAlert alloc ] init ];
67
+ [alert setAlertStyle: NSCriticalAlertStyle ];
68
+ [alert setMessageText: [exception reason ]];
69
+ [alert runModal ];
70
+
65
71
result = 1 ;
66
72
}
67
73
@@ -91,7 +97,9 @@ int launch(char *commandName) {
91
97
NSError *bundleLoadError = nil ;
92
98
Boolean runtimeBundleLoaded = CFBundleLoadExecutableAndReturnError (runtimeBundle, (CFErrorRef *)&bundleLoadError);
93
99
if (bundleLoadError != nil || !runtimeBundleLoaded) {
94
- [NSException raise: @JAVA_LAUNCH_ERROR format: @" Could not load JRE from %@ ." , bundleLoadError];
100
+ [[NSException exceptionWithName: @JAVA_LAUNCH_ERROR
101
+ reason: NSLocalizedString(@" JRELoadError" , @UNSPECIFIED_ERROR)
102
+ userInfo: nil ] raise ];
95
103
}
96
104
97
105
jli_LaunchFxnPtr = CFBundleGetFunctionPointerForName (runtimeBundle, CFSTR (" JLI_Launch" ));
@@ -103,13 +111,17 @@ int launch(char *commandName) {
103
111
}
104
112
105
113
if (jli_LaunchFxnPtr == NULL ) {
106
- [NSException raise: @JAVA_LAUNCH_ERROR format: @" Could not get function pointer for JLI_Launch." ];
114
+ [[NSException exceptionWithName: @JAVA_LAUNCH_ERROR
115
+ reason: NSLocalizedString(@" JRENotFound" , @UNSPECIFIED_ERROR)
116
+ userInfo: nil ] raise ];
107
117
}
108
118
109
119
// Get the main class name
110
120
NSString *mainClassName = [infoDictionary objectForKey: @JVM_MAIN_CLASS_NAME_KEY];
111
121
if (mainClassName == nil ) {
112
- [NSException raise: @JAVA_LAUNCH_ERROR format: @" %@ is required." , @JVM_MAIN_CLASS_NAME_KEY];
122
+ [[NSException exceptionWithName: @JAVA_LAUNCH_ERROR
123
+ reason: NSLocalizedString(@" MainClassNameRequired" , @UNSPECIFIED_ERROR)
124
+ userInfo: nil ] raise ];
113
125
}
114
126
115
127
// Set the class path
@@ -120,7 +132,9 @@ int launch(char *commandName) {
120
132
NSFileManager *defaultFileManager = [NSFileManager defaultManager ];
121
133
NSArray *javaDirectoryContents = [defaultFileManager contentsOfDirectoryAtPath: javaPath error: nil ];
122
134
if (javaDirectoryContents == nil ) {
123
- [NSException raise: @JAVA_LAUNCH_ERROR format: @" Could not enumerate Java directory contents." ];
135
+ [[NSException exceptionWithName: @JAVA_LAUNCH_ERROR
136
+ reason: NSLocalizedString(@" JavaDirectoryNotFound" , @UNSPECIFIED_ERROR)
137
+ userInfo: nil ] raise ];
124
138
}
125
139
126
140
for (NSString *file in javaDirectoryContents) {
0 commit comments