-
Enhancement
-
Resolution: Fixed
-
P3
-
None
Supposing a value class with itself as a field.
value class Node {
Node node;
}
var n1 = new Node(null);
var n2 = new Node(n1);
n1 == n2;
Results in StackOverFlowError trying to create/find a methodHandle to perform `equals`.
| at PrimitiveObjectMethods.substitutableInvoker (PrimitiveObjectMethods.java:420)
| at PrimitiveObjectMethods$MethodHandleBuilder.primitiveTypeEquals (PrimitiveObjectMethods.java:131)
| at PrimitiveObjectMethods$1.computeValue (PrimitiveObjectMethods.java:428)
| at PrimitiveObjectMethods$1.computeValue (PrimitiveObjectMethods.java:426)
| at ClassValue.getFromHashMap (ClassValue.java:229)
| at ClassValue.getFromBackup (ClassValue.java:211)
| at ClassValue.get (ClassValue.java:117)
If embedding were intended, this would be clearly illegal and should result in a compile time error; but in this case the field is a reference to a Node.
value class Node {
Node node;
}
var n1 = new Node(null);
var n2 = new Node(n1);
n1 == n2;
Results in StackOverFlowError trying to create/find a methodHandle to perform `equals`.
| at PrimitiveObjectMethods.substitutableInvoker (PrimitiveObjectMethods.java:420)
| at PrimitiveObjectMethods$MethodHandleBuilder.primitiveTypeEquals (PrimitiveObjectMethods.java:131)
| at PrimitiveObjectMethods$1.computeValue (PrimitiveObjectMethods.java:428)
| at PrimitiveObjectMethods$1.computeValue (PrimitiveObjectMethods.java:426)
| at ClassValue.getFromHashMap (ClassValue.java:229)
| at ClassValue.getFromBackup (ClassValue.java:211)
| at ClassValue.get (ClassValue.java:117)
If embedding were intended, this would be clearly illegal and should result in a compile time error; but in this case the field is a reference to a Node.
- relates to
-
JDK-8296186 [lworld] explore acmp algorithm to determine two object graphs are "equivalance"
-
- Open
-
-
JDK-8296056 [lworld] acmp should support value class with cyclic membership
-
- Closed
-