changeset 51359:d5c59fab1bdb

8202922: Method reference identity is broken by serialization Reviewed-by: jlaskey, mchung
author psandoz
date Fri, 22 Jun 2018 12:05:36 -0700
parents 2826fcb2683f
children d7cf64ce3950
files src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java src/java.base/share/classes/java/lang/invoke/SerializedLambda.java
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java	Fri Jun 22 19:04:16 2018 +0200
+++ b/src/java.base/share/classes/java/lang/invoke/LambdaMetafactory.java	Fri Jun 22 12:05:36 2018 -0700
@@ -61,7 +61,13 @@
  *     parameters</em>, which must be provided as arguments to the
  *     {@code CallSite} target, and which may be early-bound to the behavior
  *     {@code MethodHandle}.  The number of captured parameters and their types
- *     are determined during linkage.</li>
+ *     are determined during linkage.
+ *     The identity of a function object produced by invoking the
+ *     {@code CallSite}'s target is unpredictable, and therefore
+ *     identity-sensitive operations (such as reference equality, object
+ *     locking, and {@code System.identityHashCode()} may produce different
+ *     results in different implementations, or even upon different invocations
+ *     in the same implementation.</li>
  *
  *     <li><em>Invocation</em> occurs when an implemented interface method
  *     is invoked on a function object.  This may occur many times for a single
--- a/src/java.base/share/classes/java/lang/invoke/SerializedLambda.java	Fri Jun 22 19:04:16 2018 +0200
+++ b/src/java.base/share/classes/java/lang/invoke/SerializedLambda.java	Fri Jun 22 12:05:36 2018 -0700
@@ -53,6 +53,12 @@
  * that the properties of the {@code SerializedLambda} are consistent with a
  * lambda actually captured by that class.
  *
+ * <p>The identity of a function object produced by deserializing the serialized
+ * form is unpredictable, and therefore identity-sensitive operations (such as
+ * reference equality, object locking, and {@code System.identityHashCode()} may
+ * produce different results in different implementations, or even upon
+ * different deserializations in the same implementation.
+ *
  * @see LambdaMetafactory
  * @since 1.8
  */