Skip to content

Commit

Permalink
8251861: Remove unused jdk.internal.ref.SoftCleanable and WeakCleanable
Browse files Browse the repository at this point in the history
Reviewed-by: mchung, rriggs
  • Loading branch information
Kiran Sidhartha Ravikumar authored and coffeys committed Oct 13, 2020
1 parent 6ed4c89 commit ba24f96
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 635 deletions.
115 changes: 2 additions & 113 deletions src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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 Down Expand Up @@ -52,10 +52,6 @@ public final class CleanerImpl implements Runnable {
*/
final PhantomCleanable<?> phantomCleanableList;

final WeakCleanable<?> weakCleanableList;

final SoftCleanable<?> softCleanableList;

// The ReferenceQueue of pending cleaning actions
final ReferenceQueue<Object> queue;

Expand Down Expand Up @@ -87,8 +83,6 @@ static CleanerImpl getCleanerImpl(Cleaner cleaner) {
public CleanerImpl() {
queue = new ReferenceQueue<>();
phantomCleanableList = new PhantomCleanableRef();
weakCleanableList = new WeakCleanableRef();
softCleanableList = new SoftCleanableRef();
}

/**
Expand Down Expand Up @@ -135,9 +129,7 @@ public void run() {
InnocuousThread mlThread = (t instanceof InnocuousThread)
? (InnocuousThread) t
: null;
while (!phantomCleanableList.isListEmpty() ||
!weakCleanableList.isListEmpty() ||
!softCleanableList.isListEmpty()) {
while (!phantomCleanableList.isListEmpty()) {
if (mlThread != null) {
// Clear the thread locals
mlThread.eraseThreadLocals();
Expand Down Expand Up @@ -207,109 +199,6 @@ public void clear() {
}
}

/**
* Perform cleaning on an unreachable WeakReference.
*/
public static final class WeakCleanableRef extends WeakCleanable<Object> {
private final Runnable action;

/**
* Constructor for a weak cleanable reference.
* @param obj the object to monitor
* @param cleaner the cleaner
* @param action the action Runnable
*/
WeakCleanableRef(Object obj, Cleaner cleaner, Runnable action) {
super(obj, cleaner);
this.action = action;
}

/**
* Constructor used only for root of weak cleanable list.
*/
WeakCleanableRef() {
super();
this.action = null;
}

@Override
protected void performCleanup() {
action.run();
}

/**
* Prevent access to referent even when it is still alive.
*
* @throws UnsupportedOperationException always
*/
@Override
public Object get() {
throw new UnsupportedOperationException("get");
}

/**
* Direct clearing of the referent is not supported.
*
* @throws UnsupportedOperationException always
*/
@Override
public void clear() {
throw new UnsupportedOperationException("clear");
}
}

/**
* Perform cleaning on an unreachable SoftReference.
*/
public static final class SoftCleanableRef extends SoftCleanable<Object> {
private final Runnable action;

/**
* Constructor for a soft cleanable reference.
* @param obj the object to monitor
* @param cleaner the cleaner
* @param action the action Runnable
*/
SoftCleanableRef(Object obj, Cleaner cleaner, Runnable action) {
super(obj, cleaner);
this.action = action;
}

/**
* Constructor used only for root of soft cleanable list.
*/
SoftCleanableRef() {
super();
this.action = null;
}

@Override
protected void performCleanup() {
action.run();
}

/**
* Prevent access to referent even when it is still alive.
*
* @throws UnsupportedOperationException always
*/
@Override
public Object get() {
throw new UnsupportedOperationException("get");
}

/**
* Direct clearing of the referent is not supported.
*
* @throws UnsupportedOperationException always
*/
@Override
public void clear() {
throw new UnsupportedOperationException("clear");
}

}

/**
* A ThreadFactory for InnocuousThreads.
* The factory is a singleton.
Expand Down
179 changes: 0 additions & 179 deletions src/java.base/share/classes/jdk/internal/ref/SoftCleanable.java

This file was deleted.

1 comment on commit ba24f96

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on ba24f96 Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.