< prev index next >

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

Print this page




 412 
 413     @Test
 414     public void isJavaLangObjectInitTest() throws NoSuchMethodException {
 415         ResolvedJavaMethod method = metaAccess.lookupJavaMethod(Object.class.getConstructor());
 416         assertTrue(method.isJavaLangObjectInit());
 417         for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) {
 418             ResolvedJavaMethod m = e.getValue();
 419             assertFalse(m.isJavaLangObjectInit());
 420         }
 421         for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) {
 422             ResolvedJavaMethod m = e.getValue();
 423             Constructor<?> key = e.getKey();
 424             if (key.getDeclaringClass() == Object.class && key.getParameters().length == 0) {
 425                 assertTrue(m.isJavaLangObjectInit());
 426             } else {
 427                 assertFalse(m.isJavaLangObjectInit());
 428             }
 429         }
 430     }
 431 



 432     /**
 433      * All public non-final methods should be available in the vtable.
 434      */
 435     @Test
 436     public void testVirtualMethodTableAccess() {










 437         for (Class<?> c : classes) {
 438             if (c.isPrimitive() || c.isInterface()) {
 439                 continue;
 440             }
 441             ResolvedJavaType receiverType = metaAccess.lookupJavaType(c);
 442             for (Method m : c.getMethods()) {
 443                 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
 444                 if (!method.isStatic() && !method.isFinal() && !method.getDeclaringClass().isLeaf() && !method.getDeclaringClass().isInterface()) {
 445                     assertTrue(method + " not available in " + receiverType, method.isInVirtualMethodTable(receiverType));
 446                 }
 447             }
 448         }
 449     }
 450 
 451     private Method findTestMethod(Method apiMethod) {
 452         String testName = apiMethod.getName() + "Test";
 453         for (Method m : getClass().getDeclaredMethods()) {
 454             if (m.getName().equals(testName) && m.getAnnotation(Test.class) != null) {
 455                 return m;
 456             }




 412 
 413     @Test
 414     public void isJavaLangObjectInitTest() throws NoSuchMethodException {
 415         ResolvedJavaMethod method = metaAccess.lookupJavaMethod(Object.class.getConstructor());
 416         assertTrue(method.isJavaLangObjectInit());
 417         for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) {
 418             ResolvedJavaMethod m = e.getValue();
 419             assertFalse(m.isJavaLangObjectInit());
 420         }
 421         for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) {
 422             ResolvedJavaMethod m = e.getValue();
 423             Constructor<?> key = e.getKey();
 424             if (key.getDeclaringClass() == Object.class && key.getParameters().length == 0) {
 425                 assertTrue(m.isJavaLangObjectInit());
 426             } else {
 427                 assertFalse(m.isJavaLangObjectInit());
 428             }
 429         }
 430     }
 431 
 432     static class UnlinkedType {
 433     }
 434 
 435     /**
 436      * All public non-final methods should be available in the vtable.
 437      */
 438     @Test
 439     public void testVirtualMethodTableAccess() {
 440         ResolvedJavaType unlinkedType = metaAccess.lookupJavaType(UnlinkedType.class);
 441         assertTrue(!unlinkedType.isLinked());
 442         for (Class<?> c : classes) {
 443             if (c.isInterface()) {
 444                 for (Method m : c.getDeclaredMethods()) {
 445                     ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
 446                     method.isInVirtualMethodTable(unlinkedType);
 447                 }
 448             }
 449         }
 450         for (Class<?> c : classes) {
 451             if (c.isPrimitive() || c.isInterface()) {
 452                 continue;
 453             }
 454             ResolvedJavaType receiverType = metaAccess.lookupJavaType(c);
 455             for (Method m : c.getMethods()) {
 456                 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
 457                 if (!method.isStatic() && !method.isFinal() && !method.getDeclaringClass().isLeaf() && !method.getDeclaringClass().isInterface()) {
 458                     assertTrue(method + " not available in " + receiverType, method.isInVirtualMethodTable(receiverType));
 459                 }
 460             }
 461         }
 462     }
 463 
 464     private Method findTestMethod(Method apiMethod) {
 465         String testName = apiMethod.getName() + "Test";
 466         for (Method m : getClass().getDeclaredMethods()) {
 467             if (m.getName().equals(testName) && m.getAnnotation(Test.class) != null) {
 468                 return m;
 469             }


< prev index next >