mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8283415: Update java.lang.ref to use sealed classes
Reviewed-by: kbarrett, alanb
This commit is contained in:
parent
f4f87284cb
commit
14b9e80b8a
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 @@ package java.lang.ref;
|
|||
/**
|
||||
* 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 @@ import jdk.internal.vm.annotation.IntrinsicCandidate;
|
|||
* @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 @@ import jdk.internal.ref.Cleaner;
|
|||
* @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 @@ package java.lang.ref;
|
|||
* @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 @@ package java.lang.ref;
|
|||
* @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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue