< prev index next >
test/jdk/valhalla/valuetypes/ObjectMethods.java
Print this page
rev 55127 : 8223351: [lworld] Primary mirror and nullable mirror for inline type
Reviewed-by: tbd
@@ -31,11 +31,10 @@
*/
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.List;
-import java.util.Objects;
import java.util.stream.Stream;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -139,27 +138,27 @@
.setPoint(Point.makePoint(200, 200))
.setNumber(Value.Number.intValue(10))
.setReference(new Object()).build();
// this is sensitive to the order of the returned fields from Class::getDeclaredFields
return new Object[][]{
- { P1, hash(Point.class.asValueType(), 1, 2) },
- { LINE1, hash(Line.class.asValueType(), Point.makePoint(1, 2), Point.makePoint(3, 4)) },
+ { P1, hash(Point.class, 1, 2) },
+ { LINE1, hash(Line.class, Point.makePoint(1, 2), Point.makePoint(3, 4)) },
{ v, hash(hashCodeComponents(v))},
- { Point.makePoint(0,0), hash(Point.class.asValueType(), 0, 0) },
- { Point.default, hash(Point.class.asValueType(), 0, 0) },
- { MyValue1.default, hash(MyValue1.class.asValueType(), Point.default, null) },
- { MyValue1.make(0,0, null), hash(MyValue1.class.asValueType(), Point.makePoint(0,0), null) },
+ { Point.makePoint(0,0), hash(Point.class, 0, 0) },
+ { Point.default, hash(Point.class, 0, 0) },
+ { MyValue1.default, hash(MyValue1.class, Point.default, null) },
+ { MyValue1.make(0,0, null), hash(MyValue1.class, Point.makePoint(0,0), null) },
};
}
@Test(dataProvider="hashcodeTests")
public void testHashCode(Object o, int hash) {
assertEquals(o.hashCode(), hash);
}
private static Object[] hashCodeComponents(Object o) {
- Class<?> type = o.getClass().asValueType();
+ Class<?> type = o.getClass();
// filter static fields and synthetic fields
Stream<Object> fields = Arrays.stream(type.getDeclaredFields())
.filter(f -> !Modifier.isStatic(f.getModifiers()) && !f.isSynthetic())
.map(f -> {
try {
@@ -179,11 +178,11 @@
return hc;
}
static inline class MyValue1 {
Point p = Point.default;
- Point? box = Point.default;
+ Point? box = null;
static MyValue1 make(int x, int y, Point? box) {
MyValue1 v = MyValue1.default;
v = __WithField(v.p, Point.makePoint(x, y));
v = __WithField(v.box, box);
< prev index next >