Re: BCEL newbie question

Jacob Kjome <[email protected]> Sat, 03 Sep 2005 00:24:59 -0500
Newsgroups gmane.comp.jakarta.bcel.user
Message-ID <[email protected]>
Is there someone that can comment on this?  I'm sure I'm just missing 
something small.  But even though it is small, I'm still dead in the water 
until I get it figured out.

thanks,

Jake

At 09:59 AM 8/27/2005 -0500, you wrote:
 >
 >How do I get this...
 >
 >private void createMethod_11() {
 >         InstructionList il = new InstructionList();
 >         MethodGen method = new MethodGen(ACC_STATIC | ACC_FINAL,
 >Type.VOID, Type.NO_ARGS, new String[] {}, "<clinit>",
 >                 className, il, _cp);
 >         il.append(_factory.createFieldAccess(className, "class$L" +
 >className.replace('.', '$'), new ObjectType(
 >                 "java.lang.Class"), Constants.GETSTATIC));
 >         il.append(_factory.createFieldAccess(className,
 >"XMLC_GENERATED_CLASS",
 >                 new ObjectType("java.lang.Class"), Constants.PUTSTATIC));
 >         il.append(_factory.createFieldAccess(className,
 >
 >"class$Lorg$enhydra$xml$xmlc$dom$xerces$XercesHTMLDomFactory",
 >
 >new ObjectType("java.lang.Class"),
 >                 Constants.GETSTATIC));
 >
 >il.append(_factory.createInvoke("org.enhydra.xml.xmlc.dom.XMLCDomFactoryCache",
 >                 "getFactory", new
 >ObjectType("org.enhydra.xml.xmlc.dom.XMLCDomFactory"), new Type[] { new
 >ObjectType(
 >                         "java.lang.Class") }, Constants.INVOKESTATIC));
 >         il.append(_factory.createFieldAccess(className, "fDOMFactory", new
 >ObjectType(
 >                 "org.enhydra.xml.xmlc.dom.XMLCDomFactory"),
 >Constants.PUTSTATIC));
 >         il.append(InstructionFactory.createReturn(Type.VOID));
 >         method.setMaxStack();
 >         method.setMaxLocals();
 >         _cg.addMethod(method.getMethod());
 >         il.dispose();
 >     }
 >
 >to generate this...
 >
 >     static  {
 >         XMLC_GENERATED_CLASS = $$XMLC_GENERATED$$.dyna.dyna01.html.class;
 >         fDOMFactory =
 >XMLCDomFactoryCache.getFactory(org.enhydra.xml.xmlc.dom.xerces.XercesHTMLDom
 >Factory.class);
 >     }
 >
 >currently, it is generating this...
 >
 >     static final  {
 >         XMLC_GENERATED_CLASS = class$L$$XMLC_GENERATED$$$dyna$dyna01$html;
 >         fDOMFactory =
 >XMLCDomFactoryCache.getFactory(class$Lorg$enhydra$xml$xmlc$dom$xerces$Xerces
 >HTMLDomFactory);
 >     }
 >
 >
 >The class was originally generated by the BCELifier (by someone else on our
 >team) based on an example generated XMLC ( http://xmlc.objectweb.org/ )
 >class.  We tweaked it for our purposes, but the code in the block above
 >never really worked so we had it commented out (I also removed bits to
 >avoid generating code that didn't need to be generated and got it slimmed
 >down to the code you see above).  However, that means that some
 >functionality isn't available where it works just fine for the ASM2 version
 >(built with the ASMifier).  I would like the two to generate nearly
 >identical code and this is the last little bit that I need to get
 >working.  Can someone please point out the syntax needed to generate the
 >proper code (like the former, which is spit out by the ASM2 version) rather
 >than the improper code (like the latter, generated by the BCEL code above,
 >which is clearly incorrect, but I'm just not familiar enough with these
 >bytecode tools to know what the proper syntax is).
 >
 >thanks,
 >
 >
 >Jake
 >
 >
 >
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: [email protected]
 >For additional commands, e-mail: [email protected]
 >
 >
 >