<AWT Dev> RFR: 8257853: Remove dependencies on JNF's JNI utility functions in AWT and 2D code [v6]

Prasanta Sadhukhan psadhukhan at openjdk.java.net
Fri Dec 18 11:23:33 UTC 2020


On Thu, 17 Dec 2020 21:32:16 GMT, Phil Race <prr at openjdk.org> wrote:

>> This defines some macros to support declaring and initialising statically allocated instances of jclass, jmethodID and jfieldID
>> and changes many existing uses of JNF macros/functions to use these instead.
>> Then calls to JNFCall* and JNFNewObject - etc are updated to directly call JNI methods
>> JNI exception checking macros are added as needed.
>
> Phil Race has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8257853: Remove dependencies on JNF's JNI utility functions in AWT and 2D code

I believe we could add CHECK_EXCEPTION in few places...pointing those out...

src/java.desktop/macosx/native/libosxui/ScreenMenu.m line 154:

> 152:     (*env)->CallVoidMethod(env, [self.javaObjectWrapper jObject], jm_ScreenMenu_updateSelectedItem, menuIndex,
> 153:                     NSMinY(rect), NSMinX(rect), NSMaxY(rect), NSMaxX(rect)); // AWT_THREADING Safe (AWTRunLoopMode)
> 154: 

Don't we need to call CHECK_EXCEPTION here?

src/java.desktop/macosx/native/libawt_lwawt/awt/CDragSource.m line 575:

> 573:         DECLARE_METHOD(dragDropFinishedMethod, CDragSourceContextPeerClass, "dragDropFinished", "(ZIII)V");
> 574:         DLog3(@"  -> posting dragDropFinished, point %f, %f", point.x, point.y);
> 575:         (*env)->CallVoidMethod(env, fDragSourceContextPeer, dragDropFinishedMethod, success, dragOp, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)

CHECK_EXCEPTION missed?

src/java.desktop/macosx/native/libawt_lwawt/awt/CDropTarget.m line 511:

> 509:             // Double-casting self gets rid of 'different size' compiler warning:
> 510:             // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
> 511:             actions = (*env)->CallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod,

Should call CHECK_EXCEPTION here

src/java.desktop/macosx/native/libawt_lwawt/awt/CDropTarget.m line 596:

> 594:         if (sDraggingError == FALSE) {
> 595:             DLog3(@"  >> posting handleMotionMessage, point %f, %f", javaLocation.x, javaLocation.y);
> 596:             userAction = (*env)->CallIntMethod(env, fDropTargetContextPeer, handleMotionMessageMethod, fComponent,

CHECK_EXCEPTION missing

src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m line 454:

> 452:     jint selectID = (*env)->CallIntMethod(env, srcPrinterJob, jm_getSelectAttrib);
> 453:     jint fromPage = (*env)->CallIntMethod(env, srcPrinterJob, jm_getFromPage);
> 454:     jint toPage = (*env)->CallIntMethod(env, srcPrinterJob, jm_getToPage);

CHECK_EXCEPTION missing

src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterView.m line 220:

> 218:                     [[[NSPrintOperation currentOperation] printInfo] orientation];
> 219:             // set page orientation
> 220:             switch ((*env)->CallIntMethod(env, fCurPageFormat, jm_getOrientation)) {

CHECK_EXCEPTION?

src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m line 625:

> 623:         NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr((*env)->CallLongMethod(env, jthis, sjm_getNSPrintInfo)); // AWT_THREADING Safe (known object)
> 624:         CHECK_EXCEPTION();
> 625:         jobject printerTrayObj = (*env)->CallObjectMethod(env, jthis, jm_getPrinterTray);

CHECK_EXCEPTION?

src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m line 649:

> 647: 
> 648:         // <rdar://problem/4367998> JTable.print attributes are ignored
> 649:         jobject pageable = (*env)->CallObjectMethod(env, jthis, jm_getPageable); // AWT_THREADING Safe (!appKit)

same CHECK_EXCEPTION?

src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m line 694:

> 692:     jobject printerJob = (*env)->GetObjectField(env, jthis, sjm_printerJob);
> 693:     if (printerJob == NULL) return NO;
> 694:     NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr((*env)->CallLongMethod(env, printerJob, sjm_getNSPrintInfo)); // AWT_THREADING Safe (known object)

missing CHECK_EXCEPTION

src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m line 743:

> 741:     if (printerJob == NULL) return NO;
> 742:     GET_NSPRINTINFO_METHOD_RETURN(NO)
> 743:     NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr((*env)->CallLongMethod(env, printerJob, sjm_getNSPrintInfo)); // AWT_THREADING Safe (known object)

CHECK_EXCEPTION?

src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m line 274:

> 272:         DECLARE_CLASS(jc_CTrayIcon, "sun/lwawt/macosx/CTrayIcon");
> 273:         DECLARE_METHOD(jm_getPopupMenuModel, jc_CTrayIcon, "getPopupMenuModel", "()J");
> 274:         jlong res = (*env)->CallLongMethod(env, trayIcon.peer, jm_getPopupMenuModel);

CHECK_EXCEPTION?

src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterView.m line 125:

> 123:     DECLARE_METHOD_RETURN(jm_getJobName, sjc_CPrinterJob, "getJobName", "()Ljava/lang/String;", nil);
> 124: 
> 125:     jobject o = (*env)->CallObjectMethod(env, fPrinterJob, jm_getJobName); // AWT_THREADING Safe (known object)

CHECK_EXCEPTION?

src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterView.m line 196:

> 194:     }
> 195: 
> 196:     jobjectArray objectArray = (*env)->CallObjectMethod(env, fPrinterJob,

CHECK_EXCEPTION?

src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterView.m line 214:

> 212: 
> 213:         // Actually print and get the PageFormatArea
> 214:         jobject pageFormatArea = (*env)->CallObjectMethod(env, fPrinterJob, jm_printAndGetPageFormatArea, fCurPainter,

CHECK_EXCEPTION?

-------------

PR: https://git.openjdk.java.net/jdk/pull/1679


More information about the awt-dev mailing list