--- old/src/java.base/share/classes/java/lang/ref/PhantomReference.java 2019-05-23 15:39:18.441433248 -0400 +++ new/src/java.base/share/classes/java/lang/ref/PhantomReference.java 2019-05-23 15:39:18.045431284 -0400 @@ -30,6 +30,9 @@ * Phantom reference objects, which are enqueued after the collector * determines that their referents may otherwise be reclaimed. Phantom * references are most often used to schedule post-mortem cleanup actions. + *
+ * The referent must not be an instance of an inline class; such a value + * can never have another reference to it and cannot be held in a reference type. * *
Suppose the garbage collector determines at a certain point in time
* that an object is
@@ -72,6 +75,8 @@
* @param referent the object the new phantom reference will refer to
* @param q the queue with which the reference is to be registered,
* or {@code null} if registration is not required
+ * @throws IllegalArgumentException if the referent is an instance of an
+ * {@link Class#isInlineClass() inlineClass}
*/
public PhantomReference(T referent, ReferenceQueue super T> q) {
super(referent, q);
--- old/src/java.base/share/classes/java/lang/ref/Reference.java 2019-05-23 15:39:19.657439278 -0400
+++ new/src/java.base/share/classes/java/lang/ref/Reference.java 2019-05-23 15:39:19.257437294 -0400
@@ -396,6 +396,10 @@
}
Reference(T referent, ReferenceQueue super T> queue) {
+ if (referent != null && referent.getClass().isInlineClass()) {
+ throw new IllegalArgumentException("cannot reference an inline value of type: " +
+ referent.getClass().getName());
+ }
this.referent = referent;
this.queue = (queue == null) ? ReferenceQueue.NULL : queue;
}
--- old/src/java.base/share/classes/java/lang/ref/SoftReference.java 2019-05-23 15:39:20.833445109 -0400
+++ new/src/java.base/share/classes/java/lang/ref/SoftReference.java 2019-05-23 15:39:20.441443165 -0400
@@ -30,6 +30,9 @@
* Soft reference objects, which are cleared at the discretion of the garbage
* collector in response to memory demand. Soft references are most often used
* to implement memory-sensitive caches.
+ *
+ * The referent must not be an instance of an inline class; such a value
+ * can never have another reference to it and cannot be held in a reference type.
*
*