Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





Java - Code Samples

 Sample 1. Code Sample / Example / Snippet of org.apache.bcel.classfile.EnclosingMethod

    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"));

}


   Like      Feedback      org.apache.bcel.classfile.EnclosingMethod



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner