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.generic.EnumElementValueGen

    public void testCreateEnumElementValue() throws Exception


final ClassGen cg = createClassGen("HelloWorld");

final ConstantPoolGen cp = cg.getConstantPool();

final ObjectType enumType = new ObjectType("SimpleEnum"); // Supports rainbow

final EnumElementValueGen evg = new EnumElementValueGen(enumType, "Red", cp);


"The new ElementValue value index should match the contents of the constantpool but "

+ evg.getValueIndex() + "!=" + cp.lookupUtf8("Red"),

evg.getValueIndex() == cp.lookupUtf8("Red"));

checkSerialize(evg, cp);


   Like      Feedback      org.apache.bcel.generic.EnumElementValueGen

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

comments powered by Disqus