Skip to content

8260616: Removing remaining JNF dependencies in the java.desktop module #2305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions make/modules/java.desktop/Lib.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ ifeq ($(call isTargetOs, macosx), true)
-framework Cocoa \
-framework Security \
-framework ExceptionHandling \
-framework JavaNativeFoundation \
-framework JavaRuntimeSupport \
-framework OpenGL \
-framework IOSurface \
Expand All @@ -127,7 +126,6 @@ ifeq ($(call isTargetOs, macosx), true)
-losxapp \
-framework Cocoa \
-framework ApplicationServices \
-framework JavaNativeFoundation \
-framework JavaRuntimeSupport \
-framework SystemConfiguration \
$(JDKLIB_LIBS), \
Expand Down
6 changes: 1 addition & 5 deletions make/modules/java.desktop/lib/Awt2dLibraries.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \
LIBS_macosx := -lmlib_image \
-framework Cocoa \
-framework OpenGL \
-framework JavaNativeFoundation \
-framework JavaRuntimeSupport \
-framework ApplicationServices \
-framework AudioToolbox, \
Expand Down Expand Up @@ -767,8 +766,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false)
-framework ApplicationServices \
-framework Foundation \
-framework Security \
-framework Cocoa \
-framework JavaNativeFoundation
-framework Cocoa
else ifeq ($(call isTargetOs, windows), true)
LIBSPLASHSCREEN_LIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib $(WIN_JAVA_LIB) jvm.lib
else
Expand Down Expand Up @@ -866,7 +864,6 @@ ifeq ($(call isTargetOs, macosx), true)
-framework Cocoa \
-framework Security \
-framework ExceptionHandling \
-framework JavaNativeFoundation \
-framework JavaRuntimeSupport \
-framework OpenGL \
-framework QuartzCore -ljava, \
Expand Down Expand Up @@ -904,7 +901,6 @@ ifeq ($(call isTargetOs, macosx), true)
-framework Cocoa \
-framework Carbon \
-framework ApplicationServices \
-framework JavaNativeFoundation \
-framework JavaRuntimeSupport \
-ljava -ljvm, \
))
Expand Down
2 changes: 1 addition & 1 deletion make/test/JtregNativeJdk.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ endif
ifeq ($(call isTargetOs, macosx), true)
BUILD_JDK_JTREG_EXCLUDE += exelauncher.c
BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestMainKeyWindow := \
-framework Cocoa -framework JavaNativeFoundation
-framework Cocoa
BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeJniInvocationTest := -ljli
BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestDynamicStore := \
-framework Cocoa -framework SystemConfiguration
Expand Down
1 change: 0 additions & 1 deletion src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#import "JNIUtilities.h"

#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import <sys/time.h>
#import <Carbon/Carbon.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#import "LWCToolkit.h"
#import "JNIUtilities.h"

#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import <QuartzCore/CATransaction.h>

@implementation AWTSurfaceLayers
Expand Down
40 changes: 18 additions & 22 deletions src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#import "JNIUtilities.h"

#import <Carbon/Carbon.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>

