< prev index next >
src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m
Print this page
rev 54096 : 8259651: [macOS] Replace JNF_COCOA_ENTER/EXIT macros
rev 54098 : 8260616: Removing remaining JNF dependencies in the java.desktop module
8259729: Missed JNFInstanceOf -> IsInstanceOf conversion
*** 22,57 ****
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#import <CoreFoundation/CoreFoundation.h>
#import <ApplicationServices/ApplicationServices.h>
- #import <JavaNativeFoundation/JavaNativeFoundation.h>
/*
* Class: sun_lwawt_macosx_CDesktopPeer
* Method: _lsOpenURI
* Signature: (Ljava/lang/String;)I;
*/
JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenURI
(JNIEnv *env, jclass clz, jstring uri)
{
OSStatus status = noErr;
! JNF_COCOA_ENTER(env);
// I would love to use NSWorkspace here, but it's not thread safe. Why? I don't know.
// So we use LaunchServices directly.
! NSURL *url = [NSURL URLWithString:JNFJavaToNSString(env, uri)];
LSLaunchFlags flags = kLSLaunchDefaults;
LSApplicationParameters params = {0, flags, NULL, NULL, NULL, NULL, NULL};
status = LSOpenURLsWithRole((CFArrayRef)[NSArray arrayWithObject:url], kLSRolesAll, NULL, ¶ms, NULL, 0);
! JNF_COCOA_EXIT(env);
return status;
}
/*
* Class: sun_lwawt_macosx_CDesktopPeer
--- 22,57 ----
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+ #import "JNIUtilities.h"
#import <CoreFoundation/CoreFoundation.h>
#import <ApplicationServices/ApplicationServices.h>
/*
* Class: sun_lwawt_macosx_CDesktopPeer
* Method: _lsOpenURI
* Signature: (Ljava/lang/String;)I;
*/
JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenURI
(JNIEnv *env, jclass clz, jstring uri)
{
OSStatus status = noErr;
! JNI_COCOA_ENTER(env);
// I would love to use NSWorkspace here, but it's not thread safe. Why? I don't know.
// So we use LaunchServices directly.
! NSURL *url = [NSURL URLWithString:JavaStringToNSString(env, uri)];
LSLaunchFlags flags = kLSLaunchDefaults;
LSApplicationParameters params = {0, flags, NULL, NULL, NULL, NULL, NULL};
status = LSOpenURLsWithRole((CFArrayRef)[NSArray arrayWithObject:url], kLSRolesAll, NULL, ¶ms, NULL, 0);
! JNI_COCOA_EXIT(env);
return status;
}
/*
* Class: sun_lwawt_macosx_CDesktopPeer
*** 60,75 ****
*/
JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenFile
(JNIEnv *env, jclass clz, jstring jpath, jboolean print)
{
OSStatus status = noErr;
! JNF_COCOA_ENTER(env);
// I would love to use NSWorkspace here, but it's not thread safe. Why? I don't know.
// So we use LaunchServices directly.
! NSString *path = JNFNormalizedNSStringForPath(env, jpath);
NSURL *url = [NSURL fileURLWithPath:(NSString *)path];
// This byzantine workaround is necesary, or else directories won't open in Finder
url = (NSURL *)CFURLCreateWithFileSystemPath(NULL, (CFStringRef)[url path], kCFURLPOSIXPathStyle, false);
--- 60,75 ----
*/
JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenFile
(JNIEnv *env, jclass clz, jstring jpath, jboolean print)
{
OSStatus status = noErr;
! JNI_COCOA_ENTER(env);
// I would love to use NSWorkspace here, but it's not thread safe. Why? I don't know.
// So we use LaunchServices directly.
! NSString *path = NormalizedPathNSStringFromJavaString(env, jpath);
NSURL *url = [NSURL fileURLWithPath:(NSString *)path];
// This byzantine workaround is necesary, or else directories won't open in Finder
url = (NSURL *)CFURLCreateWithFileSystemPath(NULL, (CFStringRef)[url path], kCFURLPOSIXPathStyle, false);
*** 79,87 ****
LSApplicationParameters params = {0, flags, NULL, NULL, NULL, NULL, NULL};
status = LSOpenURLsWithRole((CFArrayRef)[NSArray arrayWithObject:url], kLSRolesAll, NULL, ¶ms, NULL, 0);
[url release];
! JNF_COCOA_EXIT(env);
return status;
}
--- 79,87 ----
LSApplicationParameters params = {0, flags, NULL, NULL, NULL, NULL, NULL};
status = LSOpenURLsWithRole((CFArrayRef)[NSArray arrayWithObject:url], kLSRolesAll, NULL, ¶ms, NULL, 0);
[url release];
! JNI_COCOA_EXIT(env);
return status;
}
< prev index next >