< prev index next >

src/java.base/share/classes/java/lang/ref/Reference.java

Print this page

        

@@ -394,10 +394,14 @@
     Reference(T referent) {
         this(referent, null);
     }
 
     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;
     }
 
     /**
< prev index next >