// keyboard layout
static NSString *kbdLayout;
Expand Down Expand Up @@ -135,7 +134,7 @@ - (void) viewDidMoveToWindow {

[AWTToolkit eventCountPlusPlus];

[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
[ThreadUtilities performOnMainThreadWaiting:NO block:^() {
[[self window] makeFirstResponder: self];
}];
if ([self window] != NULL) {
Expand Down Expand Up @@ -461,8 +460,8 @@ -(void) deliverJavaKeyEventHelper: (NSEvent *) event {
jstring characters = NULL;
jstring charactersIgnoringModifiers = NULL;
if ([event type] != NSFlagsChanged) {
characters = JNFNSToJavaString(env, [event characters]);
charactersIgnoringModifiers = JNFNSToJavaString(env, [event charactersIgnoringModifiers]);
characters = NSStringToJavaString(env, [event characters]);
charactersIgnoringModifiers = NSStringToJavaString(env, [event charactersIgnoringModifiers]);
}

DECLARE_CLASS(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
Expand Down Expand Up @@ -575,10 +574,7 @@ - (jobject)awtComponent:(JNIEnv*)env
DECLARE_FIELD_RETURN(jf_Peer, jc_CPlatformView, "peer", "Lsun/lwawt/LWWindowPeer;", NULL);
if ((env == NULL) || (m_cPlatformView == NULL)) {
NSLog(@"Apple AWT : Error AWTView:awtComponent given bad parameters.");
if (env != NULL)
{
JNFDumpJavaStack(env);
}
NSLog(@"%@",[NSThread callStackSymbols]);
return NULL;
}

Expand All @@ -592,7 +588,7 @@ - (jobject)awtComponent:(JNIEnv*)env
DECLARE_FIELD_RETURN(jf_Target, jc_LWWindowPeer, "target", "Ljava/awt/Component;", NULL);
if (peer == NULL) {
NSLog(@"Apple AWT : Error AWTView:awtComponent got null peer from CPlatformView");
JNFDumpJavaStack(env);
NSLog(@"%@",[NSThread callStackSymbols]);
return NULL;
}
jobject comp = (*env)->GetObjectField(env, peer, jf_Target);
Expand Down Expand Up @@ -989,8 +985,8 @@ - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
}

DECLARE_METHOD(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V");
jstring insertedText = JNFNSToJavaString(env, useString);
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode)
jstring insertedText = NSStringToJavaString(env, useString);
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText);
CHECK_EXCEPTION();
(*env)->DeleteLocalRef(env, insertedText);

Expand Down Expand Up @@ -1055,8 +1051,8 @@ - (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replace
// NSInputContext already did the analysis of the TSM event and created attributes indicating
// the underlining and color that should be done to the string. We need to look at the underline
// style and color to determine what kind of Java hilighting needs to be done.
jstring inProcessText = JNFNSToJavaString(env, incomingString);
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_startIMUpdate, inProcessText); // AWT_THREADING Safe (AWTRunLoopMode)
jstring inProcessText = NSStringToJavaString(env, incomingString);
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_startIMUpdate, inProcessText);
CHECK_EXCEPTION();
(*env)->DeleteLocalRef(env, inProcessText);

Expand All @@ -1081,7 +1077,7 @@ - (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replace
isGray = !([underlineColorObj isEqual:[NSColor blackColor]]);

(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_addAttribute, isThickUnderline,
isGray, effectiveRange.location, effectiveRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
isGray, effectiveRange.location, effectiveRange.length);
CHECK_EXCEPTION();
}
}
Expand All @@ -1096,7 +1092,7 @@ - (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replace
}

(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_dispatchText,
selectionRange.location, selectionRange.length, JNI_FALSE); // AWT_THREADING Safe (AWTRunLoopMode)
selectionRange.location, selectionRange.length, JNI_FALSE);
CHECK_EXCEPTION();
// If the marked text is being cleared (zero-length string) don't handle the key event.
if ([incomingString length] == 0) {
Expand All @@ -1118,7 +1114,7 @@ - (void) unmarkText
JNIEnv *env = [ThreadUtilities getJNIEnv];
GET_CIM_CLASS();
DECLARE_METHOD(jm_unmarkText, jc_CInputMethod, "unmarkText", "()V");
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_unmarkText); // AWT_THREADING Safe (AWTRunLoopMode)
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_unmarkText);
CHECK_EXCEPTION();
}

Expand Down Expand Up @@ -1171,10 +1167,10 @@ - (NSAttributedString *) attributedSubstringForProposedRange:(NSRange)theRange a

JNIEnv *env = [ThreadUtilities getJNIEnv];
DECLARE_METHOD_RETURN(jm_substringFromRange, jc_CInputMethod, "attributedSubstringFromRange", "(II)Ljava/lang/String;", nil);
jobject theString = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_substringFromRange, theRange.location, theRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
jobject theString = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_substringFromRange, theRange.location, theRange.length);
CHECK_EXCEPTION_NULL_RETURN(theString, nil);

