< prev index next > test/jdk/java/lang/runtime/ObjectMethodsTest.java
Print this page
assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, "toString", C.EQUALS_DESC, C.class, "x;y", C.ACCESSORS));
assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, "hashCode", C.TO_STRING_DESC, C.class, "x;y", C.ACCESSORS));
assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, "equals", C.HASHCODE_DESC, C.class, "x;y", C.ACCESSORS));
+ assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, "toString", methodType(String.class, this.getClass()), C.class, "x;y", C.ACCESSORS));
+ assertThrows(IAE, () -> ObjectMethods.bootstrap(LOOKUP, "toString", C.TO_STRING_DESC, C.class, "x;y",
+ new MethodHandle[]{
+ MethodHandles.lookup().findGetter(C.class, "x", int.class),
+ MethodHandles.lookup().findGetter(this.getClass(), "y", int.class),
+ }));
+
record NamePlusType(String mn, MethodType mt) {}
List<NamePlusType> namePlusTypeList = List.of(
new NamePlusType("toString", C.TO_STRING_DESC),
new NamePlusType("equals", C.EQUALS_DESC),
new NamePlusType("hashCode", C.HASHCODE_DESC)
assertThrows(NPE, () -> ObjectMethods.bootstrap(LOOKUP, null, npt.mt(), C.class, "x;y", C.ACCESSORS));
assertThrows(NPE, () -> ObjectMethods.bootstrap(null, npt.mn(), npt.mt(), C.class, "x;y", C.ACCESSORS));
}
}
+ // same field name and type as C::y
+ private int y;
+
// Based on the ObjectMethods internal implementation
private static int hashCombiner(int x, int y) {
return x*31 + y;
}
}
< prev index next >