< prev index next >

test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java

Print this page

 237     public void getSuperclassTest() {
 238         for (Class<?> c : classes) {
 239             ResolvedJavaType type = metaAccess.lookupJavaType(c);
 240             Class<?> expected = c.getSuperclass();
 241             ResolvedJavaType actual = type.getSuperclass();
 242             if (expected == null) {
 243                 assertTrue(actual == null);
 244             } else {
 245                 assertNotNull(actual);
 246                 assertTrue(actual.equals(metaAccess.lookupJavaType(expected)));
 247             }
 248         }
 249     }
 250 
 251     @Test
 252     public void getInterfacesTest() {
 253         for (Class<?> c : classes) {
 254             ResolvedJavaType type = metaAccess.lookupJavaType(c);
 255             Class<?>[] expected = c.getInterfaces();
 256             ResolvedJavaType[] actual = type.getInterfaces();
 257             assertEquals(expected.length, actual.length);


 258             for (int i = 0; i < expected.length; i++) {
 259                 assertTrue(actual[i].equals(metaAccess.lookupJavaType(expected[i])));
 260             }
 261         }
 262     }
 263 
 264     public Class<?> getSupertype(Class<?> c) {
 265         assert !c.isPrimitive();
 266         if (c.isArray()) {
 267             Class<?> componentType = c.getComponentType();
 268             if (componentType.isPrimitive() || componentType == Object.class) {
 269                 return Object.class;
 270             }
 271             return getArrayClass(getSupertype(componentType));
 272         }
 273         if (c.isInterface()) {
 274             return Object.class;
 275         }
 276         return c.getSuperclass();
 277     }

 237     public void getSuperclassTest() {
 238         for (Class<?> c : classes) {
 239             ResolvedJavaType type = metaAccess.lookupJavaType(c);
 240             Class<?> expected = c.getSuperclass();
 241             ResolvedJavaType actual = type.getSuperclass();
 242             if (expected == null) {
 243                 assertTrue(actual == null);
 244             } else {
 245                 assertNotNull(actual);
 246                 assertTrue(actual.equals(metaAccess.lookupJavaType(expected)));
 247             }
 248         }
 249     }
 250 
 251     @Test
 252     public void getInterfacesTest() {
 253         for (Class<?> c : classes) {
 254             ResolvedJavaType type = metaAccess.lookupJavaType(c);
 255             Class<?>[] expected = c.getInterfaces();
 256             ResolvedJavaType[] actual = type.getInterfaces();
 257             // With injection of the IdentityObject interface by the JVM, the number of
 258             // interfaces visible through reflection and through JVMCI could differ by one
 259             assertTrue(expected.length == actual.length || (actual.length - expected.length) == 1);
 260             for (int i = 0; i < expected.length; i++) {
 261                 assertTrue(actual[i].equals(metaAccess.lookupJavaType(expected[i])));
 262             }
 263         }
 264     }
 265 
 266     public Class<?> getSupertype(Class<?> c) {
 267         assert !c.isPrimitive();
 268         if (c.isArray()) {
 269             Class<?> componentType = c.getComponentType();
 270             if (componentType.isPrimitive() || componentType == Object.class) {
 271                 return Object.class;
 272             }
 273             return getArrayClass(getSupertype(componentType));
 274         }
 275         if (c.isInterface()) {
 276             return Object.class;
 277         }
 278         return c.getSuperclass();
 279     }
< prev index next >