Giter Club home page Giter Club logo

lamarr's Introduction

lamarr

Attach JShell to an existing Java Process

Usage

jshell -J--module-path=lamarr-1.0.jar --execution instrumentation:pid(128)

Replace 128 with the target process id (pid).
You may want to add --module-path <module-path> --add-modules <roots> and/or -cp <classpath> of your application.

How it works

Lamarr loads a java agent into the target process, and gives JShell an ExecutionControl that uses that process.

Limitations

  • Because lamarr does not use the Java Debug Interface (JDI) - unlike the usualy used ExecutionControl, it can't interrupt snippets.
    Because it is easy to accidentially enter a runaway snippet, usage in production is discouraged.
    If it does happen anyway, you have to kill the target process.
  • Lamarr does not redirect System.in, System.out and System.err.
    This is intentional. But this also means you can't use System.out to get the result into your JShell.
  • Lamarr does automatically configure the classpath/modulepath for you.
    You have to do it by hand.

Background on how JShell works

Roughtly speaking, JShell consits of 3 parts:

  • Frontend
  • Compiler (javac)
  • ExecutionControl

Lamarr only provides an ExecutionControl to JShell.
As such, it will recive a few commands, such as "install bytecode", "execute a method"... and sends them to the java agent, which will do that in the target VM.

Notably, without manual setup the compiler does not know about any application specific classes.

The bytecode is installed into their own ClassLoader, the parent loader is the system class loader.

lamarr's People

Contributors

dasbrain avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.