mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-14 07:29:51 +00:00
8362291: [macOS] Remove finalize method in CGraphicsEnvironment.java
Reviewed-by: bchristi, serb, kizune
This commit is contained in:
parent
b8da9695f0
commit
523993e9e8
@ -37,6 +37,8 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
import sun.java2d.Disposer;
|
||||
import sun.java2d.DisposerRecord;
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
|
||||
/**
|
||||
@ -82,7 +84,7 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
/**
|
||||
* Remove the instance's registration with CGDisplayRemoveReconfigurationCallback()
|
||||
*/
|
||||
private native void deregisterDisplayReconfiguration(long context);
|
||||
private static native void deregisterDisplayReconfiguration(long context);
|
||||
|
||||
/** Available CoreGraphics displays. */
|
||||
private final Map<Integer, CGraphicsDevice> devices = new HashMap<>(5);
|
||||
@ -93,6 +95,7 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
|
||||
/** Reference to the display reconfiguration callback context. */
|
||||
private final long displayReconfigContext;
|
||||
private final Object disposerReferent = new Object();
|
||||
|
||||
// list of invalidated graphics devices (those which were removed)
|
||||
private List<WeakReference<CGraphicsDevice>> oldDevices = new ArrayList<>();
|
||||
@ -114,6 +117,7 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
if (displayReconfigContext == 0L) {
|
||||
throw new RuntimeException("Could not register CoreGraphics display reconfiguration callback");
|
||||
}
|
||||
Disposer.addRecord(disposerReferent, new CGEDisposerRecord(displayReconfigContext));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,12 +143,14 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
rebuildDevices();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
super.finalize();
|
||||
} finally {
|
||||
private static class CGEDisposerRecord implements DisposerRecord {
|
||||
private final long displayReconfigContext;
|
||||
|
||||
CGEDisposerRecord(long ptr) {
|
||||
displayReconfigContext = ptr;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
deregisterDisplayReconfiguration(displayReconfigContext);
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ JNI_COCOA_EXIT(env);
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_awt_CGraphicsEnvironment_deregisterDisplayReconfiguration
|
||||
(JNIEnv *env, jobject this, jlong p)
|
||||
(JNIEnv *env, jclass clazz, jlong p)
|
||||
{
|
||||
JNI_COCOA_ENTER(env);
|
||||
|
||||
|
||||
@ -137,7 +137,7 @@ public class Disposer implements Runnable {
|
||||
obj = null;
|
||||
rec = null;
|
||||
clearDeferredRecords();
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable t) {
|
||||
System.out.println("Exception while removing reference.");
|
||||
}
|
||||
}
|
||||
@ -157,7 +157,7 @@ public class Disposer implements Runnable {
|
||||
private static void safeDispose(DisposerRecord rec) {
|
||||
try {
|
||||
rec.dispose();
|
||||
} catch (final Exception e) {
|
||||
} catch (final Throwable t) {
|
||||
System.out.println("Exception while disposing deferred rec.");
|
||||
}
|
||||
}
|
||||
@ -212,7 +212,7 @@ public class Disposer implements Runnable {
|
||||
deferredRecords.offerLast(rec);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable t) {
|
||||
System.out.println("Exception while removing reference.");
|
||||
} finally {
|
||||
pollingQueue = false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user