Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

get current StackFrame thru JDI

Thread view: 
Ken.C - 05 Feb 2007 12:21 GMT
Hi,
I did Google search but didn't get much useful info...
Basically, I encountered IndexOutOfBoundsException when trying to get
current stack frame:
1    void methodEntryEvent(MethodEntryEvent event) {
2      Method method = event.method();
3      ThreadReference thread = (ThreadReference) event.thread();
4      try {
5        StackFrame stackFrame = thread.frame(0);
        .............
      }
      catch(IncompatibleThreadStateException e){
        ........
      }
    }

The exception occurred at line 5. Test codes running on the target VM
are:

 public static void main(String[] args) {
   String name = "Someone";
   System.out.println(foo(name));
 }

 private static String foo(String name) {
   System.out.println(bar(888));
   return "Hi, " + name + ".";
 }

 private static int bar(int a) {
   return 999;
 }

Does anyone know why the stack counter is always 0 in my codes?

Thanks a lot
Chris Uppal - 07 Feb 2007 18:53 GMT
> Does anyone know why the stack counter is always 0 in my codes?

I know very little about JDI, but no one else has replied so....

Was the thread suspended at the time the event was generated ?  If not then I
doubt whether frames are available (since the thread will have gone on
executing while the event was passed through the event queue).  See the
documentation for

   EntryRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL)

And then you'll have to resume() the target ThreadReference.  There's more
documentation about it, but I've only skimmed that -- you should probably read
it more carefully than me ;-)

   -- chris


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.