Hi Pietro Not sure JDI is what you really want, but if you would like to play with it I have some code here that uses the PID of the JVM to open a connection to itself and among other things print stack frames with variables:
https://github.com/skarsaune/kantega.debug and some demo here: https://www.youtube.com/watch?v=5sXxIfjaALg So an example of what you can do, but not suitable for anything serious. For inspecting the stack, there is an cool reflection hack to the Java 9 API demonstrated by Andrei Pangin here that is able to capture stack values: https://vimeo.com/233820012 For serious work I suppose an JVMTI agent is the best option. Others are in a better position to offer guidance on that. Martin fre. 6. apr. 2018 kl. 18:14 skrev Pietro Paolini < pietro.paol...@alfasystems.com>: > Hi all, > > > > I apologise if this is not the right ML for it but I couldn’t find > exactly what I was looking for when Googling the problem. I am a bit new to > the JDI world. > > > > I would like to inspect the stack-frame of a specific thread, I came > across the StackFrame/ThreadReference classes but I couldn’t find a way > examples where their usage is shown > > without connecting to the VM somehow, like a debugger would do. > > > > Is it possible to > > > > inspect a thread’s stack “locally” ? In my mind I could be able to have a > function such as : > > > > static void hook(Thread thread) { > > > > thread.wait() // stop that thread > > > > // inspect the frames of that thread doing any needed business with them > > } > > > > I’d need this for diagnostic purposes of my application. > > > > Thanks, > > Pietro > > > > > > > Pietro Paolini > Consultant > > Alfa > ------------------------------ > e: pietro.paol...@alfasystems.com | w: alfasystems.com > <https://www.alfasystems.com> > t: +44 (0) 20 7920-2643 <+44%2020%207920%202643> | Moor Place, 1 Fore > Street Avenue, London, EC2Y 9DT > <https://maps.google.com/?q=1+Fore+Street+Avenue,+London,+EC2Y+9DT&entry=gmail&source=g>, > GB > ------------------------------ > > The contents of this communication are not intended to be binding or > constitute any form of offer or acceptance or give rise to any legal > obligations on behalf of the sender or Alfa. The views or opinions > expressed represent those of the author and not necessarily those of Alfa. > This email and any attachments are strictly confidential and are intended > solely for use by the individual or entity to whom it is addressed. If you > are not the addressee (or responsible for delivery of the message to the > addressee) you may not copy, forward, disclose or use any part of the > message or its attachments. At present the integrity of email across the > internet cannot be guaranteed and messages sent via this medium are > potentially at risk. All liability is excluded to the extent permitted by > law for any claims arising as a result of the use of this medium to > transmit information by or to Alfa or its affiliates. > > Alfa Financial Software Ltd > Reg. in England No: 0248 2325 > >