IDEA-117493 Native crash in Mac launcher

This commit is contained in:
Vladimir Orlov
2014-03-12 13:45:02 +04:00
parent 28cc4def6a
commit 168dbd0908
2 changed files with 30 additions and 11 deletions
Binary file not shown.
+30 -11
View File
@@ -147,16 +147,19 @@ NSBundle *findMatchingVm() {
NSString *required = requiredJvmVersion();
debugLog([NSString stringWithFormat:@"Required VM: %@", required]);
for (NSBundle *vm in vmBundles) {
if (required != nil && required != NULL) {
for (NSBundle *vm in vmBundles) {
if (satisfies(jvmVersion(vm), required)) {
debugLog(@"Chosen VM:");
debugLog([vm bundlePath]);
return vm;
}
}
} else {
NSLog(@"Info.plist is corrupted, Absent JVMOptios key.");
exit(-1);
}
debugLog(@"No matching VM found");
NSLog(@"No matching VM found.");
return nil;
}
@@ -174,14 +177,21 @@ CFBundleRef NSBundle2CFBundle(NSBundle *bundle) {
- (NSMutableString *)buildClasspath:(NSBundle *)jvm {
NSDictionary *jvmInfo = [[NSBundle mainBundle] objectForInfoDictionaryKey:JVMOptions];
NSMutableString *classpathOption = [NSMutableString stringWithString:@"-Djava.class.path="];
[classpathOption appendString:[jvmInfo objectForKey:@"ClassPath"]];
NSString *toolsJar = [[jvm bundlePath] stringByAppendingString:@"/Contents/Home/lib/tools.jar"];
if ([[NSFileManager defaultManager] fileExistsAtPath:toolsJar]) {
NSString *classPath = [jvmInfo objectForKey:@"ClassPath"];
if (classPath != nil && classPath != NULL) {
[classpathOption appendString:[jvmInfo objectForKey:@"ClassPath"]];
NSString *toolsJar = [[jvm bundlePath] stringByAppendingString:@"/Contents/Home/lib/tools.jar"];
if ([[NSFileManager defaultManager] fileExistsAtPath:toolsJar]) {
[classpathOption appendString:@":"];
[classpathOption appendString:toolsJar];
}
} else {
NSLog(@"Info.plist is corrupted, Absent ClassPath key.");
exit(-1);
}
return classpathOption;
return classpathOption;
}
@@ -263,6 +273,13 @@ NSDictionary *parseProperties() {
- (const char *)mainClassName {
NSDictionary *jvmInfo = [[NSBundle mainBundle] objectForInfoDictionaryKey:JVMOptions];
NSString *mainClass = [jvmInfo objectForKey:@"MainClass"];
if (mainClass == nil || mainClass == NULL) {
NSLog(@"Info.plist is corrupted, Absent MainClass key.");
exit(-1);
}
char *answer = strdup([[jvmInfo objectForKey:@"MainClass"] UTF8String]);
char *cur = answer;
@@ -279,11 +296,14 @@ NSDictionary *parseProperties() {
- (void)process_cwd {
NSDictionary *jvmInfo = [[NSBundle mainBundle] objectForInfoDictionaryKey:JVMOptions];
NSString *cwd = [jvmInfo objectForKey:@"WorkingDirectory"];
if (cwd != nil) {
if (cwd != nil && cwd != NULL) {
cwd = [self expandMacros:cwd];
if (chdir([cwd UTF8String]) != 0) {
NSLog(@"Cannot chdir to working directory at %@", cwd);
}
} else {
NSLog(@"Info.plist is corrupted, Absent WorkingDirectory key.");
exit(-1);
}
}
@@ -390,5 +410,4 @@ NSDictionary *parseProperties() {
[pool release];
}
@end