Javassist help.
Hey all, I have a quick question regarding Javassist.
How do I insert an expression directly before/after an expression?
For example, I have a HelloWorld class with a log method that prints out the numbers to screen like this:
1
2
3
5
6
Notice number 4 is missing. I want to be able to insert a log("4"); statement between log("3"); and log("5");
How do I do this?
HelloWorld.java:
publicclass HelloWorld{
publicstaticvoid main(String[] args){
log("1");
log("2");
log("3");
log("5");
log("6");
}
privatestaticvoid log(Object o){
System.out.println(o);
}
}
Note: I don't want to refer to line numbers since I will be obfuscating and deleting the line number tables.
[1364 byte] By [
solarwinda] at [2007-11-27 9:19:55]

Ah, I see: http://www.csg.is.titech.ac.jp/~chiba/javassist/Perhaps you need to find a javassist forum?
> WTF is javassist?is 2b assisting teh jav misteire petes.
Boy I ask a simple question and all I get is spam... How sad...
spam? my link was directly to the javassist site. how is that spam?
> Boy I ask a simple question and all I get is spam...
> How sad...
This is not the javassist, netbeans, eclipse, JBoss, Joe-Schmoe's Java Junkyard, etc. support forums. Just because a technology is java-related doesn't mean that this is the forum to support it. When dealing with this type of thing, find the developers' mailing-lists, forums, FAQs or what-have-you. You're always more likely to get a better, more rapid - often times more specific response from those sources.
... not to mention the fact that had you taken 10 seconds to type "javassist" into google, you would have found the same results as the only productive post on this thread gave you - a link to the developer's web site.
I suggest you get your attitude straight. I've searched many places, including the Javassist site and could not find any answers relating to my question. Thank you, incompetent fool.
> I suggest you get your attitude straight. I've> searched many places, including the Javassist site> and could not find any answers relating to my> question. Thank you, incompetent fool.Good way of encouraging others to try to help you in the
> I suggest you get your attitude straight. I've
> searched many places, including the Javassist site
> and could not find any answers relating to my
> question. Thank you, incompetent fool.
After searching so many places, you concluded this was the best place to ask such a question? I think here's only one person who needs his attituide straight, and it's not Navy_coder.
I know, it's great, isn't it? Never fails...
"After searching so many places, you concluded this was the best place to ask such a question? I think here's only one person who needs his attituide straight, and it's not Navy_coder."
Oh, golly gosh! Could it be.... hmm... YOU?
Yes, I did search a few places, but it's odd how people try to retaliate in odd ways for their stupidity... it was my mistake to ask you all... Never should have bothered...
Message was edited by:
solarwind
> I know, it's great, isn't it? Never fails...What? Stupidity? Yeah ...
This place SERIOUSLY needs moderators...
> Oh, golly gosh! Could it be.... hmm... YOU?
No, it's not me.
> Yes, I did search a few places, but it's odd how
> people try to retaliate in odd ways for their
> stupidity... it was my mistake to ask you all...
> Never should have bothered...
Yes, people are strange when one starts interacting with 'em, aren't they? Don't be bothered too much, you'll get used to it ...
> This place SERIOUSLY needs moderators...You realize this after being a member for just 2 months? I'd call this quick.
Ok seriously though, I'd REALLY VERY MUCH appreciate it if SOMEONE can help me solve my petty problem. I'm sure there are many intelligent people who can solve this quickly...
> I'm sure there are many intelligent people who can solve this quickly...I'm pretty sure.
> Ok seriously though, I'd REALLY VERY MUCH appreciate
> it if SOMEONE can help me solve my petty problem. I'm
> sure there are many intelligent people who can solve
> this quickly...
Some friendly advice. After having insulted a frequent and well-regarded poster here you assume that you have a good chance of getting help? My guess is probably not. You might want to try over at javaranch.
Wow. It took me a grand total of about seventeen seconds to find the answer to this. There's no way this guy bothered reading the documentation.
> Wow. It took me a grand total of about seventeen> seconds to find the answer to this. There's no way> this guy bothered reading the documentation.Why should he? There's this forum doing his job ...
If you mean that little code block with the before-exptressions in red text colour, that doesn't work, tried that... If you would be so kind as to point me to where you found it, that'd be great. Also, if you're referring to the line number method, already checked that out (wont work for my situation since my class will have its line number tables deleted).
You guys did seem to come of kind of spammish.Perhaps instead of writing"wtf is this javaasst"You could have googled it? Just like you told the original poster to do about his question.
> You guys did seem to come of kind of spammish.
>
> Perhaps instead of writing
> "wtf is this javaasst"
>
> You could have googled it? Just like you told the
> original poster to do about his question.
Thank you, exactly what I was trying to get at.
Hmm, looks like this will require some modification of Javassist. My real objective is to modify an obfuscated class file which has been flow obfuscated, aggressively renamed and line number tables deleted. Inside, it will have several string constructors with secret messages. My goal is to use Javassist to reroute those strings to log(string); statements so as to reveal the string. I know I know that this can be done with reflection, but I must strictly use byte code modification means such as either BCEL, Javassist, ASM and so on. Although revealing hidden messages is one of my first goals, some others include inserting expressions and method calls any where I want through out the code.
so whose program are you doing this to?
> I suggest you get your attitude straight.**** Off !!!
> I suggest you get your attitude straight. > ...Yes, that's always a great response to get help around here. Piss off, twat!
> so whose program are you doing this to?My own.Edit: Seriously, how immature to spam a thread like this. Especially from some senior members, I expected better.Message was edited by: solarwind
> > so whose program are you doing this to?
>
> My own.
I'm confused then. If it is your own program, why not modify it directly? Why go through all of this? Why must you manipulate the byte code and not the source code? What you are trying to do is obviously not straight-forward (else you wouldn't be here asking for help). What am I missing?
I always like challenge =)Well, there will be other uses for this, I'm just flexing my Javassist/BCEL muscle, but this will be more important for other projects... So, any ideas?
> ...> Edit: Seriously, how immature to spam a thread like> this. Especially from some senior members, I expected> better.> ...You brought it on yourself with your attitude.
> ... So, any ideas?Yes: leave this place, and go here:Javassist user questions: http://www.jboss.com/index.html?module=bb&op=viewforum&f=178
Already posted there quite a while ago, that place isn't too active. I believe this is the best place to ask as there are quite a few knowledgeable people here...
> Already posted there quite a while ago, that place
> isn't too active. I believe this is the best place to
> ask as there are quite a few knowledgeable people
> here...
With the exception of the incompetent fools though, right?
>Thank you, incompetent fool.
> Already posted there quite a while ago, that place
> isn't too active. I believe this is the best place to
> ask as there are quite a few knowledgeable people
> here...
You could have stated that in your original post. You also could have been more descriptive and have explained why you posted this here and provided a link to the software you were referring to.
But no, you did not, and when asked what this had to do with Java (in general) and a harmless joke, you displayed your attitude.
Good luck with your problem.
Hmm. I figured I can iterate through all calls to log and control which ones get changed. That'll solve the single replace problem but not the insert one... Hmmm...