提交 f5942d67 编写于 作者: A ant

8145984: [macosx] sun.lwawt.macosx.CAccessible leaks

Reviewed-by: serb, ptbrunet
上级 0d184d68
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -25,6 +25,8 @@
package sun.lwawt.macosx;
import sun.lwawt.LWWindowPeer;
import java.awt.*;
import java.beans.*;
import java.lang.reflect.Field;
......@@ -421,6 +423,8 @@ class CAccessibility implements PropertyChangeListener {
}
public static AccessibleAction getAccessibleAction(final Accessible a, final Component c) {
if (a == null) return null;
return invokeAndWait(new Callable<AccessibleAction>() {
public AccessibleAction call() throws Exception {
final AccessibleContext ac = a.getAccessibleContext();
......@@ -667,4 +671,28 @@ class CAccessibility implements PropertyChangeListener {
}
}, c);
}
/**
* @return AWTView ptr, a peer of the CPlatformView associated with the toplevel container of the Accessible, if any
*/
private static long getAWTView(Accessible a) {
Accessible ax = CAccessible.getSwingAccessible(a);
if (!(ax instanceof Component)) return 0;
return invokeAndWait(new Callable<Long>() {
public Long call() throws Exception {
Component cont = (Component) ax;
while (cont != null && !(cont instanceof Window)) {
cont = cont.getParent();
}
if (cont != null) {
LWWindowPeer peer = (LWWindowPeer) cont.getPeer();
if (peer != null) {
return ((CPlatformWindow) peer.getPlatformWindow()).getContentView().getAWTView();
}
}
return 0L;
}
}, (Component)ax);
}
}
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -264,6 +264,8 @@ class CAccessibleText {
final double localY = boundsUnion.getY();
final Point componentLocation = ac.getAccessibleComponent().getLocationOnScreen();
if (componentLocation == null) return ret;
final double screenX = componentLocation.getX() + localX;
final double screenY = componentLocation.getY() + localY;
......
/*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -63,6 +63,8 @@
- (void) deliverJavaMouseEvent: (NSEvent *) event;
- (jobject) awtComponent:(JNIEnv *)env;
+ (AWTView *) awtView:(JNIEnv *)env ofAccessible:(jobject)jaccessible;
// Input method-related events
- (void)setInputMethod:(jobject)inputMethod;
- (void)abandonInput;
......
/*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -35,6 +35,7 @@
#import "LWCToolkit.h"
#import "JavaComponentAccessibility.h"
#import "JavaTextAccessibility.h"
#import "JavaAccessibilityUtilities.h"
#import "GeomUtilities.h"
#import "OSVersion.h"
#import "CGLLayer.h"
......@@ -132,7 +133,7 @@ AWT_ASSERT_APPKIT_THREAD;
self.cglLayer = nil;
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
(*env)->DeleteGlobalRef(env, m_cPlatformView);
(*env)->DeleteWeakGlobalRef(env, m_cPlatformView);
m_cPlatformView = NULL;
if (fInputMethodLOCKABLE != NULL)
......@@ -402,7 +403,12 @@ AWT_ASSERT_APPKIT_THREAD;
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
JNFCallVoidMethod(env, m_cPlatformView, jm_deliverMouseEvent, jEvent);
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
if (!(*env)->IsSameObject(env, jlocal, NULL)) {
JNFCallVoidMethod(env, jlocal, jm_deliverMouseEvent, jEvent);
(*env)->DeleteLocalRef(env, jlocal);
}
}
- (void) resetTrackingArea {
......@@ -463,7 +469,12 @@ AWT_ASSERT_APPKIT_THREAD;
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView,
"deliverKeyEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
JNFCallVoidMethod(env, m_cPlatformView, jm_deliverKeyEvent, jevent);
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
if (!(*env)->IsSameObject(env, jlocal, NULL)) {
JNFCallVoidMethod(env, jlocal, jm_deliverKeyEvent, jevent);
(*env)->DeleteLocalRef(env, jlocal);
}
if (characters != NULL) {
(*env)->DeleteLocalRef(env, characters);
......@@ -478,7 +489,12 @@ AWT_ASSERT_APPKIT_THREAD;
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
static JNF_MEMBER_CACHE(jm_deliverResize, jc_PlatformView, "deliverResize", "(IIII)V");
JNFCallVoidMethod(env, m_cPlatformView, jm_deliverResize, x,y,w,h);
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
if (!(*env)->IsSameObject(env, jlocal, NULL)) {
JNFCallVoidMethod(env, jlocal, jm_deliverResize, x,y,w,h);
(*env)->DeleteLocalRef(env, jlocal);
}
}
......@@ -507,7 +523,12 @@ AWT_ASSERT_APPKIT_THREAD;
*/
static JNF_CLASS_CACHE(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView");
static JNF_MEMBER_CACHE(jm_deliverWindowDidExposeEvent, jc_CPlatformView, "deliverWindowDidExposeEvent", "()V");
JNFCallVoidMethod(env, m_cPlatformView, jm_deliverWindowDidExposeEvent);
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
if (!(*env)->IsSameObject(env, jlocal, NULL)) {
JNFCallVoidMethod(env, jlocal, jm_deliverWindowDidExposeEvent);
(*env)->DeleteLocalRef(env, jlocal);
}
/*
}
*/
......@@ -535,7 +556,13 @@ AWT_ASSERT_APPKIT_THREAD;
}
return NULL;
}
jobject peer = JNFGetObjectField(env, m_cPlatformView, jf_Peer);
jobject peer = NULL;
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
if (!(*env)->IsSameObject(env, jlocal, NULL)) {
peer = JNFGetObjectField(env, jlocal, jf_Peer);
(*env)->DeleteLocalRef(env, jlocal);
}
static JNF_CLASS_CACHE(jc_LWWindowPeer, "sun/lwawt/LWWindowPeer");
static JNF_MEMBER_CACHE(jf_Target, jc_LWWindowPeer, "target", "Ljava/awt/Component;");
if (peer == NULL) {
......@@ -543,12 +570,27 @@ AWT_ASSERT_APPKIT_THREAD;
JNFDumpJavaStack(env);
return NULL;
}
return JNFGetObjectField(env, peer, jf_Target);
jobject comp = JNFGetObjectField(env, peer, jf_Target);
(*env)->DeleteLocalRef(env, peer);
return comp;
}
+ (AWTView *) awtView:(JNIEnv*)env ofAccessible:(jobject)jaccessible
{
static JNF_STATIC_MEMBER_CACHE(jm_getAWTView, sjc_CAccessibility, "getAWTView", "(Ljavax/accessibility/Accessible;)J");
jlong jptr = JNFCallStaticLongMethod(env, jm_getAWTView, jaccessible);
if (jptr == 0) return nil;
return (AWTView *)jlong_to_ptr(jptr);
}
- (id)getAxData:(JNIEnv*)env
{
return [[[JavaComponentAccessibility alloc] initWithParent:self withEnv:env withAccessible:[self awtComponent:env] withIndex:-1 withView:self withJavaRole:nil] autorelease];
jobject jcomponent = [self awtComponent:env];
id ax = [[[JavaComponentAccessibility alloc] initWithParent:self withEnv:env withAccessible:jcomponent withIndex:-1 withView:self withJavaRole:nil] autorelease];
(*env)->DeleteLocalRef(env, jcomponent);
return ax;
}
- (NSArray *)accessibilityAttributeNames
......@@ -1291,7 +1333,7 @@ Java_sun_lwawt_macosx_CPlatformView_nativeCreateView
JNF_COCOA_ENTER(env);
NSRect rect = NSMakeRect(originX, originY, width, height);
jobject cPlatformView = (*env)->NewGlobalRef(env, obj);
jobject cPlatformView = (*env)->NewWeakGlobalRef(env, obj);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
......
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -35,9 +35,9 @@
{
self = [super init];
if (self) {
fAccessibleAction = JNFNewGlobalRef(env, accessibleAction);
fAccessibleAction = JNFNewWeakGlobalRef(env, accessibleAction);
fIndex = index;
fComponent = JNFNewGlobalRef(env, component);
fComponent = JNFNewWeakGlobalRef(env, component);
}
return self;
}
......@@ -46,10 +46,10 @@
{
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
JNFDeleteGlobalRef(env, fAccessibleAction);
JNFDeleteWeakGlobalRef(env, fAccessibleAction);
fAccessibleAction = NULL;
JNFDeleteGlobalRef(env, fComponent);
JNFDeleteWeakGlobalRef(env, fComponent);
fComponent = NULL;
[super dealloc];
......@@ -59,10 +59,10 @@
{
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
JNFDeleteGlobalRef(env, fAccessibleAction);
JNFDeleteWeakGlobalRef(env, fAccessibleAction);
fAccessibleAction = NULL;
JNFDeleteGlobalRef(env, fComponent);
JNFDeleteWeakGlobalRef(env, fComponent);
fComponent = NULL;
[super finalize];
......@@ -75,7 +75,18 @@
JNIEnv* env = [ThreadUtilities getJNIEnv];
return JNFJavaToNSString(env, JNFCallStaticObjectMethod(env, jm_getAccessibleActionDescription, fAccessibleAction, fIndex, fComponent)); // AWT_THREADING Safe (AWTRunLoopMode)
jobject fCompLocal = (*env)->NewLocalRef(env, fComponent);
if ((*env)->IsSameObject(env, fCompLocal, NULL)) {
return @"unknown";
}
NSString *str = nil;
jobject jstr = JNFCallStaticObjectMethod(env, jm_getAccessibleActionDescription, fAccessibleAction, fIndex, fCompLocal);
if (jstr != NULL) {
NSString *str = JNFJavaToNSString(env, jstr); // AWT_THREADING Safe (AWTRunLoopMode)
(*env)->DeleteLocalRef(env, jstr);
}
(*env)->DeleteLocalRef(env, fCompLocal);
return str == nil ? @"unknown" : str;
}
- (void)perform
......@@ -96,9 +107,9 @@
{
self = [super init];
if (self) {
fTabGroup = JNFNewGlobalRef(env, tabGroup);
fTabGroup = JNFNewWeakGlobalRef(env, tabGroup);
fIndex = index;
fComponent = JNFNewGlobalRef(env, component);
fComponent = JNFNewWeakGlobalRef(env, component);
}
return self;
}
......@@ -107,10 +118,10 @@
{
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
JNFDeleteGlobalRef(env, fTabGroup);
JNFDeleteWeakGlobalRef(env, fTabGroup);
fTabGroup = NULL;
JNFDeleteGlobalRef(env, fComponent);
JNFDeleteWeakGlobalRef(env, fComponent);
fComponent = NULL;
[super dealloc];
......@@ -120,10 +131,10 @@
{
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
JNFDeleteGlobalRef(env, fTabGroup);
JNFDeleteWeakGlobalRef(env, fTabGroup);
fTabGroup = NULL;
JNFDeleteGlobalRef(env, fComponent);
JNFDeleteWeakGlobalRef(env, fComponent);
fComponent = NULL;
[super finalize];
......
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -77,7 +77,9 @@ NSString *getJavaRole(JNIEnv *env, jobject axComponent, jobject component)
jobject axRole = JNFCallStaticObjectMethod(env, sjm_getAccessibleRole, axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode)
if (axRole == NULL) return @"unknown";
return JNFJavaToNSString(env, axRole);
NSString* str = JNFJavaToNSString(env, axRole);
(*env)->DeleteLocalRef(env, axRole);
return str;
}
jobject getAxSelection(JNIEnv *env, jobject axContext, jobject component)
......@@ -126,21 +128,27 @@ BOOL isVertical(JNIEnv *env, jobject axContext, jobject component)
{
static JNF_STATIC_MEMBER_CACHE(jm_VERTICAL, sjc_AccessibleState, "VERTICAL", "Ljavax/accessibility/AccessibleState;");
jobject axVertState = JNFGetStaticObjectField(env, jm_VERTICAL);
return containsAxState(env, axContext, axVertState, component);
BOOL vertical = containsAxState(env, axContext, axVertState, component);
(*env)->DeleteLocalRef(env, axVertState);
return vertical;
}
BOOL isHorizontal(JNIEnv *env, jobject axContext, jobject component)
{
static JNF_STATIC_MEMBER_CACHE(jm_HORIZONTAL, sjc_AccessibleState, "HORIZONTAL", "Ljavax/accessibility/AccessibleState;");
jobject axHorizState = JNFGetStaticObjectField(env, jm_HORIZONTAL);
return containsAxState(env, axContext, axHorizState, component);
BOOL horizontal = containsAxState(env, axContext, axHorizState, component);
(*env)->DeleteLocalRef(env, axHorizState);
return horizontal;
}
BOOL isShowing(JNIEnv *env, jobject axContext, jobject component)
{
static JNF_STATIC_MEMBER_CACHE(jm_SHOWING, sjc_AccessibleState, "SHOWING", "Ljavax/accessibility/AccessibleState;");
jobject axVisibleState = JNFGetStaticObjectField(env, jm_SHOWING);
return containsAxState(env, axContext, axVisibleState, component);
BOOL showing = containsAxState(env, axContext, axVisibleState, component);
(*env)->DeleteLocalRef(env, axVisibleState);
return showing;
}
NSPoint getAxComponentLocationOnScreen(JNIEnv *env, jobject axComponent, jobject component)
......
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -112,7 +112,9 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
// if it's static text, the AppKit AXValue is the java accessibleName
jobject axName = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axName != NULL) {
return JNFJavaToNSString(env, axName);
NSString* str = JNFJavaToNSString(env, axName);
(*env)->DeleteLocalRef(env, axName);
return str;
}
// value is still nil if no accessibleName for static text. Below, try to get the accessibleText.
}
......@@ -120,12 +122,18 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
// cmcnote: inefficient to make three distinct JNI calls. Coalesce. radr://3951923
jobject axText = JNFCallStaticObjectMethod(env, sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axText == NULL) return nil;
(*env)->DeleteLocalRef(env, axText);
jobject axEditableText = JNFCallStaticObjectMethod(env, sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axEditableText == NULL) return nil;
static JNF_STATIC_MEMBER_CACHE(jm_getTextRange, sjc_CAccessibleText, "getTextRange", "(Ljavax/accessibility/AccessibleEditableText;IILjava/awt/Component;)Ljava/lang/String;");
NSString *string = JNFJavaToNSString(env, JNFCallStaticObjectMethod(env, jm_getTextRange, axEditableText, 0, getAxTextCharCount(env, axEditableText, fComponent), fComponent)); // AWT_THREADING Safe (AWTRunLoop)
jobject jrange = JNFCallStaticObjectMethod(env, jm_getTextRange, axEditableText, 0, getAxTextCharCount(env, axEditableText, fComponent), fComponent);
NSString *string = JNFJavaToNSString(env, jrange); // AWT_THREADING Safe (AWTRunLoop)
(*env)->DeleteLocalRef(env, jrange);
(*env)->DeleteLocalRef(env, axEditableText);
if (string == nil) string = @"";
return string;
}
......@@ -139,6 +147,7 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
JNIEnv* env = [ThreadUtilities getJNIEnv];
jobject axEditableText = JNFCallStaticObjectMethod(env, sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axEditableText == NULL) return NO;
(*env)->DeleteLocalRef(env, axEditableText);
return YES;
}
......@@ -157,7 +166,9 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
static JNF_STATIC_MEMBER_CACHE(jm_getSelectedText, sjc_CAccessibleText, "getSelectedText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
jobject axText = JNFCallStaticObjectMethod(env, jm_getSelectedText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axText == NULL) return @"";
return JNFJavaToNSString(env, axText);
NSString* str = JNFJavaToNSString(env, axText);
(*env)->DeleteLocalRef(env, axText);
return str;
}
- (BOOL)accessibilityIsSelectedTextAttributeSettable
......@@ -220,7 +231,9 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
// also, static text doesn't always have accessibleText. if axText is null, should get the charcount of the accessibleName instead
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject axText = JNFCallStaticObjectMethod(env, sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
return [NSNumber numberWithInt:getAxTextCharCount(env, axText, fComponent)];
NSNumber* num = [NSNumber numberWithInt:getAxTextCharCount(env, axText, fComponent)];
(*env)->DeleteLocalRef(env, axText);
return num;
}
- (BOOL)accessibilityIsNumberOfCharactersAttributeSettable
......@@ -285,7 +298,7 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getBoundsForRange, sjc_CAccessibleText, "getBoundsForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)[D");
jdoubleArray axBounds = JNFCallStaticObjectMethod(env, jm_getBoundsForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
jdoubleArray axBounds = (jdoubleArray)JNFCallStaticObjectMethod(env, jm_getBoundsForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
if (axBounds == NULL) return nil;
// We cheat because we know that the array is 4 elements long (x, y, width, height)
......@@ -324,7 +337,7 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getRangeForLine, sjc_CAccessibleText, "getRangeForLine", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I");
jintArray axTextRange = JNFCallStaticObjectMethod(env, jm_getRangeForLine, fAccessible, fComponent, [line intValue]); // AWT_THREADING Safe (AWTRunLoop)
jintArray axTextRange = (jintArray)JNFCallStaticObjectMethod(env, jm_getRangeForLine, fAccessible, fComponent, [line intValue]); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaIntArrayToNSRangeValue(env,axTextRange);
......@@ -350,10 +363,12 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getStringForRange, sjc_CAccessibleText, "getStringForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)Ljava/lang/String;");
jstring jstringForRange = JNFCallStaticObjectMethod(env, jm_getStringForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
jstring jstringForRange = (jstring)JNFCallStaticObjectMethod(env, jm_getStringForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
if (jstringForRange == NULL) return @"";
return JNFJavaToNSString(env, jstringForRange);
NSString* str = JNFJavaToNSString(env, jstringForRange);
(*env)->DeleteLocalRef(env, jstringForRange);
return str;
}
//
......@@ -406,7 +421,7 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getRangeForIndex, sjc_CAccessibleText, "getRangeForIndex", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I");
jintArray axTextRange = JNFCallStaticObjectMethod(env, jm_getRangeForIndex, fAccessible, fComponent, index); // AWT_THREADING Safe (AWTRunLoop)
jintArray axTextRange = (jintArray)JNFCallStaticObjectMethod(env, jm_getRangeForIndex, fAccessible, fComponent, index); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaIntArrayToNSRangeValue(env, axTextRange);
......
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -31,7 +31,7 @@
@interface CGLLayer : CAOpenGLLayer
{
@private
JNFJObjectWrapper *javaLayer;
JNFWeakJObjectWrapper *javaLayer;
// intermediate buffer, used the RQ lock to synchronize
GLuint textureID;
......@@ -45,7 +45,7 @@
#endif /* REMOTELAYER */
}
@property (nonatomic, retain) JNFJObjectWrapper *javaLayer;
@property (nonatomic, retain) JNFWeakJObjectWrapper *javaLayer;
@property (readwrite, assign) GLuint textureID;
@property (readwrite, assign) GLenum target;
@property (readwrite, assign) float textureWidth;
......@@ -57,7 +57,7 @@
@property (nonatomic, retain) NSObject<JRSRemoteLayer> *jrsRemoteLayer;
#endif
- (id) initWithJavaLayer:(JNFJObjectWrapper *)javaLayer;
- (id) initWithJavaLayer:(JNFWeakJObjectWrapper *)javaLayer;
- (void) blitTexture;
@end
......
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -46,7 +46,7 @@ extern NSOpenGLContext *sharedContext;
@synthesize jrsRemoteLayer;
#endif
- (id) initWithJavaLayer:(JNFJObjectWrapper *)layer;
- (id) initWithJavaLayer:(JNFWeakJObjectWrapper *)layer;
{
AWT_ASSERT_APPKIT_THREAD;
// Initialize ourselves
......@@ -133,6 +133,15 @@ AWT_ASSERT_APPKIT_THREAD;
{
AWT_ASSERT_APPKIT_THREAD;
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_CLASS_CACHE(jc_JavaLayer, "sun/java2d/opengl/CGLLayer");
static JNF_MEMBER_CACHE(jm_drawInCGLContext, jc_JavaLayer, "drawInCGLContext", "()V");
jobject javaLayerLocalRef = [self.javaLayer jObjectWithEnv:env];
if ((*env)->IsSameObject(env, javaLayerLocalRef, NULL)) {
return;
}
// Set the current context to the one given to us.
CGLSetCurrentContext(glContext);
......@@ -141,12 +150,7 @@ AWT_ASSERT_APPKIT_THREAD;
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, textureWidth, textureHeight);
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_CLASS_CACHE(jc_JavaLayer, "sun/java2d/opengl/CGLLayer");
static JNF_MEMBER_CACHE(jm_drawInCGLContext, jc_JavaLayer, "drawInCGLContext", "()V");
jobject javaLayerLocalRef = [self.javaLayer jObjectWithEnv:env];
JNFCallVoidMethod(env, javaLayerLocalRef, jm_drawInCGLContext);
(*env)->DeleteLocalRef(env, javaLayerLocalRef);
......@@ -171,7 +175,7 @@ Java_sun_java2d_opengl_CGLLayer_nativeCreateLayer
JNF_COCOA_ENTER(env);
JNFJObjectWrapper *javaLayer = [JNFJObjectWrapper wrapperWithJObject:obj withEnv:env];
JNFWeakJObjectWrapper *javaLayer = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env];
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
AWT_ASSERT_APPKIT_THREAD;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册