This discussion is archived
10 Replies Latest reply: Jun 9, 2011 11:47 AM by jschellSomeoneStoleMyAlias RSS

Can we push a Custom Type Object on Stack in BCEL?

859992 Newbie
Currently Being Moderated
Hi All,

I know how to push Primitive Types on Stack IN BCEL using
InstructinoList.append(new PUSH(ConstantPoolGen,343));

Now i want to push Custom Type Object(Obj of some user defined class i.e EngineClass obj) on Stack in BCEL.


Let me explain some context of my problem What i want to do is i have a class

class Automobile {

public void getEngine(int carNo,EngineClass engineClassObj){

System.out.println("EngineNo="+engineClassObj.sisNo);
}
}

Now when i load "Automobile" class in memory.

ilist = new InstructionList();
ilist.append(InstructionConstants.ALOAD_0);
ilist.append(new PUSH(pgen,345));

////Hear Now i have to also push the Object on Stack

ilist.append(ifact.createInvoke(_invoking_ClassName,_invoking_MethodName, Type.INT,*
new Type[] { Type.INT,Type.OBJECT }, Constants.INVOKEVIRTUAL));

ilist.append(InstructionConstants.IRETURN);


1-if i use createNew() method and generate new object then how i am going to
fill its fields value?
2-or if i firstly push all fields values of Engine type Obj on Stack using PUSH
then i can some how construct object on memory & then push it on Stack.
these are some solution i can think of.

But i don't know the right solution
So Still need help ...

thanks
  • 1. Re: Can we push a Custom Type Object on Stack in BCEL?
    EJP Guru
    Currently Being Moderated
    Deleted your duplicate post. Please fix your wild formatting without all the boldface and italics, and please use {noformat}
    {noformat} tags around the code. At present this is just an unreadable mess.                                                                                                                                                                                                                                                                                                                                                                                                                            
  • 2. Re: Can we push a Custom Type Object on Stack in BCEL?
    859992 Newbie
    Currently Being Moderated
    Done fixing Format,Hope now things easily get through
  • 3. Re: Can we push a Custom Type Object on Stack in BCEL?
    EJP Guru
    Currently Being Moderated
    You haven't 'done fixing format' at all. There is still bold-face, and you haven't used the code tags. The code is still unformatted and therefore unreadable.

    This is for your own good. Nobody is going to read an unreadable mess.
  • 4. Re: Can we push a Custom Type Object on Stack in BCEL?
    859992 Newbie
    Currently Being Moderated
    I try my best but could not find the Code tag in the editing window.Only i saw was "Plain Text Help" thats why i am unable to do code editing.
  • 5. Re: Can we push a Custom Type Object on Stack in BCEL?
    EJP Guru
    Currently Being Moderated
    I try my best but could not find the Code tag in the editing window.
    Blimey. It's a tag. I wrote it in my first post. Put it around the code.
  • 6. Re: Can we push a Custom Type Object on Stack in BCEL?
    gimbal2 Guru
    Currently Being Moderated
    Perhaps you should stick with the other forums you have spammed this question too, mister Zaree the crossposter.

    http://www.gsurge.org/topic/181-bcel-creating-classes/
  • 7. Re: Can we push a Custom Type Object on Stack in BCEL?
    859992 Newbie
    Currently Being Moderated
    Mr.gimbal2, i dont thnink so that this is BAD thing to post same question on different forums.As on different forums different no of people linked with it and you can get different point of view.
  • 8. Re: Can we push a Custom Type Object on Stack in BCEL?
    EJP Guru
    Currently Being Moderated
    It just wastes everybody's time, starting with your own. What's your procedure for deciding which answer is correct?

    More importantly at the moment, what's your procedure for formatting your code correctly here? If you can't do that, with advice, what chance do you have of (a) identifying the solution and (b) implementing it?
  • 9. Re: Can we push a Custom Type Object on Stack in BCEL?
    gimbal2 Guru
    Currently Being Moderated
    856989 wrote:
    Mr.gimbal2, i dont thnink so that this is BAD thing to post same question on different forums.As on different forums different no of people linked with it and you can get different point of view.
    As you may have noticed, all your attempts to stick to your petty arguments have given you little results; in fact your previous thread was locked because of your own fault. Perhaps you should think a little more and maybe you'll find that what you are doing is not as acceptable as you may think. Make an effort to be helped and perhaps people will start to help you.

    Or go away so people that do want to make an effort can get the proper attention in what little time people have during their day jobs to spend here.
  • 10. Re: Can we push a Custom Type Object on Stack in BCEL?
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    856989 wrote:
    Now i want to push Custom Type Object(Obj of some user defined class i.e EngineClass obj) on Stack in BCEL.
    I seriously doubt that is possible.

    BCEL just represents what the VM byte codes and VM itself does.
    And the 'stack' can only contain a limited set of primitives (not all of the ones in java) and references.

    So you can put a reference that points to the object but not the object itself.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points