id result = [[[NSAttributedString alloc] initWithString:JNFJavaToNSString(env, theString)] autorelease];
id result = [[[NSAttributedString alloc] initWithString:JavaStringToNSString(env, theString)] autorelease];
#ifdef IM_DEBUG
NSLog(@"attributedSubstringFromRange returning \"%@\"", result);
#endif // IM_DEBUG
Expand Down Expand Up @@ -1205,7 +1201,7 @@ - (NSRange) markedRange
GET_CIM_CLASS_RETURN(range);
DECLARE_METHOD_RETURN(jm_markedRange, jc_CInputMethod, "markedRange", "()[I", range);

array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_markedRange); // AWT_THREADING Safe (AWTRunLoopMode)
array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_markedRange);
CHECK_EXCEPTION();

if (array) {
Expand Down Expand Up @@ -1246,7 +1242,7 @@ - (NSRange) selectedRange
fprintf(stderr, "AWTView InputMethod Selector Called : [selectedRange]\n");
#endif // IM_DEBUG

array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_selectedRange); // AWT_THREADING Safe (AWTRunLoopMode)
array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_selectedRange);
CHECK_EXCEPTION();
if (array) {
_array = (*env)->GetIntArrayElements(env, array, &isCopy);
Expand Down Expand Up @@ -1285,7 +1281,7 @@ - (NSRect) firstRectForCharacterRange:(NSRange)theRange actualRange:(NSRangePoin
#endif // IM_DEBUG

array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_firstRectForCharacterRange,
theRange.location); // AWT_THREADING Safe (AWTRunLoopMode)
theRange.location);
CHECK_EXCEPTION();

_array = (*env)->GetIntArrayElements(env, array, &isCopy);
Expand Down Expand Up @@ -1326,7 +1322,7 @@ - (NSUInteger)characterIndexForPoint:(NSPoint)thePoint
#endif // IM_DEBUG

jint index = (*env)->CallIntMethod(env, fInputMethodLOCKABLE, jm_characterIndexForPoint,
(jint)flippedLocation.x, (jint)flippedLocation.y); // AWT_THREADING Safe (AWTRunLoopMode)
(jint)flippedLocation.x, (jint)flippedLocation.y);
CHECK_EXCEPTION();

#ifdef IM_DEBUG
Expand Down
5 changes: 2 additions & 3 deletions src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/

#import <Cocoa/Cocoa.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>

