< prev index next >

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

Print this page




 310 
 311     static class Concrete3 extends Concrete2 {
 312     }
 313 
 314     static final class Final1 extends Abstract1 {
 315     }
 316 
 317     abstract static class Abstract4 extends Concrete3 {
 318     }
 319 
 320     void checkConcreteSubtype(ResolvedJavaType type, ResolvedJavaType expected) {
 321         AssumptionResult<ResolvedJavaType> leafConcreteSubtype = type.findLeafConcreteSubtype();
 322         if (leafConcreteSubtype == null) {
 323             // findLeafConcreteSubtype() is conservative
 324         } else {
 325             if (expected == null) {
 326                 assertNull(leafConcreteSubtype);
 327             } else {
 328                 assertTrue(leafConcreteSubtype.getResult().equals(expected));
 329             }

 330         }
 331 
 332         if (!type.isArray()) {
 333             ResolvedJavaType arrayType = type.getArrayClass();
 334             AssumptionResult<ResolvedJavaType> arraySubtype = arrayType.findLeafConcreteSubtype();
 335             if (arraySubtype != null) {
 336                 assertEquals(arraySubtype.getResult(), arrayType);
 337             } else {
 338                 // findLeafConcreteSubtype() method is conservative
 339             }
 340         }
 341     }
 342 
 343     @Test
 344     public void findLeafConcreteSubtypeTest() {
 345         ResolvedJavaType base = metaAccess.lookupJavaType(Base.class);
 346         checkConcreteSubtype(base, base);
 347 
 348         ResolvedJavaType a1 = metaAccess.lookupJavaType(Abstract1.class);
 349         ResolvedJavaType c1 = metaAccess.lookupJavaType(Concrete1.class);


 354 
 355         ResolvedJavaType i1 = metaAccess.lookupJavaType(Interface1.class);
 356         ResolvedJavaType c2 = metaAccess.lookupJavaType(Concrete2.class);
 357 
 358         checkConcreteSubtype(base, null);
 359         checkConcreteSubtype(a1, null);
 360         checkConcreteSubtype(c1, c1);
 361         checkConcreteSubtype(i1, c2);
 362         checkConcreteSubtype(c2, c2);
 363 
 364         ResolvedJavaType c3 = metaAccess.lookupJavaType(Concrete3.class);
 365         checkConcreteSubtype(c2, null);
 366         checkConcreteSubtype(c3, c3);
 367 
 368         ResolvedJavaType a4 = metaAccess.lookupJavaType(Abstract4.class);
 369         checkConcreteSubtype(c3, null);
 370         checkConcreteSubtype(a4, null);
 371 
 372         ResolvedJavaType a1a = metaAccess.lookupJavaType(Abstract1[].class);
 373         checkConcreteSubtype(a1a, null);


 374         ResolvedJavaType c1a = metaAccess.lookupJavaType(Concrete1[].class);
 375         checkConcreteSubtype(c1a, null);
 376         ResolvedJavaType f1a = metaAccess.lookupJavaType(Final1[].class);
 377         checkConcreteSubtype(f1a, f1a);
 378 
 379         ResolvedJavaType obja = metaAccess.lookupJavaType(Object[].class);
 380         checkConcreteSubtype(obja, null);
 381 
 382         ResolvedJavaType inta = metaAccess.lookupJavaType(int[].class);
 383         checkConcreteSubtype(inta, inta);
 384     }
 385 
 386     interface NoImplementor {
 387     }
 388 
 389     interface SingleImplementorInterface {
 390     }
 391 
 392     static class SingleConcreteImplementor implements SingleImplementorInterface {
 393     }
 394 
 395     interface SingleAbstractImplementorInterface {




 310 
 311     static class Concrete3 extends Concrete2 {
 312     }
 313 
 314     static final class Final1 extends Abstract1 {
 315     }
 316 
 317     abstract static class Abstract4 extends Concrete3 {
 318     }
 319 
 320     void checkConcreteSubtype(ResolvedJavaType type, ResolvedJavaType expected) {
 321         AssumptionResult<ResolvedJavaType> leafConcreteSubtype = type.findLeafConcreteSubtype();
 322         if (leafConcreteSubtype == null) {
 323             // findLeafConcreteSubtype() is conservative
 324         } else {
 325             if (expected == null) {
 326                 assertNull(leafConcreteSubtype);
 327             } else {
 328                 assertTrue(leafConcreteSubtype.getResult().equals(expected));
 329             }
 330             assertTrue(!type.isLeaf() || leafConcreteSubtype.isAssumptionFree());
 331         }
 332 
 333         if (!type.isArray()) {
 334             ResolvedJavaType arrayType = type.getArrayClass();
 335             AssumptionResult<ResolvedJavaType> arraySubtype = arrayType.findLeafConcreteSubtype();
 336             if (arraySubtype != null) {
 337                 assertEquals(arraySubtype.getResult(), arrayType);
 338             } else {
 339                 // findLeafConcreteSubtype() method is conservative
 340             }
 341         }
 342     }
 343 
 344     @Test
 345     public void findLeafConcreteSubtypeTest() {
 346         ResolvedJavaType base = metaAccess.lookupJavaType(Base.class);
 347         checkConcreteSubtype(base, base);
 348 
 349         ResolvedJavaType a1 = metaAccess.lookupJavaType(Abstract1.class);
 350         ResolvedJavaType c1 = metaAccess.lookupJavaType(Concrete1.class);


 355 
 356         ResolvedJavaType i1 = metaAccess.lookupJavaType(Interface1.class);
 357         ResolvedJavaType c2 = metaAccess.lookupJavaType(Concrete2.class);
 358 
 359         checkConcreteSubtype(base, null);
 360         checkConcreteSubtype(a1, null);
 361         checkConcreteSubtype(c1, c1);
 362         checkConcreteSubtype(i1, c2);
 363         checkConcreteSubtype(c2, c2);
 364 
 365         ResolvedJavaType c3 = metaAccess.lookupJavaType(Concrete3.class);
 366         checkConcreteSubtype(c2, null);
 367         checkConcreteSubtype(c3, c3);
 368 
 369         ResolvedJavaType a4 = metaAccess.lookupJavaType(Abstract4.class);
 370         checkConcreteSubtype(c3, null);
 371         checkConcreteSubtype(a4, null);
 372 
 373         ResolvedJavaType a1a = metaAccess.lookupJavaType(Abstract1[].class);
 374         checkConcreteSubtype(a1a, null);
 375         ResolvedJavaType i1a = metaAccess.lookupJavaType(Interface1[].class);
 376         checkConcreteSubtype(i1a, null);
 377         ResolvedJavaType c1a = metaAccess.lookupJavaType(Concrete1[].class);
 378         checkConcreteSubtype(c1a, c1a);
 379         ResolvedJavaType f1a = metaAccess.lookupJavaType(Final1[].class);
 380         checkConcreteSubtype(f1a, f1a);
 381 
 382         ResolvedJavaType obja = metaAccess.lookupJavaType(Object[].class);
 383         checkConcreteSubtype(obja, null);
 384 
 385         ResolvedJavaType inta = metaAccess.lookupJavaType(int[].class);
 386         checkConcreteSubtype(inta, inta);
 387     }
 388 
 389     interface NoImplementor {
 390     }
 391 
 392     interface SingleImplementorInterface {
 393     }
 394 
 395     static class SingleConcreteImplementor implements SingleImplementorInterface {
 396     }
 397 
 398     interface SingleAbstractImplementorInterface {


< prev index next >