Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions src/nativeStub.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,18 @@ int main(int argc, char** argv) {
}

jvmVersion = javaInfo[@"JVMVersion"];
jvmOptionsFile = javaInfo[@"JVMOptionsFile"];
bootstrapScript = javaInfo[@"BootstrapScript"];
if(javaInfo[@"JVMOptionsFile"] != nil) {
NSString *jvmOptFileWithPlaceholders = javaInfo[@"JVMOptionsFile"];
jvmOptionsFile = resolvePlaceholders(jvmOptFileWithPlaceholders, javaFolder);
} else {
jvmOptionsFile = info[@"JVMOptionsFile"];
}
if(javaInfo[@"BootstrapScript"] != nil) {
NSString *bootstrapFileWithPlaceholders = javaInfo[@"BootstrapScript"];
bootstrapScript = resolvePlaceholders(bootstrapFileWithPlaceholders, javaFolder);
} else {
bootstrapScript = info[@"BootstrapScript"];
}
} else {
NSLog(@"[%s] [PlistStyle] Oracle", appName);
javaFolder = [[main bundlePath] stringByAppendingPathComponent:@"Contents/Java"];
Expand Down Expand Up @@ -151,8 +161,18 @@ int main(int argc, char** argv) {
}

jvmVersion = info[@"JVMVersion"];
jvmOptionsFile = info[@"JVMOptionsFile"];
bootstrapScript = info[@"BootstrapScript"];
if(javaInfo[@"JVMOptionsFile"] != nil) {
NSString *jvmOptFileWithPlaceholders = javaInfo[@"JVMOptionsFile"];
jvmOptionsFile = resolvePlaceholders(jvmOptFileWithPlaceholders, javaFolder);
} else {
jvmOptionsFile = info[@"JVMOptionsFile"];
}
if(javaInfo[@"BootstrapScript"] != nil) {
NSString *bootstrapFileWithPlaceholders = javaInfo[@"BootstrapScript"];
bootstrapScript = resolvePlaceholders(bootstrapFileWithPlaceholders, javaFolder);
} else {
bootstrapScript = info[@"BootstrapScript"];
}
}
if([jvmVersion containsString:@";"]) {
NSArray *stringParts = [jvmVersion componentsSeparatedByString:@";"];
Expand Down Expand Up @@ -360,6 +380,10 @@ int main(int argc, char** argv) {
NSString *optionsFile = [[NSString alloc] initWithData:[fileManager contentsAtPath:jvmOptionsFile] encoding:NSUTF8StringEncoding];
NSArray *lines = [optionsFile componentsSeparatedByString:@"\n"];
for(NSString *line in lines) {
// Filter empty lines, otherwise application will fail to start for empty file
if ([line length] == 0) {
continue;
}
if([line hasPrefix:@"#"]) {
continue;
}
Expand Down Expand Up @@ -447,7 +471,14 @@ - (NSString *)description {
NSString *result = execute(path, @[@"-version"]);
// The actual version will be between the first two quotes in the result
// We can reasonably ignore all the rest of the output
return [result componentsSeparatedByString:@"\""][1];
NSArray *components = [result componentsSeparatedByString:@"\""];
if (components.count > 1) {
return components[1];
} else {
// Handle unexpected format
NSLog(@"Error: Unexpected version string format: %@", result);
return nil;
}
}

NSString *normalizeJavaVersion(NSString *version) {
Expand Down Expand Up @@ -521,4 +552,4 @@ BOOL versionMeetsMaxConstraint(NSString *version, NSString *constraint) {
// no modifier means it must match exactly
return !exceeds && [constraintParts count] == [versionParts count];
}
}
}