@@ -105,8 +105,18 @@ int main(int argc, char** argv) {
105
105
}
106
106
107
107
jvmVersion = javaInfo[@" JVMVersion" ];
108
- jvmOptionsFile = javaInfo[@" JVMOptionsFile" ];
109
- bootstrapScript = javaInfo[@" BootstrapScript" ];
108
+ if (javaInfo[@" JVMOptionsFile" ] != nil ) {
109
+ NSString *jvmOptFileWithPlaceholders = javaInfo[@" JVMOptionsFile" ];
110
+ jvmOptionsFile = resolvePlaceholders (jvmOptFileWithPlaceholders, javaFolder);
111
+ } else {
112
+ jvmOptionsFile = info[@" JVMOptionsFile" ];
113
+ }
114
+ if (javaInfo[@" BootstrapScript" ] != nil ) {
115
+ NSString *bootstrapFileWithPlaceholders = javaInfo[@" BootstrapScript" ];
116
+ bootstrapScript = resolvePlaceholders (bootstrapFileWithPlaceholders, javaFolder);
117
+ } else {
118
+ bootstrapScript = info[@" BootstrapScript" ];
119
+ }
110
120
} else {
111
121
NSLog (@" [%s ] [PlistStyle] Oracle" , appName);
112
122
javaFolder = [[main bundlePath ] stringByAppendingPathComponent: @" Contents/Java" ];
@@ -151,8 +161,18 @@ int main(int argc, char** argv) {
151
161
}
152
162
153
163
jvmVersion = info[@" JVMVersion" ];
154
- jvmOptionsFile = info[@" JVMOptionsFile" ];
155
- bootstrapScript = info[@" BootstrapScript" ];
164
+ if (javaInfo[@" JVMOptionsFile" ] != nil ) {
165
+ NSString *jvmOptFileWithPlaceholders = javaInfo[@" JVMOptionsFile" ];
166
+ jvmOptionsFile = resolvePlaceholders (jvmOptFileWithPlaceholders, javaFolder);
167
+ } else {
168
+ jvmOptionsFile = info[@" JVMOptionsFile" ];
169
+ }
170
+ if (javaInfo[@" BootstrapScript" ] != nil ) {
171
+ NSString *bootstrapFileWithPlaceholders = javaInfo[@" BootstrapScript" ];
172
+ bootstrapScript = resolvePlaceholders (bootstrapFileWithPlaceholders, javaFolder);
173
+ } else {
174
+ bootstrapScript = info[@" BootstrapScript" ];
175
+ }
156
176
}
157
177
if ([jvmVersion containsString: @" ;" ]) {
158
178
NSArray *stringParts = [jvmVersion componentsSeparatedByString: @" ;" ];
@@ -360,6 +380,10 @@ int main(int argc, char** argv) {
360
380
NSString *optionsFile = [[NSString alloc ] initWithData: [fileManager contentsAtPath: jvmOptionsFile] encoding: NSUTF8StringEncoding];
361
381
NSArray *lines = [optionsFile componentsSeparatedByString: @" \n " ];
362
382
for (NSString *line in lines) {
383
+ // Filter empty lines, otherwise application will fail to start for empty file
384
+ if ([line length ] == 0 ) {
385
+ continue ;
386
+ }
363
387
if ([line hasPrefix: @" #" ]) {
364
388
continue ;
365
389
}
@@ -447,7 +471,14 @@ - (NSString *)description {
447
471
NSString *result = execute (path, @[@" -version" ]);
448
472
// The actual version will be between the first two quotes in the result
449
473
// We can reasonably ignore all the rest of the output
450
- return [result componentsSeparatedByString: @" \" " ][1 ];
474
+ NSArray *components = [result componentsSeparatedByString: @" \" " ];
475
+ if (components.count > 1 ) {
476
+ return components[1 ];
477
+ } else {
478
+ // Handle unexpected format
479
+ NSLog (@" Error: Unexpected version string format: %@ " , result);
480
+ return nil ;
481
+ }
451
482
}
452
483
453
484
NSString *normalizeJavaVersion (NSString *version) {
@@ -521,4 +552,4 @@ BOOL versionMeetsMaxConstraint(NSString *version, NSString *constraint) {
521
552
// no modifier means it must match exactly
522
553
return !exceeds && [constraintParts count ] == [versionParts count ];
523
554
}
524
- }
555
+ }
0 commit comments