Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-26-2008, 08:42 PM
Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
juru is on a distinguished road
Default Disabling part of a method
Well, i want to know if there is a way to disable part of a method(.class) rather than decompiling the class and fixing the errors and all.
For ex:
Code:
public method test() {
try {
	    is_17_ = String.methodE(is_16_, true);
	} catch (RuntimeException runtimeexception) {
	    throw Test.method1D(runtimeexception,
				      (""));
	}
}
and i want to disable the Throw, what would i have to do?
EDIT:
i would like it to look like this:
Code:
public method test() {
try {
	    is_17_ = String.methodE(is_16_, true);
	} catch (RuntimeException runtimeexception) {
	is_B_ = new byte[100];
	    //throw Test.method1D(runtimeexception,
				      (""));
	}
}

Last edited by juru; 10-26-2008 at 08:44 PM.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-26-2008, 08:51 PM
Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
juru is on a distinguished road
Default
And if anyone could help me do that in bytecode, it would also be appreciated .
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-26-2008, 09:25 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,393
Rep Power: 8
Fubarable is on a distinguished road
Default
So, let me guess that this is decompiled code that you're messing with. If so, I'd go to the folks who coded it and ask to get the source code. You'll have a much easier time changing that.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 10-26-2008, 10:05 PM
Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
juru is on a distinguished road
Default
Originally Posted by Fubarable View Post
So, let me guess that this is decompiled code that you're messing with. If so, I'd go to the folks who coded it and ask to get the source code. You'll have a much easier time changing that.
No, that is the example, I am the one who has the src(its a basic applet) i made it last night, because i wanted to learn how to disable somepart of a method
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 10-26-2008, 10:13 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,393
Rep Power: 8
Fubarable is on a distinguished road
Default
OK,... then why don't you post the whole class if it's not too big, or shorten it to the smallest possible amount of code that still compiles and still shows your problem. Please adjust your variable and method names, and fix your indentation to make everything readable. Also, please specify exactly what you are trying to do here and why. You stated something about removing a catch block which sounds a bit fishy .... why is there a catch there in the first place, possibly because there's a method within the block that can possibly throw an exception, and you may need the catch,... I'm not sure. Any way, the more information and readable code you can provide, the better we'll understand your problem.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 10-26-2008, 10:16 PM
Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
juru is on a distinguished road
Default
Originally Posted by Fubarable View Post
OK,... then why don't you post the whole class if it's not too big, or shorten it to the smallest possible amount of code that still compiles and still shows your problem. Please adjust your variable and method names, and fix your indentation to make everything readable. Also, please specify exactly what you are trying to do here and why. You stated something about removing a catch block which sounds a bit fishy .... why is there a catch there in the first place, possibly because there's a method within the block that can possibly throw an exception, and you may need the catch,... I'm not sure. Any way, the more information and readable code you can provide, the better we'll understand your problem.
Why is the class src so important? disabling a method, can you not show me how to do it with that method itself?
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 10-26-2008, 10:31 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,393
Rep Power: 8
Fubarable is on a distinguished road
Default
Quote:
Why is the class src so important? disabling a method, can you not show me how to do it with that method itself?
Your code as written makes no sense, isn't compilable in the least (String method "methodE"?), and makes it hard to understand your question out of context. Sure you can often place a portion of a methods code within an if block and use a boolean variable to control its execution, but I've not seen that done with a throws clause. I guess it all smells funny to me.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 10-26-2008, 11:05 PM
Senior Member
 
Join Date: Sep 2008
Posts: 129
Rep Power: 0
georgemc is on a distinguished road
Default
You have the source, but want to manipulate bytecode? Sounds almost certainly like a fudgy workaround for something-or-other. What is that something-or-other? Simply disabling the throwing of a runtime exception isn't going to magically fix some bug you've got, if that's what you're thinking
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 10-26-2008, 11:15 PM
Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
juru is on a distinguished road
Default
No, i wanted to experement with that, for example, whatever the applet sends out can be changed by a class. (like..1+1=2, the output can be changed so 1+1=6, something similar)
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 10-27-2008, 12:01 AM
Senior Member
 
Join Date: Sep 2008
Posts: 129
Rep Power: 0
georgemc is on a distinguished road
Default
You mean "can I hack bytecode to do something other than what it was compiled to do?"
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 10-27-2008, 02:41 AM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 571
Rep Power: 2
fishtoprecords is on a distinguished road
Default
Originally Posted by georgemc View Post
You mean "can I hack bytecode to do something other than what it was compiled to do?"
To which the answer is "yes" with suitable effort and skill
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enabling/disabling menu depending on clipboard content availability Java Tip SWT 0 07-07-2008 05:35 PM
[SOLVED] Disabling a button not working Leprechaun New To Java 2 04-24-2008 05:46 AM
How to get part of a String? eva New To Java 1 12-23-2007 07:58 AM
Inventory part 2 help please badness New To Java 1 12-12-2007 08:51 AM
disabling JButtons after win in TicTacToe noisepoet New To Java 1 05-19-2007 12:01 AM


All times are GMT +2. The time now is 07:01 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org