test/jdk/java/lang/invoke/JavaDocExamplesTest.java
changeset 47856 76519338df34
parent 47216 71c04702a3d5
equal deleted inserted replaced
47855:72b6d674bde2 47856:76519338df34
   413 MethodHandle eq2 = equals.asSpreader(Object[].class, 2);
   413 MethodHandle eq2 = equals.asSpreader(Object[].class, 2);
   414 assert( (boolean) eq2.invokeExact(new Object[]{ "me", "me" }));
   414 assert( (boolean) eq2.invokeExact(new Object[]{ "me", "me" }));
   415 assert(!(boolean) eq2.invokeExact(new Object[]{ "me", "thee" }));
   415 assert(!(boolean) eq2.invokeExact(new Object[]{ "me", "thee" }));
   416 // try to spread from anything but a 2-array:
   416 // try to spread from anything but a 2-array:
   417 for (int n = 0; n <= 10; n++) {
   417 for (int n = 0; n <= 10; n++) {
   418   Object[] badArityArgs = (n == 2 ? null : new Object[n]);
   418   Object[] badArityArgs = (n == 2 ? new Object[0] : new Object[n]);
   419   try { assert((boolean) eq2.invokeExact(badArityArgs) && false); }
   419   try { assert((boolean) eq2.invokeExact(badArityArgs) && false); }
   420   catch (IllegalArgumentException ex) { } // OK
   420   catch (IllegalArgumentException ex) { } // OK
   421 }
   421 }
   422 // spread both arguments from a String array:
   422 // spread both arguments from a String array:
   423 MethodHandle eq2s = equals.asSpreader(String[].class, 2);
   423 MethodHandle eq2s = equals.asSpreader(String[].class, 2);