Skip to content

8362572: Delete the usage of "sun.java2d.reftype" from the sun.java2d.Disposer #26394

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 1 commit into from
Closed
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
31 changes: 6 additions & 25 deletions src/java.desktop/share/classes/sun/java2d/Disposer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2025, 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
Expand All @@ -25,15 +25,15 @@

package sun.java2d;

import sun.awt.util.ThreadGroupUtils;

import java.lang.ref.PhantomReference;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.PhantomReference;
import java.lang.ref.WeakReference;
import java.util.Hashtable;
import java.util.concurrent.ConcurrentLinkedDeque;

import sun.awt.util.ThreadGroupUtils;

/**
* This class is used for registering and disposing the native
* data associated with java objects.
Expand All @@ -54,24 +54,11 @@ public class Disposer implements Runnable {
private static final Hashtable<java.lang.ref.Reference<Object>, DisposerRecord> records =
new Hashtable<>();

private static Disposer disposerInstance;
public static final int WEAK = 0;
public static final int PHANTOM = 1;
public static int refType = PHANTOM;
private static final Disposer disposerInstance;

static {
System.loadLibrary("awt");
initIDs();
String type = System.getProperty("sun.java2d.reftype");
if (type != null) {
if (type.equals("weak")) {
refType = WEAK;
System.err.println("Using WEAK refs");
} else {
refType = PHANTOM;
System.err.println("Using PHANTOM refs");
}
}
disposerInstance = new Disposer();
String name = "Java2D Disposer";
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
Expand Down Expand Up @@ -118,13 +105,7 @@ synchronized void add(Object target, DisposerRecord rec) {
if (target instanceof DisposerTarget) {
target = ((DisposerTarget)target).getDisposerReferent();
}
java.lang.ref.Reference<Object> ref;
if (refType == PHANTOM) {
ref = new PhantomReference<>(target, queue);
} else {
ref = new WeakReference<>(target, queue);
}
records.put(ref, rec);
records.put(new PhantomReference<>(target, queue), rec);
}

public void run() {
Expand Down