Hi Burt,
Many thanks for this. I'll study this and see how we go.
I think an 'interesting' aspect of this is exceptions. In particular when an
exception is thrown there is no gaurentee that this exits the method. It
could be that the exception is caught within the method and handled - this
area feels really tricky. However I'm going to study the Exceptions
mechanism when I get more time (this is my own personal interest - so
probably not till next week).
Meanwhile thanks for input so far - I am a seaoned Java programmer, but the
learning curve on this stuff is hurting/interesting!
But the potential power is amazing...
Ian
>From: "Burt Wagner" <[EMAIL PROTECTED]>
>Reply-To: "BCEL Users List" <[EMAIL PROTECTED]>
>To: "BCEL Users List" <[EMAIL PROTECTED]>
>Subject: RE: Method start & termination points
>Date: Wed, 21 Aug 2002 09:50:31 -0600
>
>Ian Hunter wrote:
>
>Are there convenient ways within BCel to identify points in methods
>where
>users can safely insert code. My thoughts are that given a method, can I
>
>identify things like all return statements, exception exits from the
>method
>and possibly System.exit(). I also realise that in the case of <init>
>there
>is some code which must be first (the new and the call to super()).
>There may be other examples which I haven't come across.
>
>Burt Wagner, Senior Software Engineer
>Alignment Software, Inc. www.alignmentsoftware.com
>(Formerly NPULSE Software, Inc. www.npulse.com)
>100 Superior Plaza Way, Suite 200
>Superior, Colorado 80027
>Work: (303) 642-4457 WFax: (303) 642-4002
>Cell: (303) 589-3095
>
>Responds:
>
>The following code snip might give you some ideas.
>
>public static final String PATTERNS =
> "`RETURN'|`ARETURN'|`DRETURN'|`FRETURN'|`IRETURN'|`LRETURN'";
>
>InstructionHandle instructionHandle = instructionList.getStart();
>FindPattern findPattern = new FindPattern(instructionList);
>
>do {
>
> instructionHandle = findPattern.search(PATTERNS, instructionHandle);
>
> if (instructionHandle != null) {
>
> Instruction instruction = instructionHandle.getInstruction();
> switch (instruction.getOpcode()) {
>
> case Constants.IRETURN: // 172
> break;
>
> case Constants.LRETURN: // 173
> break;
>
> case Constants.FRETURN: // 174
> break;
>
> case Constants.DRETURN: // 175
> break;
>
> case Constants.ARETURN: // 176
> break;
>
> case Constants.RETURN: // 177
> break;
>
> default: throw new RuntimeException("Bad case in opcode switch");
> }
>
>} while (instructionHandle!=null);
>
>
>--
>To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
------------------------------
Sent from my Hotmail Account.
------------------------------
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>