#import "sun_lwawt_macosx_CPlatformWindow.h"
#import "com_apple_eawt_event_GestureHandler.h"
Expand Down Expand Up @@ -1444,7 +1443,7 @@ + (AWTWindow *) lastKeyWindow {

NSWindow *nsWindow = OBJC(windowPtr);
[nsWindow performSelectorOnMainThread:@selector(setTitle:)
withObject:JNFJavaToNSString(env, jtitle)
withObject:JavaStringToNSString(env, jtitle)
waitUntilDone:NO];

JNI_COCOA_EXIT(env);
Expand Down Expand Up @@ -1520,7 +1519,7 @@ + (AWTWindow *) lastKeyWindow {
JNI_COCOA_ENTER(env);

NSWindow *nsWindow = OBJC(windowPtr);
NSURL *url = (filename == NULL) ? nil : [NSURL fileURLWithPath:JNFNormalizedNSStringForPath(env, filename)];
NSURL *url = (filename == NULL) ? nil : [NSURL fileURLWithPath:NormalizedPathNSStringFromJavaString(env, filename)];
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[nsWindow setRepresentedURL:url];
}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#import "com_apple_eawt__AppMenuBarHandler.h"
#import "com_apple_eawt__AppMiscHandlers.h"

#import <JavaNativeFoundation/JavaNativeFoundation.h>

#import "CPopupMenu.h"
#import "CMenuBar.h"
#import "ThreadUtilities.h"
Expand Down Expand Up @@ -290,10 +288,10 @@ - (void)_handleOpenURLEvent:(NSAppleEventDescriptor *)openURLEvent withReplyEven

//fprintf(stderr,"jm_handleOpenURL\n");
JNIEnv *env = [ThreadUtilities getJNIEnv];
jstring jURL = JNFNSToJavaString(env, url);
jstring jURL = NSStringToJavaString(env, url);
GET_APPEVENTHANDLER_CLASS();
DECLARE_STATIC_METHOD(jm_handleOpenURI, sjc_AppEventHandler, "handleOpenURI", "(Ljava/lang/String;)V");
(*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleOpenURI, jURL); // AWT_THREADING Safe (event)
(*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleOpenURI, jURL);
CHECK_EXCEPTION();
(*env)->DeleteLocalRef(env, jURL);

Expand All @@ -312,11 +310,11 @@ - (jobject)_createFilePathArrayFrom:(NSArray *)filenames withEnv:(JNIEnv *)env {
DECLARE_METHOD_RETURN(jm_ArrayList_ctor, sjc_ArrayList, "<init>", "(I)V", NULL);
DECLARE_METHOD_RETURN(jm_ArrayList_add, sjc_ArrayList, "add", "(Ljava/lang/Object;)Z", NULL);

jobject jFileNamesArray = (*env)->NewObject(env, sjc_ArrayList, jm_ArrayList_ctor, (jint)[filenames count]); // AWT_THREADING Safe (known object)
jobject jFileNamesArray = (*env)->NewObject(env, sjc_ArrayList, jm_ArrayList_ctor, (jint)[filenames count]);
CHECK_EXCEPTION_NULL_RETURN(jFileNamesArray, NULL);

for (NSString *filename in filenames) {
jstring jFileName = JNFNormalizedJavaStringForPath(env, filename);
jstring jFileName = NormalizedPathJavaStringFromNSString(env, filename);
(*env)->CallVoidMethod(env, jFileNamesArray, jm_ArrayList_add, jFileName);
CHECK_EXCEPTION();
}
Expand All @@ -338,7 +336,7 @@ - (void)application:(NSApplication *)theApplication openFiles:(NSArray *)fileNam
// if these files were opened from a Spotlight query, try to get the search text from the current AppleEvent
NSAppleEventDescriptor *currentEvent = [[NSAppleEventManager sharedAppleEventManager] currentAppleEvent];
NSString *searchString = [[currentEvent paramDescriptorForKeyword:keyAESearchText] stringValue];
jstring jSearchString = JNFNSToJavaString(env, searchString);
jstring jSearchString = NSStringToJavaString(env, searchString);

// convert the file names array
jobject jFileNamesArray = [self _createFilePathArrayFrom:fileNames withEnv:env];
Expand All @@ -365,7 +363,7 @@ - (NSApplicationPrintReply)application:(NSApplication *)application printFiles:(
GET_APPEVENTHANDLER_CLASS_RETURN(NSPrintingCancelled);
DECLARE_STATIC_METHOD_RETURN(jm_handlePrintFile, sjc_AppEventHandler,
"handlePrintFiles", "(Ljava/util/List;)V", NSPrintingCancelled);
(*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handlePrintFile, jFileNamesArray); // AWT_THREADING Safe (event)
(*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handlePrintFile, jFileNamesArray);
CHECK_EXCEPTION();
(*env)->DeleteLocalRef(env, jFileNamesArray);

Expand All @@ -380,7 +378,7 @@ + (void)_notifyJava:(jint)notificationType {
JNIEnv *env = [ThreadUtilities getJNIEnv];
GET_APPEVENTHANDLER_CLASS();
DECLARE_STATIC_METHOD(jm_handleNativeNotification, sjc_AppEventHandler, "handleNativeNotification", "(I)V");
(*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleNativeNotification, notificationType); // AWT_THREADING Safe (event)
(*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleNativeNotification, notificationType);
CHECK_EXCEPTION();
}

Expand Down Expand Up @@ -624,7 +622,7 @@ + (NSImage *)_dockIconImage {
[ThreadUtilities performOnMainThread:@selector(_registerForNotification:)
on:[ApplicationDelegate class]
withObject:[NSNumber numberWithInt:notificationType]
waitUntilDone:NO]; // AWT_THREADING Safe (non-blocking)
waitUntilDone:NO];
JNI_COCOA_EXIT(env);
}

Expand Down Expand Up @@ -714,7 +712,7 @@ + (NSImage *)_dockIconImage {
{
JNI_COCOA_ENTER(env);

NSString *badgeString = JNFJavaToNSString(env, badge);
NSString *badgeString = JavaStringToNSString(env, badge);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
NSDockTile *dockTile = [NSApp dockTile];
[dockTile setBadgeLabel:badgeString];
Expand Down
3 changes: 1 addition & 2 deletions src/java.desktop/macosx/native/libawt_lwawt/awt/CClipboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#import "ThreadUtilities.h"
#import "JNIUtilities.h"
#import <Cocoa/Cocoa.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>

@interface CClipboard : NSObject { }
@property NSInteger changeCount;
Expand Down Expand Up @@ -99,7 +98,7 @@ - (void)checkPasteboard:(id)sender {
DECLARE_METHOD(jm_lostOwnership, jc_CClipboard, "notifyLostOwnership", "()V");
@synchronized(self) {
if (self.clipboardOwner) {
(*env)->CallVoidMethod(env, self.clipboardOwner, jm_lostOwnership); // AWT_THREADING Safe (event)
(*env)->CallVoidMethod(env, self.clipboardOwner, jm_lostOwnership);
CHECK_EXCEPTION();
(*env)->DeleteGlobalRef(env, self.clipboardOwner);
self.clipboardOwner = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "sun_lwawt_macosx_CCursorManager.h"

#include <Cocoa/Cocoa.h>
#include <JavaNativeFoundation/JavaNativeFoundation.h>

#include "GeomUtilities.h"
#include "ThreadUtilities.h"
Expand Down Expand Up @@ -75,7 +74,7 @@ static void setCursorOnAppKitThread(NSCursor *cursor) {
{
JNI_COCOA_ENTER(env);

NSString *cursorName = JNFJavaToNSString(env, name);
NSString *cursorName = JavaStringToNSString(env, name);
SEL cursorSelector = (type == sun_lwawt_macosx_CCursorManager_NAMED_CURSOR) ? lookupCursorSelectorForName(cursorName) : lookupCursorSelectorForType(type);
if (cursorSelector == nil) {
NSString *reason = [NSString stringWithFormat:@"unimplemented built-in cursor type: %d / %@", type, cursorName];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@

#import "JNIUtilities.h"

#import <JavaNativeFoundation/JavaNativeFoundation.h>


// ***** NOTE ***** This dictionary corresponds to the static array predefinedClipboardNames
// in CDataTransferer.java.
NSMutableDictionary *sStandardMappings = nil;
Expand Down Expand Up @@ -110,7 +107,7 @@ jlong registerFormatWithPasteboard(NSString *format) {
{
jlong returnValue = -1;
JNI_COCOA_ENTER(env);
returnValue = registerFormatWithPasteboard(JNFJavaToNSString(env, newformat));
returnValue = registerFormatWithPasteboard(JavaStringToNSString(env, newformat));
JNI_COCOA_EXIT(env);
return returnValue;
}
Expand All @@ -125,7 +122,7 @@ jlong registerFormatWithPasteboard(NSString *format) {
{
jstring returnValue = NULL;
JNI_COCOA_ENTER(env);
returnValue = JNFNSToJavaString(env, formatForIndex(index));
returnValue = NSStringToJavaString(env, formatForIndex(index));
JNI_COCOA_EXIT(env);
return returnValue;
}
Expand All @@ -138,7 +135,7 @@ static jobjectArray CreateJavaFilenameArray(JNIEnv *env, NSArray *filenameArray)
// Get the java.lang.String class object:
jclass stringClazz = (*env)->FindClass(env, "java/lang/String");
CHECK_NULL_RETURN(stringClazz, nil);
jobject jfilenameArray = (*env)->NewObjectArray(env, filenameCount, stringClazz, NULL); // AWT_THREADING Safe (known object)
jobject jfilenameArray = (*env)->NewObjectArray(env, filenameCount, stringClazz, NULL);
if ((*env)->ExceptionOccurred(env)) {
(*env)->ExceptionDescribe(env);
(*env)->ExceptionClear(env);
Expand Down
Loading