Dave Brosius <dbrosius <at> apache.org> writes:
> 
> Often times questions like, "How i do this?" can be most easily answered by 
> BCELifier, a tool bundled with the distribution that given a java class, 
> writes a BCEL program to generate that class.
>

Thansk for the suggestion, but using BCELified din't help me a lot. I've created
this class

public class Bcelify {

        public static void main(String[] args) {
                
                try {
                        JavaClass jclass = new 
ClassParser("Bcelify.class").parse();
                        BCELifier b = new BCELifier(jclass, System.out);
                        b.start();
                        Class c = int.class;
                        System.out.println(c);
                }
                catch(Exception e) {
                        System.out.println(e.getMessage());
                }               
        }
}

The instuction I'm interested in is: 
int.class; 
that in the resultin code is generated with 
factory.createFieldAccess("java.lang.Integer", "TYPE", new
ObjectType("java.lang.Class"), Constants.GETSTATIC);

and this is ok. The problem is that if instead of a primitive I use a class name
writing something like String.class I have an "Unknown or invalid constant type
at 42" error. Watching the bytecode the classobject is obtained by a ldc_w
instruction but I don't know how to create it in BCEL casue I've no idea of what
argument I have to pass it.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to