# HG changeset patch # User ddehaven # Date 1403885588 25200 # Fri Jun 27 09:13:08 2014 -0700 # Node ID 7fcf79800371a492a9144d5e9bb5f7b5f8839a07 # Parent 8070aad1c87903d7a1525715b94c24d74c0afbc0 [mq]: 8048337 diff --git a/make/lib/PlatformLibraries.gmk b/make/lib/PlatformLibraries.gmk --- a/make/lib/PlatformLibraries.gmk +++ b/make/lib/PlatformLibraries.gmk @@ -90,8 +90,7 @@ LIBOSX_DIRS := \ $(JDK_TOPDIR)/src/macosx/native/com/apple/concurrent \ $(JDK_TOPDIR)/src/macosx/native/com/apple/eio \ - $(JDK_TOPDIR)/src/macosx/native/apple/security \ - $(JDK_TOPDIR)/src/macosx/native/apple/launcher + $(JDK_TOPDIR)/src/macosx/native/apple/security $(eval $(call SetupNativeCompilation,BUILD_LIBOSX, \ LIBRARY := osx, \ diff --git a/src/macosx/bundle/JavaAppLauncher/JavaAppLauncher.xcodeproj/project.pbxproj b/src/macosx/bundle/JavaAppLauncher/JavaAppLauncher.xcodeproj/project.pbxproj deleted file mode 100644 --- a/src/macosx/bundle/JavaAppLauncher/JavaAppLauncher.xcodeproj/project.pbxproj +++ /dev/null @@ -1,318 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 45; - objects = { - -/* Begin PBXBuildFile section */ - 2C483E05143512EB00F2AEFD /* 1.7.0.jre in Copy PlugIns */ = {isa = PBXBuildFile; fileRef = 2C483E04143512EB00F2AEFD /* 1.7.0.jre */; }; - 89D3CD32142EEB2200A08AED /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 89D3CD29142EEB2200A08AED /* InfoPlist.strings */; }; - 89D3CD33142EEB2200A08AED /* GenericApp.icns in Resources */ = {isa = PBXBuildFile; fileRef = 89D3CD2B142EEB2200A08AED /* GenericApp.icns */; }; - 89D3CD35142EEB2200A08AED /* JVMArgs.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D3CD30142EEB2200A08AED /* JVMArgs.m */; }; - 89D3CD36142EEB2200A08AED /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D3CD31142EEB2200A08AED /* main.m */; }; - 89D3D365143041F000A08AED /* JavaAppLauncher.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D3D364143041F000A08AED /* JavaAppLauncher.m */; }; - 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 2C48F06614350F0F00F2AEFD /* Copy PlugIns */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 13; - files = ( - 2C483E05143512EB00F2AEFD /* 1.7.0.jre in Copy PlugIns */, - ); - name = "Copy PlugIns"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; - 2C483E04143512EB00F2AEFD /* 1.7.0.jre */ = {isa = PBXFileReference; lastKnownFileType = folder; name = 1.7.0.jre; path = "../../../../../build/macosx-universal/j2sdk-bundle/1.7.0.jdk/Contents/Home/1.7.0.jre"; sourceTree = SOURCE_ROOT; }; - 2C48F06714350F8300F2AEFD /* 1.7.0.jdk */ = {isa = PBXFileReference; lastKnownFileType = folder; name = 1.7.0.jdk; path = "../../../../../build/macosx-universal/j2sdk-bundle/1.7.0.jdk"; sourceTree = SOURCE_ROOT; }; - 2CB5DA5E14355FCA00D3A656 /* classfile_constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = classfile_constants.h; sourceTree = ""; }; - 2CB5DA6014355FCA00D3A656 /* jawt_md.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jawt_md.h; sourceTree = ""; }; - 2CB5DA6114355FCA00D3A656 /* jni_md.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_md.h; sourceTree = ""; }; - 2CB5DA6214355FCA00D3A656 /* jawt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jawt.h; sourceTree = ""; }; - 2CB5DA6314355FCA00D3A656 /* jdwpTransport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jdwpTransport.h; sourceTree = ""; }; - 2CB5DA6414355FCA00D3A656 /* jni.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni.h; sourceTree = ""; }; - 2CB5DA6514355FCA00D3A656 /* jvmti.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jvmti.h; sourceTree = ""; }; - 2CB5DA6614355FCA00D3A656 /* jvmticmlr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jvmticmlr.h; sourceTree = ""; }; - 89D3CD2A142EEB2200A08AED /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; - 89D3CD2B142EEB2200A08AED /* GenericApp.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = GenericApp.icns; path = /System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/GenericApp.icns; sourceTree = ""; }; - 89D3CD2C142EEB2200A08AED /* JavaAppLauncher-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "JavaAppLauncher-Info.plist"; sourceTree = ""; }; - 89D3CD2E142EEB2200A08AED /* JavaAppLauncher_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaAppLauncher_Prefix.pch; sourceTree = ""; }; - 89D3CD2F142EEB2200A08AED /* JVMArgs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JVMArgs.h; sourceTree = ""; }; - 89D3CD30142EEB2200A08AED /* JVMArgs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JVMArgs.m; sourceTree = ""; }; - 89D3CD31142EEB2200A08AED /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 89D3D363143041F000A08AED /* JavaAppLauncher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaAppLauncher.h; sourceTree = ""; }; - 89D3D364143041F000A08AED /* JavaAppLauncher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JavaAppLauncher.m; sourceTree = ""; }; - 8D1107320486CEB800E47090 /* JavaAppLauncher.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JavaAppLauncher.app; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 8D11072E0486CEB800E47090 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 1058C7A0FEA54F0111CA2CBB /* frameworks */ = { - isa = PBXGroup; - children = ( - 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, - ); - name = frameworks; - sourceTree = ""; - }; - 19C28FACFE9D520D11CA2CBB /* Products */ = { - isa = PBXGroup; - children = ( - 8D1107320486CEB800E47090 /* JavaAppLauncher.app */, - ); - name = Products; - sourceTree = ""; - }; - 29B97314FDCFA39411CA2CEA /* JavaAppLauncher */ = { - isa = PBXGroup; - children = ( - 89D3CD2D142EEB2200A08AED /* src */, - 89D3CD28142EEB2200A08AED /* resources */, - 29B97323FDCFA39411CA2CEA /* linking */, - 19C28FACFE9D520D11CA2CBB /* Products */, - ); - name = JavaAppLauncher; - sourceTree = ""; - }; - 29B97323FDCFA39411CA2CEA /* linking */ = { - isa = PBXGroup; - children = ( - 2C48F06714350F8300F2AEFD /* 1.7.0.jdk */, - 2C483E04143512EB00F2AEFD /* 1.7.0.jre */, - 2CB5DA5D14355FCA00D3A656 /* include */, - 1058C7A0FEA54F0111CA2CBB /* frameworks */, - ); - name = linking; - sourceTree = ""; - }; - 2CB5DA5D14355FCA00D3A656 /* include */ = { - isa = PBXGroup; - children = ( - 2CB5DA5E14355FCA00D3A656 /* classfile_constants.h */, - 2CB5DA5F14355FCA00D3A656 /* darwin */, - 2CB5DA6214355FCA00D3A656 /* jawt.h */, - 2CB5DA6314355FCA00D3A656 /* jdwpTransport.h */, - 2CB5DA6414355FCA00D3A656 /* jni.h */, - 2CB5DA6514355FCA00D3A656 /* jvmti.h */, - 2CB5DA6614355FCA00D3A656 /* jvmticmlr.h */, - ); - name = include; - path = "../../../../../build/macosx-universal/j2sdk-bundle/1.7.0.jdk/Contents/Home/include"; - sourceTree = ""; - }; - 2CB5DA5F14355FCA00D3A656 /* darwin */ = { - isa = PBXGroup; - children = ( - 2CB5DA6014355FCA00D3A656 /* jawt_md.h */, - 2CB5DA6114355FCA00D3A656 /* jni_md.h */, - ); - path = darwin; - sourceTree = ""; - }; - 89D3CD28142EEB2200A08AED /* resources */ = { - isa = PBXGroup; - children = ( - 89D3CD29142EEB2200A08AED /* InfoPlist.strings */, - 89D3CD2B142EEB2200A08AED /* GenericApp.icns */, - 89D3CD2C142EEB2200A08AED /* JavaAppLauncher-Info.plist */, - ); - path = resources; - sourceTree = ""; - }; - 89D3CD2D142EEB2200A08AED /* src */ = { - isa = PBXGroup; - children = ( - 89D3CD31142EEB2200A08AED /* main.m */, - 89D3D363143041F000A08AED /* JavaAppLauncher.h */, - 89D3D364143041F000A08AED /* JavaAppLauncher.m */, - 89D3CD2F142EEB2200A08AED /* JVMArgs.h */, - 89D3CD30142EEB2200A08AED /* JVMArgs.m */, - 89D3CD2E142EEB2200A08AED /* JavaAppLauncher_Prefix.pch */, - ); - path = src; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 8D1107260486CEB800E47090 /* JavaAppLauncher */ = { - isa = PBXNativeTarget; - buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "JavaAppLauncher" */; - buildPhases = ( - 8D1107290486CEB800E47090 /* Resources */, - 2C48F06614350F0F00F2AEFD /* Copy PlugIns */, - 8D11072C0486CEB800E47090 /* Sources */, - 8D11072E0486CEB800E47090 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = JavaAppLauncher; - productInstallPath = "$(HOME)/Applications"; - productName = JavaAppLauncher; - productReference = 8D1107320486CEB800E47090 /* JavaAppLauncher.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 29B97313FDCFA39411CA2CEA /* Project object */ = { - isa = PBXProject; - buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "JavaAppLauncher" */; - compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - en, - English, - ); - mainGroup = 29B97314FDCFA39411CA2CEA /* JavaAppLauncher */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 8D1107260486CEB800E47090 /* JavaAppLauncher */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 8D1107290486CEB800E47090 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D3CD32142EEB2200A08AED /* InfoPlist.strings in Resources */, - 89D3CD33142EEB2200A08AED /* GenericApp.icns in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 8D11072C0486CEB800E47090 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D3CD35142EEB2200A08AED /* JVMArgs.m in Sources */, - 89D3CD36142EEB2200A08AED /* main.m in Sources */, - 89D3D365143041F000A08AED /* JavaAppLauncher.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 89D3CD29142EEB2200A08AED /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - 89D3CD2A142EEB2200A08AED /* English */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - C01FCF4B08A954540054247B /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = src/JavaAppLauncher_Prefix.pch; - INFOPLIST_FILE = "resources/JavaAppLauncher-Info.plist"; - INSTALL_PATH = "$(HOME)/Applications"; - LIBRARY_SEARCH_PATHS = "$(inherited)"; - PRODUCT_NAME = JavaAppLauncher; - }; - name = Debug; - }; - C01FCF4C08A954540054247B /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = src/JavaAppLauncher_Prefix.pch; - INFOPLIST_FILE = "resources/JavaAppLauncher-Info.plist"; - INSTALL_PATH = "$(HOME)/Applications"; - LIBRARY_SEARCH_PATHS = "$(inherited)"; - PRODUCT_NAME = JavaAppLauncher; - }; - name = Release; - }; - C01FCF4F08A954540054247B /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - ONLY_ACTIVE_ARCH = YES; - PREBINDING = NO; - SDKROOT = ""; - }; - name = Debug; - }; - C01FCF5008A954540054247B /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - PREBINDING = NO; - SDKROOT = ""; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "JavaAppLauncher" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C01FCF4B08A954540054247B /* Debug */, - C01FCF4C08A954540054247B /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C01FCF4E08A954540054247B /* Build configuration list for PBXProject "JavaAppLauncher" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C01FCF4F08A954540054247B /* Debug */, - C01FCF5008A954540054247B /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; -} diff --git a/src/macosx/bundle/JavaAppLauncher/resources/English.lproj/InfoPlist.strings b/src/macosx/bundle/JavaAppLauncher/resources/English.lproj/InfoPlist.strings deleted file mode 100644 --- a/src/macosx/bundle/JavaAppLauncher/resources/English.lproj/InfoPlist.strings +++ /dev/null @@ -1,2 +0,0 @@ -/* Localized versions of Info.plist keys */ - diff --git a/src/macosx/bundle/JavaAppLauncher/resources/JavaAppLauncher-Info.plist b/src/macosx/bundle/JavaAppLauncher/resources/JavaAppLauncher-Info.plist deleted file mode 100644 --- a/src/macosx/bundle/JavaAppLauncher/resources/JavaAppLauncher-Info.plist +++ /dev/null @@ -1,48 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIconFile - GenericApp.icns - CFBundleIdentifier - com.yourcompany.${PRODUCT_NAME:rfc1034identifier} - CFBundleDisplayName - Your Cool App - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} - NSHumanReadableCopyright - Copyright © 2011 Your Company Inc. All Rights Reserved. - JVMInfo - - JRE - 1.7.0.jre - ClassPath - - Properties - - apple.laf.useScreenMenuBar - true - - MainClass - com.yourcompany.yourapp.mainclass - Arguments - - - - diff --git a/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.h b/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.h deleted file mode 100644 --- a/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import - -#import "jni.h" - - -@interface JVMArgs : NSObject { -@public - NSBundle *jreBundle; - char *preferredJVMLib; - JavaVMInitArgs vm_args; - BOOL startOnFirstThread; - BOOL debug; - - NSDictionary *appInfo; - NSMutableDictionary *jvmInfo; - - NSString *userHome; - NSString *appPackage; - NSString *javaRoot; -} - -@property (retain, nonatomic) NSBundle *jreBundle; -@property (nonatomic) char *preferredJVMLib; -@property (nonatomic) JavaVMInitArgs vm_args; -@property (nonatomic) BOOL startOnFirstThread; -@property (nonatomic) BOOL debug; - -@property (retain, nonatomic) NSDictionary *appInfo; -@property (retain, nonatomic) NSMutableDictionary *jvmInfo; - -@property (retain, nonatomic) NSString *userHome; -@property (retain, nonatomic) NSString *appPackage; -@property (retain, nonatomic) NSString *javaRoot; - -+ (JVMArgs *)jvmArgsForBundle:(NSBundle *)appBundle argc:(int)argc argv:(char *[])argv; - -@end diff --git a/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.m b/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.m deleted file mode 100644 --- a/src/macosx/bundle/JavaAppLauncher/src/JVMArgs.m +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import "JVMArgs.h" - - -#define kArgsFailure "JVMArgsFailure" - -NSString *kArgumentsKey = @"Arguments"; - -NSString *kClassPathKey = @"ClassPath"; -#ifdef __i386__ -NSString *kArchClassPathKey = @"ClassPath.i386"; -#elif __x86_64__ -NSString *kArchClassPathKey = @"ClassPath.x86_64"; -#endif - -NSString *kVMOptionsKey = @"VMOptions"; -#ifdef __i386__ -NSString *kArchVMOptionsKey = @"VMOptions.i386"; -#elif __x86_64__ -NSString *kArchVMOptionsKey = @"VMOptions.x86_64"; -#endif - - -@implementation JVMArgs - -@synthesize jreBundle; -@synthesize preferredJVMLib; -@synthesize vm_args; -@synthesize startOnFirstThread; -@synthesize debug; - -@synthesize appInfo; -@synthesize jvmInfo; - -@synthesize userHome; -@synthesize appPackage; -@synthesize javaRoot; - -- (void) dealloc { - self.jreBundle = nil; - if (self.preferredJVMLib) free(self.preferredJVMLib); - - self.appInfo = nil; - self.jvmInfo = nil; - - self.userHome = nil; - self.appPackage = nil; - self.javaRoot = nil; - - [super dealloc]; -} - - -NSString *GetJavaRoot(NSDictionary *jvmInfoDict) { - NSObject *javaRoot = [jvmInfoDict objectForKey:@"$JAVAROOT"]; - if (![javaRoot isKindOfClass:[NSString class]]) return @"$APP_PACKAGE/Contents/Java"; - return (NSString *)javaRoot; -} - -// Replaces occurances of $JAVAROOT, $APP_PACKAGE, and $USER_HOME -- (NSString *) expandMacros:(NSString *)str { - if ([str rangeOfString:@"$JAVAROOT"].length == 0 && [str rangeOfString:@"$APP_PACKAGE"].length == 0 && [str rangeOfString:@"$USER_HOME"].length == 0) return str; - - // expand $JAVAROOT first, because it can contain $APP_PACKAGE - NSMutableString *mutable = [str mutableCopy]; - [mutable replaceOccurrencesOfString:@"$JAVAROOT" withString:javaRoot options:0 range:NSMakeRange(0, [str length])]; - [mutable replaceOccurrencesOfString:@"$APP_PACKAGE" withString:appPackage options:0 range:NSMakeRange(0, [str length])]; - [mutable replaceOccurrencesOfString:@"$USER_HOME" withString:userHome options:0 range:NSMakeRange(0, [str length])]; - return mutable; -} - -- (NSArray *) arrayFrom:(id) obj delimitedBy:(NSString *)delimiter withErrKey:(NSString *)key { - if (obj == nil) return nil; - if ([obj isKindOfClass:[NSArray class]]) return obj; - if (![obj isKindOfClass:[NSString class]]) { - [NSException raise:@kArgsFailure format:@"%@", [NSString stringWithFormat:@"Failed to find '%@' array in JVMInfo Info.plist"]]; - } - - // split - return [(NSString *)obj componentsSeparatedByString:delimiter]; -} - -- (void) buildArgsForBundle:(NSBundle *)appBundle argc:(int)argc argv:(char *[])argv { - // for verbose logging - self.debug = NULL != getenv("JAVA_LAUNCHER_VERBOSE"); - - self.appInfo = [appBundle infoDictionary]; - - // all apps must have a JVMInfo dictionary inside their Info.plist - self.jvmInfo = [[self.appInfo objectForKey:@"JVMInfo"] mutableCopy]; - if (![jvmInfo isKindOfClass:[NSDictionary class]]) { - [NSException raise:@kArgsFailure format:@"Failed to find 'JVMInfo' dictionary in Info.plist"]; - } - - // initialize macro expansion values - self.userHome = NSHomeDirectory(); - self.appPackage = [appBundle bundlePath]; - self.javaRoot = GetJavaRoot(jvmInfo); - self.javaRoot = [self expandMacros:self.javaRoot]; // dereference $APP_PACKAGE - - // if the 'Arguments' key is defined, those override the ones that came into main() - NSArray *jvmInfoArgs = [jvmInfo valueForKey:kArgumentsKey]; - if (jvmInfoArgs != nil) { - // substitute all the variables in the 'Arguments' array/string - jvmInfoArgs = [self arrayFrom:jvmInfoArgs delimitedBy:@" " withErrKey:kArgumentsKey]; - NSMutableArray *arguments = [NSMutableArray arrayWithCapacity:[jvmInfoArgs count]]; - [jvmInfoArgs enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [arguments replaceObjectAtIndex:idx withObject:[self expandMacros:[obj description]]]; - }]; - [jvmInfo setObject:arguments forKey:kArgumentsKey]; - } else if (argc != 0) { - // put the (macro expanded) args to main() in an NSArray - NSMutableArray *arguments = [NSMutableArray arrayWithCapacity:argc]; - for (int i = 0; i < argc; i++) { - [arguments addObject:[self expandMacros:[NSString stringWithUTF8String:(argv[i])]]]; - } - [jvmInfo setObject:arguments forKey:kArgumentsKey]; - } - - // all JVMInfo's must have a JRE or JDK key - NSString *jreBundleName = [jvmInfo objectForKey:@"JRE"]; - if (!jreBundleName) jreBundleName = [jvmInfo objectForKey:@"JDK"]; - if (![jreBundleName isKindOfClass:[NSString class]]) { - [NSException raise:@kArgsFailure format:@"Failed to find 'JRE' or 'JDK' string in Info.plist JVMInfo"]; - } - - // the JRE/JDK must be loadable from the ($APP_PACKAGE)/Contents/PlugIns/ directory - NSURL *jreBundleURL = [[appBundle builtInPlugInsURL] URLByAppendingPathComponent:jreBundleName]; - self.jreBundle = [NSBundle bundleWithURL:jreBundleURL]; - if (!self.jreBundle) { - [NSException raise:@kArgsFailure format:@"Failed to find JRE/JDK at: %@", jreBundleURL]; - } - - // if the app prefers 'client' or 'server', use the JVM key - NSString *JVMLib = [jvmInfo objectForKey:@"JVM"]; - if (JVMLib != nil) self.preferredJVMLib = strdup([JVMLib UTF8String]); - - // sniff for StartOnFirstThread - if ([[jvmInfo objectForKey:@"StartOnFirstThread"] boolValue]) { - self.startOnFirstThread = YES; - } else if ([[jvmInfo objectForKey:@"StartOnMainThread"] boolValue]) { - // for key compatibility with the Apple JavaApplicationStub's 'Java' dictionary - self.startOnFirstThread = YES; - } - - // add $JAVAROOT directory to the JNI library search path - setenv("JAVA_LIBRARY_PATH", [javaRoot UTF8String], 1); - - // 'WorkingDirectory' key changes current working directory - NSString *javaWorkingDir = [jvmInfo objectForKey:@"WorkingDirectory"]; - if (javaWorkingDir == nil) javaWorkingDir = @"$APP_PACKAGE/.."; - javaWorkingDir = [self expandMacros:javaWorkingDir]; - if (chdir([javaWorkingDir UTF8String]) == -1) { - NSLog(@kArgsFailure " chdir() failed, could not change the current working directory to %s\n", [javaWorkingDir UTF8String]); - } - - NSMutableArray *classpath = [NSMutableArray array]; - - // 'Jar' key sets exactly one classpath entry - NSString *jarFile = [jvmInfo objectForKey:@"Jar"]; - if (jarFile != nil) { - [jvmInfo setObject:[self expandMacros:jarFile] forKey:@"Jar"]; - [classpath addObject:jarFile]; - } - - // 'ClassPath' key allows arbitrary classpath - [classpath addObjectsFromArray:[self arrayFrom:[jvmInfo objectForKey:kClassPathKey] delimitedBy:@":" withErrKey:kClassPathKey]]; - [classpath addObjectsFromArray:[self arrayFrom:[jvmInfo objectForKey:kArchClassPathKey] delimitedBy:@":" withErrKey:kArchClassPathKey]]; - - // Sum up all the classpath entries into one big JVM arg - NSMutableString *classpathOption = [NSMutableString stringWithString:@"-Djava.class.path="]; - [classpath enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - if (idx > 1) [classpathOption appendString:@":"]; - [classpathOption appendString:obj]; - }]; - - NSMutableArray *jvmOptions = [NSMutableArray arrayWithObject:classpathOption]; - - // 'VMOptions' key allows arbitary VM start up options - [jvmOptions addObjectsFromArray:[self arrayFrom:[jvmInfo objectForKey:kVMOptionsKey] delimitedBy:@" " withErrKey:kVMOptionsKey]]; - [jvmOptions addObjectsFromArray:[self arrayFrom:[jvmInfo objectForKey:kArchVMOptionsKey] delimitedBy:@" " withErrKey:kArchVMOptionsKey]]; - - // 'Properties' key is a sub-dictionary transfered to initial System.properties - NSDictionary *properties = [jvmInfo objectForKey:@"Properties"]; - if (properties != nil) { - if (![properties isKindOfClass:[NSDictionary class]]) { - [NSException raise:@kArgsFailure format:@"Failed to find 'Properties' dictionary in Info.plist JVMInfo"]; - } - - [properties enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - [jvmOptions addObject:[NSString stringWithFormat:@"-D%@=%@", key, obj]]; - }]; - } - - // build the real JVM init args struct - vm_args.version = JNI_VERSION_1_6; - vm_args.ignoreUnrecognized = JNI_TRUE; - vm_args.nOptions = [jvmOptions count]; - vm_args.options = calloc(vm_args.nOptions, sizeof(JavaVMOption)); - [jvmOptions enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - NSString *expanded = [self expandMacros:[obj description]]; // turn everything into a string, and expand macros - vm_args.options[idx].optionString = strdup([expanded UTF8String]); - }]; -} - -+ (JVMArgs *)jvmArgsForBundle:(NSBundle *)appBundle argc:(int)argc argv:(char *[])argv { - JVMArgs *args = [JVMArgs new]; - [args buildArgsForBundle:appBundle argc:argc argv:argv]; - return [args autorelease]; -} - -@end diff --git a/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.h b/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.h deleted file mode 100644 --- a/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import - -#import "jni.h" - -#import "JVMArgs.h" - - -@interface JavaAppLauncher : NSObject { - JVMArgs *args; - JavaVM *jvm; -} - -@property (retain) JVMArgs *args; - -- (void) findAndLoadJVM; -- (void) invokeBundledAppJavaLauncherWithEnv:(JNIEnv *)env; - -@end diff --git a/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.m b/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.m deleted file mode 100644 --- a/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher.m +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import "JavaAppLauncher.h" - -#import - -#import "jni.h" - -#define kLaunchFailure "JavaAppLauncherFailure" - - -typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, void **env, void *args); -typedef void (JNICALL *SetPreferredJVM_t)(const char *prefJVM); - - -@implementation JavaAppLauncher - -@synthesize args; - -- (void) findAndLoadJVM { - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - - @try { - // load the libjli.dylib of the embedded JRE (or JDK) bundle - NSURL *jreBundleURL = [args.jreBundle bundleURL]; - CFBundleRef jreBundle = CFBundleCreate(NULL, (CFURLRef)jreBundleURL); - - NSError *err = nil; - Boolean jreBundleLoaded = CFBundleLoadExecutableAndReturnError(jreBundle, (CFErrorRef *)&err); - if (err != nil || !jreBundleLoaded) { - [NSException raise:@kLaunchFailure format:@"could not load the JRE/JDK: %@", err]; - } - - // if there is a preferred libjvm to load, set it here - if (args.preferredJVMLib != NULL) { - SetPreferredJVM_t setPrefJVMFxnPtr = CFBundleGetFunctionPointerForName(jreBundle, CFSTR("JLI_SetPreferredJVM")); - if (setPrefJVMFxnPtr != NULL) { - setPrefJVMFxnPtr(args.preferredJVMLib); - } else { - NSLog(@"No JLI_SetPreferredJVM in JRE/JDK primary executable, failed to set preferred JVM library to: %s", args->preferredJVMLib); - } - } - - // pull the JNI_CreateJavaVM function pointer out of the primary executable of the JRE/JDK bundle - CreateJavaVM_t createJVMFxnPtr = CFBundleGetFunctionPointerForName(jreBundle, CFSTR("JNI_CreateJavaVM")); - if (createJVMFxnPtr == NULL) { - [NSException raise:@kLaunchFailure format:@"null JNI_CreateJavaVM fxn ptr from: %@", jreBundle]; - } - - // instantiate the JVM - JNIEnv *env; - jint createJVMStatus = createJVMFxnPtr(&jvm, (void **)&env, &(args->vm_args)); - if (createJVMStatus != JNI_OK) { - [NSException raise:@kLaunchFailure format:@"failed to JNI_CreateJavaVM (%d): %@", createJVMStatus, jreBundle]; - } - - // check the app needs to run the Java main() on the main thread - if (args.startOnFirstThread) { - dispatch_sync(dispatch_get_main_queue(), ^(void) { - JNIEnv *mainThreadEnv; - (*jvm)->AttachCurrentThread(jvm, (void **)&mainThreadEnv, NULL); - [self invokeBundledAppJavaLauncherWithEnv:mainThreadEnv]; - (*jvm)->DetachCurrentThread(jvm); - }); - } else { - [self invokeBundledAppJavaLauncherWithEnv:env]; - } - - } @catch (NSException *e) { - NSLog(@"%@: %@", e, [e callStackSymbols]); - } - - if (jvm) { - (*jvm)->DetachCurrentThread(jvm); - (*jvm)->DestroyJavaVM(jvm); - } - - [pool drain]; -} - -static const char kLauncherClassName[] = "apple/launcher/JavaAppLauncher"; - -- (void) invokeBundledAppJavaLauncherWithEnv:(JNIEnv *)env { - // hand off control to the apple.launcher.JavaAppLauncher class - - jclass mainClass = (*env)->FindClass(env, kLauncherClassName); - if (mainClass == NULL) { - fprintf(stderr, kLaunchFailure " FindClass() failed for class %s:\n", kLauncherClassName); - (*env)->ExceptionDescribe(env); - return; - } - - jmethodID mainMethod = (*env)->GetStaticMethodID(env, mainClass, "launch", "(JZ)V"); - if ((mainMethod == NULL) || (*env)->ExceptionOccurred(env)) { - fprintf(stderr, kLaunchFailure " GetStaticMethodID() failed for launch() method"); - (*env)->ExceptionDescribe(env); - return; - } - - CFDictionaryRef jvmInfo = CFRetain(args.jvmInfo); - - (*env)->CallStaticVoidMethod(env, mainClass, mainMethod, (jlong)jvmInfo, (jboolean)args.debug); - if ((*env)->ExceptionOccurred(env)) { - fprintf(stderr, kLaunchFailure " CallStaticVoidMethod() threw an exception\n"); - (*env)->ExceptionDescribe(env); - return; - } -} - -@end diff --git a/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher_Prefix.pch b/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher_Prefix.pch deleted file mode 100644 --- a/src/macosx/bundle/JavaAppLauncher/src/JavaAppLauncher_Prefix.pch +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// -// Prefix header for all source files of the 'JavaAppLauncher' target in the 'JavaAppLauncher' project -// - -#ifdef __OBJC__ - #import -#endif diff --git a/src/macosx/bundle/JavaAppLauncher/src/main.m b/src/macosx/bundle/JavaAppLauncher/src/main.m deleted file mode 100644 --- a/src/macosx/bundle/JavaAppLauncher/src/main.m +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import - -#import "JVMArgs.h" -#import "JavaAppLauncher.h" - - -static void dummyTimer(CFRunLoopTimerRef timer, void *info) {} -static void ParkEventLoop() { - // RunLoop needs at least one source, and 1e20 is pretty far into the future - CFRunLoopTimerRef t = CFRunLoopTimerCreate(kCFAllocatorDefault, 1.0e20, 0.0, 0, 0, dummyTimer, NULL); - CFRunLoopAddTimer(CFRunLoopGetCurrent(), t, kCFRunLoopDefaultMode); - CFRelease(t); - - // Park this thread in the main run loop. - int32_t result; - do { - result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e20, false); - } while (result != kCFRunLoopRunFinished); -} - -int main(int argc, char *argv[]) { - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - - @try { - NSBundle *mainBundle = [NSBundle mainBundle]; - - // pick apart the Info.plist, and release all the temporary objects - NSAutoreleasePool *argParsingPool = [NSAutoreleasePool new]; - JVMArgs *args = [JVMArgs jvmArgsForBundle:mainBundle argc:argc argv:argv]; - JavaAppLauncher *launcher = [JavaAppLauncher new]; - launcher.args = args; - [argParsingPool drain]; - - // kick off a new thread to instantiate the JVM on - NSThread *thread = [[NSThread alloc] initWithTarget:launcher selector:@selector(findAndLoadJVM) object:nil]; - struct rlimit limit; - int err = getrlimit(RLIMIT_STACK, &limit); - if (err == 0 && limit.rlim_cur != 0LL) { - [thread setStackSize:limit.rlim_cur]; - } - [thread start]; - [thread release]; - - [launcher release]; - - ParkEventLoop(); - - } @catch (NSException *e) { - NSLog(@"%@: %@", e, [e callStackSymbols]); - } - - [pool drain]; - - return 0; -} diff --git a/src/macosx/classes/apple/launcher/JavaAppLauncher.java b/src/macosx/classes/apple/launcher/JavaAppLauncher.java deleted file mode 100644 --- a/src/macosx/classes/apple/launcher/JavaAppLauncher.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package apple.launcher; - -import java.io.*; -import java.lang.reflect.*; -import java.text.MessageFormat; -import java.util.*; -import java.util.jar.*; - -import javax.swing.*; - -class JavaAppLauncher implements Runnable { - static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("osx"); - return null; - } - }); - } - - private static native T nativeConvertAndRelease(final long ptr); - private static native void nativeInvokeNonPublic(Class cls, Method m, String[] args); - - // entry point from native - static void launch(final long javaDictionaryPtr, final boolean verbose) { - final Map javaDictionary = nativeConvertAndRelease(javaDictionaryPtr); - (new JavaAppLauncher(javaDictionary, verbose)).run(); - } - - // these are the values for the enumeration JavaFailureMode - static final String kJavaFailureMainClassNotSpecified = "MainClassNotSpecified"; - static final String kJavaFailureMainClassNotFound = "CannotLoadMainClass"; - static final String kJavaFailureMainClassHasNoMain = "NoMainMethod"; - static final String kJavaFailureMainClassMainNotStatic = "MainNotStatic"; - static final String kJavaFailureMainThrewException = "MainThrewException"; - static final String kJavaFailureMainInitializerException = "MainInitializerException"; - - final boolean verbose; // Normally set by environment variable JAVA_LAUNCHER_VERBOSE. - final Map javaDictionary; - - JavaAppLauncher(final Map javaDictionary, final boolean verbose) { - this.verbose = verbose; - this.javaDictionary = javaDictionary; - } - - @Override - public void run() { - final Method m = loadMainMethod(getMainMethod()); - final String methodName = m.getDeclaringClass().getName() + ".main(String[])"; - try { - log("Calling " + methodName + " method"); - m.invoke(null, new Object[] { getArguments() }); - log(methodName + " has returned"); - } catch (final IllegalAccessException x) { - try { - nativeInvokeNonPublic(m.getClass(), m, getArguments()); - } catch (final Throwable excpt) { - logError(methodName + " threw an exception:"); - if ((excpt instanceof UnsatisfiedLinkError) && excpt.getMessage().equals("nativeInvokeNonPublic")) { - showFailureAlertAndKill(kJavaFailureMainThrewException, "nativeInvokeNonPublic not registered"); - } else { - excpt.printStackTrace(); - showFailureAlertAndKill(kJavaFailureMainThrewException, excpt.toString()); - } - } - } catch (final InvocationTargetException invokeExcpt) { - logError(methodName + " threw an exception:"); - invokeExcpt.getTargetException().printStackTrace(); - showFailureAlertAndKill(kJavaFailureMainThrewException, invokeExcpt.getTargetException().toString()); - } - } - - Method loadMainMethod(final String mainClassName) { - try { - final Class mainClass = Class.forName(mainClassName, true, sun.misc.Launcher.getLauncher().getClassLoader()); - final Method mainMethod = mainClass.getDeclaredMethod("main", new Class[] { String[].class }); - if ((mainMethod.getModifiers() & Modifier.STATIC) == 0) { - logError("The main(String[]) method of class " + mainClassName + " is not static!"); - showFailureAlertAndKill(kJavaFailureMainClassMainNotStatic, mainClassName); - } - return mainMethod; - } catch (final ExceptionInInitializerError x) { - logError("The main class \"" + mainClassName + "\" had a static initializer throw an exception."); - x.getException().printStackTrace(); - showFailureAlertAndKill(kJavaFailureMainInitializerException, x.getException().toString()); - } catch (final ClassNotFoundException x) { - logError("The main class \"" + mainClassName + "\" could not be found."); - showFailureAlertAndKill(kJavaFailureMainClassNotFound, mainClassName); - } catch (final NoSuchMethodException x) { - logError("The main class \"" + mainClassName + "\" has no static main(String[]) method."); - showFailureAlertAndKill(kJavaFailureMainClassHasNoMain, mainClassName); - } catch (final NullPointerException x) { - logError("No main class specified"); - showFailureAlertAndKill(kJavaFailureMainClassNotSpecified, null); - } - - return null; - } - - // get main class name from 'Jar' key, or 'MainClass' key - String getMainMethod() { - final Object javaJar = javaDictionary.get("Jar"); - if (javaJar != null) { - if (!(javaJar instanceof String)) { - logError("'Jar' key in 'Java' sub-dictionary of Info.plist requires a string value"); - return null; - } - - final String jarPath = (String)javaJar; - if (jarPath.length() == 0) { - log("'Jar' key of sub-dictionary 'Java' of Info.plist key is empty"); - } else { - // extract main class from manifest of this jar - final String main = getMainFromManifest(jarPath); - if (main == null) { - logError("jar file '" + jarPath + "' does not have Main-Class: attribute in its manifest"); - return null; - } - - log("Main class " + main + " found in jar manifest"); - return main; - } - } - - final Object javaMain = javaDictionary.get("MainClass"); - if (!(javaMain instanceof String)) { - logError("'MainClass' key in 'Java' sub-dictionary of Info.plist requires a string value"); - return null; - } - - final String main = (String)javaMain; - if (main.length() == 0) { - log("'MainClass' key of sub-dictionary 'Java' of Info.plist key is empty"); - return null; - } - - log("Main class " + (String)javaMain + " found via 'MainClass' key of sub-dictionary 'Java' of Info.plist key"); - return (String)javaMain; - } - - // get arguments for main(String[]) out of Info.plist and command line - String[] getArguments() { - // check for 'Arguments' key, which contains the main() args if not defined in Info.plist - final Object javaArguments = javaDictionary.get("Arguments"); - if (javaArguments == null) { - // no arguments - log("No arguments for main(String[]) specified"); - return new String[0]; - } - - if (javaArguments instanceof List) { - final List args = (List)javaArguments; - final int count = args.size(); - log("Arguments to main(String[" + count + "]):"); - - final String[] result = new String[count]; - for (int i = 0; i < count; ++i) { - final Object element = args.get(i); - if (element instanceof String) { - result[i] = (String)element; - } else { - logError("Found non-string in array"); - } - log(" arg[" + i + "]=" + result[i]); - } - return result; - } - - logError("'Arguments' key in 'Java' sub-dictionary of Info.plist requires a string value or an array of strings"); - return new String[0]; - } - - // returns name of main class, or null - String getMainFromManifest(final String jarpath) { - JarFile jar = null; - try { - jar = new JarFile(jarpath); - final Manifest man = jar.getManifest(); - final Attributes attr = man.getMainAttributes(); - return attr.getValue("Main-Class"); - } catch (final IOException x) { - // shrug - } finally { - if (jar != null) { - try { - jar.close(); - } catch (final IOException x) { } - } - } - return null; - } - - void log(final String s) { - if (!verbose) return; - System.out.println("[LaunchRunner] " + s); - } - - static void logError(final String s) { - System.err.println("[LaunchRunner Error] " + s); - } - - // This kills the app and does not return! - static void showFailureAlertAndKill(final String msg, String arg) { - if (arg == null) arg = "<>"; - JOptionPane.showMessageDialog(null, getMessage(msg, arg), "", JOptionPane.ERROR_MESSAGE); - System.exit(-1); - } - - static String getMessage(final String msgKey, final Object ... args) { - final String msg = ResourceBundle.getBundle("appLauncherErrors").getString(msgKey); - return MessageFormat.format(msg, args); - } -} diff --git a/src/macosx/classes/apple/launcher/appLauncherErrors.properties b/src/macosx/classes/apple/launcher/appLauncherErrors.properties deleted file mode 100644 --- a/src/macosx/classes/apple/launcher/appLauncherErrors.properties +++ /dev/null @@ -1,6 +0,0 @@ -MainClassNotSpecified=No main class specified. -CannotLoadMainClass=The main class \u201C{0}\u201D could not be loaded. -NoMainMethod=The main class \u201C{0}\u201D has no \u201Cvoid main(String[])\u201D method. -MainNotStatic=The \u201Cmain(String[])\u201D method of class \u201C{0}\u201D is not static. -MainThrewException=Uncaught exception in main method: {0} -MainInitializerException=A static initializer of the main class threw an exception: {0} diff --git a/src/macosx/native/apple/launcher/JavaAppLauncher.m b/src/macosx/native/apple/launcher/JavaAppLauncher.m deleted file mode 100644 --- a/src/macosx/native/apple/launcher/JavaAppLauncher.m +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#import "apple_launcher_JavaAppLauncher.h" - -#import -#import - - -/* - * Class: apple_launcher_JavaAppLauncher - * Method: nativeConvertAndRelease - * Signature: (J)Ljava/lang/Object; - */ -JNIEXPORT jobject JNICALL Java_apple_launcher_JavaAppLauncher_nativeConvertAndRelease -(JNIEnv *env, jclass clazz, jlong nsObjectPtr) { - - jobject value = NULL; - -JNF_COCOA_ENTER(env); - - id obj = jlong_to_ptr(nsObjectPtr); - value = [[JNFDefaultCoercions defaultCoercer] coerceNSObject:obj withEnv:env]; - CFRelease(obj); - -JNF_COCOA_EXIT(env); - - return value; -} - -/* - * Class: apple_launcher_JavaAppLauncher - * Method: nativeInvokeNonPublic - * Signature: (Ljava/lang/Class;Ljava/lang/reflect/Method;[Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_apple_launcher_JavaAppLauncher_nativeInvokeNonPublic -(JNIEnv *env, jclass clazz, jclass targetClass, jobject targetMethod, jobjectArray args) { - jmethodID mainMethodID = (*env)->FromReflectedMethod(env, targetMethod); - if ((*env)->ExceptionOccurred(env)) return; - (*env)->CallStaticVoidMethod(env, targetClass, mainMethodID, args); -}