Skip to content

Commit

Permalink
8260616: Removing remaining JNF dependencies in the java.desktop module
Browse files Browse the repository at this point in the history
Reviewed-by: yan
  • Loading branch information
Vladimir Kempik committed Apr 2, 2021
1 parent 1f14066 commit 4c91720
Show file tree
Hide file tree
Showing 73 changed files with 474 additions and 329 deletions.
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 @@ -715,8 +714,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 @@ -813,7 +811,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 @@ -851,7 +848,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 @@ -36,7 +36,6 @@
#import "JNIUtilities.h"

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

@interface AWTView()
@property (retain) CDropTarget *_dropTarget;
Expand Down Expand Up @@ -136,7 +135,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 @@ -462,8 +461,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 @@ -576,10 +575,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 @@ -593,7 +589,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 @@ -990,8 +986,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 @@ -1056,8 +1052,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 @@ -1082,7 +1078,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 @@ -1097,7 +1093,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 @@ -1119,7 +1115,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 @@ -1172,10 +1168,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 @@ -1206,7 +1202,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 @@ -1247,7 +1243,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 @@ -1286,7 +1282,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 @@ -1327,7 +1323,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

0 comments on commit 4c91720

Please sign in to comment.