changeset 53722:7367af6ffbe1 jep-334

adding enum resolution tests
author vromero
date Fri, 30 Nov 2018 12:43:55 -0500
parents e037cb7d27c4
children 04263eef3435 042318016a99 c76365f9e61f 9da7233f3060
files test/jdk/java/lang/constant/CondyDescTest.java
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/java/lang/constant/CondyDescTest.java	Fri Nov 30 12:02:30 2018 -0500
+++ b/test/jdk/java/lang/constant/CondyDescTest.java	Fri Nov 30 12:43:55 2018 -0500
@@ -216,7 +216,7 @@
                      DynamicConstantDesc.ofCanonical(ConstantDescs.BSM_VARHANDLE_ARRAY, "_", CD_VarHandle, new ConstantDesc[] {CD_int.arrayType() }));
     }
 
-    public void testResolvingVarHandle() throws ReflectiveOperationException {
+    public void testConstantResolution() throws ReflectiveOperationException {
         ClassDesc testClass = ClassDesc.of("CondyDescTest").inner("MyClass");
         MyClass myClass = new MyClass();
 
@@ -244,6 +244,13 @@
         vhd = (VarHandleDesc)DynamicConstantDesc.ofCanonical(ConstantDescs.BSM_VARHANDLE_ARRAY, "_", CD_VarHandle, new ConstantDesc[] {CD_int.arrayType() });
         vh = vhd.resolveConstantDesc(LOOKUP);
         assertEquals(100, vh.get(intArr, 0));
+
+        ClassDesc enumClass = ClassDesc.of("CondyDescTest").inner("MyEnum");
+        DynamicConstantDesc<MyEnum> denum = DynamicConstantDesc.ofNamed(ConstantDescs.BSM_ENUM_CONSTANT, "A", enumClass, EMPTY_ARGS);
+        assertEquals(MyEnum.A, denum.resolveConstantDesc(LOOKUP));
+
+        EnumDesc<MyEnum> enumDesc = (EnumDesc<MyEnum>)DynamicConstantDesc.<MyEnum>ofCanonical(ConstantDescs.BSM_ENUM_CONSTANT, "A", enumClass, EMPTY_ARGS);
+        assertEquals(MyEnum.A, enumDesc.resolveConstantDesc(LOOKUP));
     }
 
 }