15

I'd like to learn how, or if its possible at all to programmaticly interact with a black-box java application(by reading its data). Has there been any previous research/work on doing this sort of thing?

I'd imagine that running on a JVM significantly complicates things.

@anon: Doing this with any JVM is relevant. Do you have to know or control the specifics of how the JVM allocates memory to extract data from a java application?

Ari Ronen
  • 2,222
  • 2
  • 22
  • 24
  • 1
    Running on an arbitrary JVM, or a particular commercial JVM, or on a JVM you've developed especially for this purpose? Running on a virtual machine instead of a real one makes things *easier* if you control the VM internals, and even if you don't, it doesn't make it any harder as long as you know what those internals are. – Anon. Jun 29 '10 at 04:39
  • A related thread that should apply here: http://stackoverflow.com/questions/2771868/can-i-access-object-from-another-jvms-memory-without-requesting-that-jvm – G__ Jun 29 '10 at 04:44
  • 1
    Maybe the debugger interface helps http://java.sun.com/j2se/1.3/docs/guide/jpda/jvmdi-spec.html – josefx Jun 29 '10 at 05:42

5 Answers5

3

You could look into java.lang.instrument. As long as you understand the class structure of the application, it will let you modify the methods in an already-running JVM and you may be able to concoct a way that allows you to extract or insert data enough to communicate (depends on the methods available, of course).

G__
  • 7,003
  • 5
  • 36
  • 54
  • Thanks, I had never heard of this and it looks promising. I imagine using it in conjunction with the profiling tools other answers have mentioned could be helpful as well. – Ari Ronen Jun 30 '10 at 10:00
1

The Sable group at McGill University has contributed a lot of research to the Java world.

Much of the work is getting rather dated, but you might find some help in their EVolve project which has the goal of visualizing object-oriented programs. Some of their projects appear to be actively maintained (such as Soot, their Java optimization framework), so you might find luck contacting them directly

Chadwick
  • 12,555
  • 7
  • 49
  • 66
1

It is easily possible with, for example, StackTrace. It can attach to a java process and let you inspect and change almost everything with BeanShell.

unbeli
  • 29,501
  • 5
  • 55
  • 57
0

I believe what you're looking for is what the Eclipse MAT does. You might want to take a look at the source code...

Joan Rieu
  • 999
  • 8
  • 19
0

The HotSpot JVM allows you to hook up an agentlib from a profiler (see Open Source Java Profilers or commercials like Your Kit), in the profiler you can then inspect the memory/cpu/threads etc. If you want very specific stuff you might want to make your own agentlib that sends you information about the jvm that you need.

Community
  • 1
  • 1
Redlab
  • 3,110
  • 19
  • 17