< prev index next >

test/jdk/java/lang/constant/CondyDescTest.java

Print this page
rev 53074 : 8215648: remove equals and hashCode implementations from j.l.i.VarHandle


  50 import static org.testng.Assert.assertTrue;
  51 
  52 /**
  53  * @test
  54  * @compile CondyDescTest.java
  55  * @run testng CondyDescTest
  56  * @summary unit tests for java.lang.constant.CondyDescTest
  57  */
  58 @Test
  59 public class CondyDescTest extends SymbolicDescTest {
  60     private final static ConstantDesc[] EMPTY_ARGS = new ConstantDesc[0];
  61     private final static ClassDesc CD_ConstantBootstraps = ClassDesc.of("java.lang.invoke.ConstantBootstraps");
  62 
  63     private static<T> void testDCR(DynamicConstantDesc<T> r, T c) throws ReflectiveOperationException {
  64         assertEquals(r, DynamicConstantDesc.ofNamed(r.bootstrapMethod(), r.constantName(), r.constantType(), r.bootstrapArgs()));
  65         assertEquals(r.resolveConstantDesc(LOOKUP), c);
  66     }
  67 
  68     private void testVarHandleDesc(DynamicConstantDesc<VarHandle> r, VarHandle vh) throws ReflectiveOperationException  {
  69         testSymbolicDesc(r);
  70         assertEquals(r.resolveConstantDesc(LOOKUP), vh);
  71         assertEquals(vh.describeConstable().orElseThrow(), r);
  72     }
  73 
  74     private static<E extends Enum<E>> void testEnumDesc(EnumDesc<E> r, E e) throws ReflectiveOperationException {
  75         testSymbolicDesc(r);
  76 
  77         assertEquals(r, EnumDesc.of(r.constantType(), r.constantName()));
  78         assertEquals(r.resolveConstantDesc(LOOKUP), e);
  79     }
  80 
  81     public void testNullConstant() throws ReflectiveOperationException {
  82         DynamicConstantDesc<?> r = (DynamicConstantDesc<?>) ConstantDescs.NULL;
  83         assertEquals(r, DynamicConstantDesc.ofNamed(r.bootstrapMethod(), r.constantName(), r.constantType(), r.bootstrapArgs()));
  84         assertNull(r.resolveConstantDesc(LOOKUP));
  85     }
  86 
  87     static String concatBSM(MethodHandles.Lookup lookup, String name, Class<?> type, String a, String b) {
  88         return a + b;
  89     }
  90 




  50 import static org.testng.Assert.assertTrue;
  51 
  52 /**
  53  * @test
  54  * @compile CondyDescTest.java
  55  * @run testng CondyDescTest
  56  * @summary unit tests for java.lang.constant.CondyDescTest
  57  */
  58 @Test
  59 public class CondyDescTest extends SymbolicDescTest {
  60     private final static ConstantDesc[] EMPTY_ARGS = new ConstantDesc[0];
  61     private final static ClassDesc CD_ConstantBootstraps = ClassDesc.of("java.lang.invoke.ConstantBootstraps");
  62 
  63     private static<T> void testDCR(DynamicConstantDesc<T> r, T c) throws ReflectiveOperationException {
  64         assertEquals(r, DynamicConstantDesc.ofNamed(r.bootstrapMethod(), r.constantName(), r.constantType(), r.bootstrapArgs()));
  65         assertEquals(r.resolveConstantDesc(LOOKUP), c);
  66     }
  67 
  68     private void testVarHandleDesc(DynamicConstantDesc<VarHandle> r, VarHandle vh) throws ReflectiveOperationException  {
  69         testSymbolicDesc(r);

  70         assertEquals(vh.describeConstable().orElseThrow(), r);
  71     }
  72 
  73     private static<E extends Enum<E>> void testEnumDesc(EnumDesc<E> r, E e) throws ReflectiveOperationException {
  74         testSymbolicDesc(r);
  75 
  76         assertEquals(r, EnumDesc.of(r.constantType(), r.constantName()));
  77         assertEquals(r.resolveConstantDesc(LOOKUP), e);
  78     }
  79 
  80     public void testNullConstant() throws ReflectiveOperationException {
  81         DynamicConstantDesc<?> r = (DynamicConstantDesc<?>) ConstantDescs.NULL;
  82         assertEquals(r, DynamicConstantDesc.ofNamed(r.bootstrapMethod(), r.constantName(), r.constantType(), r.bootstrapArgs()));
  83         assertNull(r.resolveConstantDesc(LOOKUP));
  84     }
  85 
  86     static String concatBSM(MethodHandles.Lookup lookup, String name, Class<?> type, String a, String b) {
  87         return a + b;
  88     }
  89 


< prev index next >