Skip to content
Permalink
Browse files
8283415: Update java.lang.ref to use sealed classes
Reviewed-by: kbarrett, alanb
  • Loading branch information
jddarcy committed Mar 21, 2022
1 parent f4f8728 commit 14b9e80b8adcc0ab0634357f5a7c25f24fd6808c
Showing 5 changed files with 11 additions and 10 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, 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
@@ -28,7 +28,7 @@
/**
* Final references, used to implement finalization
*/
class FinalReference<T> extends Reference<T> {
sealed class FinalReference<T> extends Reference<T> permits Finalizer {

public FinalReference(T referent, ReferenceQueue<? super T> q) {
super(referent, q);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, 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
@@ -50,7 +50,7 @@
* @since 1.2
*/

public class PhantomReference<T> extends Reference<T> {
public non-sealed class PhantomReference<T> extends Reference<T> {

/**
* Returns this reference object's referent. Because the referent of a
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, 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
@@ -41,7 +41,8 @@
* @since 1.2
*/

public abstract class Reference<T> {
public abstract sealed class Reference<T>
permits PhantomReference, SoftReference, WeakReference, FinalReference {

/* The state of a Reference object is characterized by two attributes. It
* may be either "active", "pending", or "inactive". It may also be
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, 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
@@ -61,7 +61,7 @@
* @since 1.2
*/

public class SoftReference<T> extends Reference<T> {
public non-sealed class SoftReference<T> extends Reference<T> {

/**
* Timestamp clock, updated by the garbage collector
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, 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
@@ -45,7 +45,7 @@
* @since 1.2
*/

public class WeakReference<T> extends Reference<T> {
public non-sealed class WeakReference<T> extends Reference<T> {

/**
* Creates a new weak reference that refers to the given object. The new

1 comment on commit 14b9e80

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 14b9e80 Mar 21, 2022

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.