#Java - Code Snippets for '#.ConstantPool' - 2 code snippet(s) found |
|
Sample 1. Code Sample / Example / Snippet of org.apache.bcel.generic.ConstantPoolGen | |
|
public void testCreateIntegerElementValue() throws Exception
{
final ClassGen cg = createClassGen("HelloWorld");
final ConstantPoolGen cp = cg.getConstantPool();
final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 555);
assertTrue("Should have the same index in the constantpool but "
+ evg.getIndex() + "!=" + cp.lookupInteger(555),
evg.getIndex() == cp.lookupInteger(555));
checkSerialize(evg, cp);
}
|
|
Like Feedback org.apache.bcel.generic.ConstantPoolGen |
|
|
Sample 2. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantPool | |
|
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.ConstantPool |
|
|