Results 1 to 11 of 11
  1. #1
    juru is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    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:
    Java 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:
    Java 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.

  2. #2
    juru is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    Default

    And if anyone could help me do that in bytecode, it would also be appreciated :).

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    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.

  4. #4
    juru is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    Default

    Quote 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

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    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.

  6. #6
    juru is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    Default

    Quote 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?

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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.

  8. #8
    georgemc is offline Senior Member
    Join Date
    Sep 2008
    Posts
    135
    Rep Power
    0

    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

  9. #9
    juru is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    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)

  10. #10
    georgemc is offline Senior Member
    Join Date
    Sep 2008
    Posts
    135
    Rep Power
    0

    Default

    You mean "can I hack bytecode to do something other than what it was compiled to do?"

  11. #11
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Quote 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

Similar Threads

  1. Replies: 0
    Last Post: 07-07-2008, 05:35 PM
  2. [SOLVED] Disabling a button not working
    By Leprechaun in forum New To Java
    Replies: 2
    Last Post: 04-24-2008, 05:46 AM
  3. How to get part of a String?
    By eva in forum New To Java
    Replies: 1
    Last Post: 12-23-2007, 07:58 AM
  4. Inventory part 2 help please
    By badness in forum New To Java
    Replies: 1
    Last Post: 12-12-2007, 08:51 AM
  5. disabling JButtons after win in TicTacToe
    By noisepoet in forum New To Java
    Replies: 1
    Last Post: 05-19-2007, 12:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •