public void testCheckMethodLevelNamedInnerClass()
throws ClassNotFoundException
{
final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AttributeTestClassEM01$1S");
final ConstantPool pool = clazz.getConstantPool();
final Attribute[] encMethodAttrs = findAttribute("EnclosingMethod", clazz);
assertTrue("Expected 1 EnclosingMethod attribute but found "
+ encMethodAttrs.length, encMethodAttrs.length == 1);
final EnclosingMethod em = (EnclosingMethod) encMethodAttrs[0];
final String enclosingClassName = em.getEnclosingClass().getBytes(pool);
final String enclosingMethodName = em.getEnclosingMethod().getName(pool);
assertTrue(
"Expected class name to be '"+PACKAGE_BASE_SIG+"/data/AttributeTestClassEM01' but was "
+ enclosingClassName, enclosingClassName
.equals(PACKAGE_BASE_SIG+"/data/AttributeTestClassEM01"));
assertTrue("Expected method name to be 'main' but was "
+ enclosingMethodName, enclosingMethodName.equals("main"));
}
|