< prev index next >

test/jdk/java/lang/invoke/VarHandles/VarHandleBaseByteArrayTest.java

Print this page
rev 52786 : 8210031: implementation for JVM Constants API


 321                                      MemoryMode.ALIGNED, ne, MemoryMode.READ_WRITE);
 322         bavss.add(dbb_offset_aligned);
 323         ByteBufferReadOnlySource dbb_offset_aligned_ro =
 324                 new ByteBufferReadOnlySource(dbb_offset_aligned.s.asReadOnlyBuffer(), dbb_offset_aligned.s,
 325                                              MemoryMode.ALIGNED, ne, MemoryMode.READ_ONLY);
 326         bavss.add(dbb_offset_aligned_ro);
 327 
 328         ByteBufferSource dbb_offset_unaligned =
 329                 new ByteBufferSource(dbb.s.slice().position(array.length / 4 - 1).limit(array.length / 4 - 1 + array.length / 2).slice(),
 330                                      MemoryMode.UNALIGNED, ne, MemoryMode.READ_WRITE);
 331         bavss.add(dbb_offset_unaligned);
 332         ByteBufferReadOnlySource dbb_offset_unaligned_ro =
 333                 new ByteBufferReadOnlySource(dbb_offset_unaligned.s.asReadOnlyBuffer(), dbb_offset_unaligned.s,
 334                                              MemoryMode.UNALIGNED, ne, MemoryMode.READ_ONLY);
 335         bavss.add(dbb_offset_unaligned_ro);
 336     }
 337 
 338     @BeforeClass
 339     public void setup() {
 340         setupByteSources();
 341         setupVarHandleSources();
 342     }
 343 
 344     abstract void setupVarHandleSources();
 345 
 346 
 347     @DataProvider
 348     public Object[][] varHandlesProvider() throws Exception {
 349         return vhss.stream().map(cvh -> new Object[]{cvh}).toArray(Object[][]::new);
 350     }
 351 
 352     @DataProvider
 353     public Object[][] typesProvider() throws Exception {
 354         List<java.lang.Class<?>> aepts = Arrays.asList(byte[].class, int.class);
 355         List<java.lang.Class<?>> bbpts = Arrays.asList(ByteBuffer.class, int.class);
 356 
 357         Function<VarHandle, List<Class<?>>> vhToPts = vh ->
 358                 vh.coordinateTypes().get(0) == byte[].class ? aepts : bbpts;
 359 
 360         return vhss.stream().map(vh -> new Object[]{vh.s, vhToPts.apply(vh.s)}).toArray(Object[][]::new);
 361     }
 362 }


 321                                      MemoryMode.ALIGNED, ne, MemoryMode.READ_WRITE);
 322         bavss.add(dbb_offset_aligned);
 323         ByteBufferReadOnlySource dbb_offset_aligned_ro =
 324                 new ByteBufferReadOnlySource(dbb_offset_aligned.s.asReadOnlyBuffer(), dbb_offset_aligned.s,
 325                                              MemoryMode.ALIGNED, ne, MemoryMode.READ_ONLY);
 326         bavss.add(dbb_offset_aligned_ro);
 327 
 328         ByteBufferSource dbb_offset_unaligned =
 329                 new ByteBufferSource(dbb.s.slice().position(array.length / 4 - 1).limit(array.length / 4 - 1 + array.length / 2).slice(),
 330                                      MemoryMode.UNALIGNED, ne, MemoryMode.READ_WRITE);
 331         bavss.add(dbb_offset_unaligned);
 332         ByteBufferReadOnlySource dbb_offset_unaligned_ro =
 333                 new ByteBufferReadOnlySource(dbb_offset_unaligned.s.asReadOnlyBuffer(), dbb_offset_unaligned.s,
 334                                              MemoryMode.UNALIGNED, ne, MemoryMode.READ_ONLY);
 335         bavss.add(dbb_offset_unaligned_ro);
 336     }
 337 
 338     @BeforeClass
 339     public void setup() {
 340         setupByteSources();
 341         vhss = setupVarHandleSources(true);
 342     }
 343 
 344     abstract List<VarHandleSource> setupVarHandleSources(boolean same);
 345 
 346 
 347     @DataProvider
 348     public Object[][] varHandlesProvider() throws Exception {
 349         return vhss.stream().map(cvh -> new Object[]{cvh}).toArray(Object[][]::new);
 350     }
 351 
 352     @DataProvider
 353     public Object[][] typesProvider() throws Exception {
 354         List<java.lang.Class<?>> aepts = Arrays.asList(byte[].class, int.class);
 355         List<java.lang.Class<?>> bbpts = Arrays.asList(ByteBuffer.class, int.class);
 356 
 357         Function<VarHandle, List<Class<?>>> vhToPts = vh ->
 358                 vh.coordinateTypes().get(0) == byte[].class ? aepts : bbpts;
 359 
 360         return vhss.stream().map(vh -> new Object[]{vh.s, vhToPts.apply(vh.s)}).toArray(Object[][]::new);
 361     }
 362 }
< prev index next >