Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java agents, invoke methods from other JVM in runtime  RSS feed

 
Stan Gabes
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to create a java agent that accesses an already running JVM and makes it possible to invoke methods inside of certain classes at runtime. However I'm not sure if this is possible since it is translated into bytecode right?

I would like to know if it's possible and maybe a little guide on how to start.

Thanks in advance

With kind regards, Stan
 
Tim Moores
Saloon Keeper
Posts: 3889
91
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could expose those methods via JMX, and then invoke them via a JMX client like VisualVM (assuming that you want to do this manually). To do it programmatically, either write the appropriate JMX client code, or run the Jolokia web app on the same server to do it over HTTP (assuming that this is on a servlet container).
 
Stan Gabes
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:You could expose those methods via JMX, and then invoke them via a JMX client like VisualVM (assuming that you want to do this manually). To do it programmatically, either write the appropriate JMX client code, or run the Jolokia web app on the same server to do it over HTTP (assuming that this is on a servlet container).


I am aware of that, but I want it to hook into a program I haven't made myself. Don't worry, it's not for illegal purposes, I want to log the amount of players on a game server.
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch!
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems like there should be a security barrier to prevent one process from looking at the contents of another process without that process's permission.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!