< prev index next >

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

Print this page

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


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

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