java-runtime-decompiler - Man Page

Java Runtime Decompiler

Synopsis

  (./start.sh|start.bat) [-verbose] # launches GUI
  (./start.sh|start.bat) [-verbose] (-help|-h|-completion|-R|-hex|BOOT|SYSTEM|-overwrite|-init|-removeoverrides|-addclass|-addclasses|-addjar|-listoverrides|-listclassloaders)
  (./start.sh|start.bat) [-verbose] (-listclasses|-listdetails|-bytes|-base64bytes|-deps|-compile|-decompile|-patch|-api|-listjvms|-listplugins|-listbytecodeversions|-listdetailsversions|-search) [-saveas [-savelike]]
  (./start.sh|start.bat) [-hex] [file, file...] launches standalone hex (or text) editor/diff. Mighty diff. -hex suggests, how to open `file, file...`

Options

Standard options

-help, -h
Print this help text.

-verbose
All exceptions and some debugging strings will be printed to standard error.

-version
Print version project name, version and build timestamp.

-config
Print path to main config file. In verbose mode prints file itself..

-hex
Switch all binary operations to work in hex-readbale format (including patching...)

-classloader <classloader identification>
In jvm, there may be multiple classes of each FQN. Each of them loaded by different classlaoder. This regex allows you to specify classloader(s) you operate on

-listjvms
List all local Java processes and their PIDs.

-listplugins
List all currently configured decompiler plugins and their statuses.

-listagents
JRD keeps record off all local agents, dropping them once inaccessible.Use this to list known agents.

You can append -versions to get also version of agent (may be incompatible or not ours at all)

-listoverrides <PUC>
List all currently overwritten classes

-removeoverrides <PUC> removalRegex
remove all matching overwrittes of classes

-listclasses <PUC> [<CLASS REGEX>...]
List all loaded classes of a process, optionally filtering them.

Only '-savelike exact' or '-savelike default' are allowed as saving modifiers.

-listclassloaders <PUC> [classRegex]
list and count all classloaders visible by agent

-listdetails <PUC> [<CLASS REGEX>...]
Similar to -listclasses, only more details are printed about classes.

-listbytecodeversions <PUC> [<CLASS REGEX>...]
list all classes with bytecode version (slow!)

-listdetailsversions <PUC> [<CLASS REGEX>...]
list all classes with details and bytecode version (slow!)

-search <PUC> <CLASS REGEX>... searchedSubstring true/false (with/without details)
Will search ascii/utf8 substring in regex-subset binaries in remote vm.

To search in decompiled classes use grep.You can misuses -hex to include bytecode level

-base64bytes <PUC> <CLASS REGEX>...
Print Base64 encoded binary form of requested classes of a process.

-bytes <PUC> <CLASS REGEX>...
Print binary form of requested classes of a process

-deps <PUC> <CLASS REGEX>...
Print all deps of the selected class(es).

-patch <PUC>  <PLUGIN>xor<ADDITIONAL-SOURCE/CLASS-PATH (-hex) (-R)
You may ignore plugin/path param in -hex mode.You can apply patch from STD-IN to classes in <PUC>. The patch can be on source, or on binary if  -hex is provided

The header (+++/---) must contain dot-delimited FQN of class. All before / (or \) is stripped. .class$/.java$  is omitted.

See gui for the examples.

If plugin is specified, runtime classpath is decompiled, patched, compiled (is not (de)compiled with -hex) and uploaded.

 If plugin is not specified, then source from additional-source-path is patched, compiled and uploaded.

If -hex is set, then binary from additional-class-path is patched and uploaded. In both cases, class is INIT before all.

This is a bit different from gui, where patch is patching just one file.

In cli can contain several files, and is moreover direct shortcut to init, bytes, (decompile,) patch,( detect bytecode level, compile,) upload.

As patch tool, -R will invert the patch

For debugging -savelike dir can be used to save patched and compiled output. -savelike fqn can be used to save patched sources

-compile [-p <PLUGIN>] [-cp <PUC>] [-r] <PATH>...
Compile local files against runtime classpath, specified by -cp.

Use -p to utilize some plugins' (like jasm or jcoder) bundled compilers.

Use -r for recursive search if <PATH> is a directory.

If the argument of '-saveas' is a valid PID or URL, the compiled code will be attempted to be injected into that process.

If multiple PATHs were specified, but no '-saveas', the process fails.

use: -D of io.github.mkoncek.cplc.log-to-provider= any subset of ADDING_CLASS,IGNORE_ARRAYS,IGNORE_LAMBDAS,INTERESTING,SKIPPING_OVER

to see what is CPLC reolver doing. Warning, CPLC have issues with default (none).

-decompile <PUC> <PLUGIN> <CLASS REGEX>...
Decompile and print classes of a process with the specified decompiler plugin.

Javap can be passed options by appending them without spaces: 'javap-v-public ...' executes as 'javap -v -public ...'

-overwrite <PUC> <FQN> [<CLASS FILE>]
Overwrite class of a process with new bytecode. If <CLASS FILE> is not set, standard input is used.

-addclass <PUC> <FQN> <CLASS FILE>
Add class is currently unable to add class, unless all its dependencies are already in running vm. Stdin used if no file.

-addjar <PUC> <JAR FILE> [BOOT]
Will add all classes from jar into selected VM. If you are adding system classes, yo have to specify BOOT

-addclasses <PUC> (<CLASS FILE1>)^n [BOOT]
Will add all classes into jar, guess theirs FQN, and sent them into selected VM. If you are adding system classes, yo have to specify BOOT

-addclasses <PUC> (<FQN1> <CLASS FILE1>)^n [BOOT]
Will add all classes into jar, set theirs FQN, and sent them into selected VM. If you are adding system classes, yo have to specify BOOT

-init <PUC> <FQN>
Try to initialize a class in a running JVM (has no effect in FS VMs). Because class loading is lazy, the class you need might be missing, eg. java.lang.Override.

-attach <PID>
Will only attach the agent to selected pid. Prints out the port for future usage.

-agent <AgentLiveliness> <AgentLoneliness> <port>
Control how agent is attached. Have sense only in operations attaching to PID. Possible values of AgentLiveliness:

  ONE_SHOT - Agent will connect, do its job and disconnect.

  SESSION - Agent will connect and will remain connected untill end of session.

  PERMANENT - Agent will attach, and will disconnect only manually or on death of target process

optional, defaults to SESSION for -overwrite, -patch, -attach and -compile with upload to VM.

to ONE_SHOT for read. Followed one of AgentLoneliness:

  SINGLE_INSTANCE - Agent be allowed to attach to each process only once, unless FORCING is put to following attachment (default)

  ANONYMOUS - Agent will attach, but will not set the flag about its presence. Still, the property will be set. (weird)

  FORCING - Agent will attach, but will skip the check for single instance (sometimes useful)

  AF - Agent will attach, but will skip the check for single instanceand will not set the flag about its presence. Still, the property will be set. (super weird)

optional, defaults to SINGLE_INSTANCE

You can also specify *port* where the agent will listen, otherwise default port is calculated.

JRD keep record of all permanent and session agents, so they can be listed/reused/removed.

This list is still checked for consistency.

File is /tmp/jrdAgents

The -addclass, -addclasses, -addjar is not SESSION or PERMANENT because there is no way to unload them

-detach URL xor PORT xor PID
Will close and detach PERMANENT agent from given localhost:port or url. To detach from PID, a valid mapping in /tmp/jrdAgents file is needed

-api <PUC>
Will print out dynamic, real-to-time api which can be used to insert fields/methods to running vm

-completion [<completion1, completion2,...>]
Without parameter Will print available code completions. With parameter ofcoded completion names(delimited by ',' or ' '), will print details of that exact set of completion.

Saving modifiers

-saveas <PATH>
All outputs will be written to PATH instead of to standard output.

-savelike <SAVE METHOD>
Specify how saving will behave.

Notes

All options can be with either one or two leading slashes ('-').

When using <CLASS REGEX>, escape dollar signs '$' of inner classes to '\$'; otherwise they mean the end-of-line.

<FQN> is the fully qualified name of a class as per the Java Language Specification §6.7.

<PUC>, short for PidUrlClasspath, can be one of:

· local process PID

· remote process URL, in the format of 'hostname:port'

· classpath of JAR on the filesystem (classpath separator is ':')

<SAVE METHOD> can be one of:

· 'dir' - Result will be saved as '<PATH>/fully/qualified/name.class'. Default for .class binaries.

· 'fqn' - Result will be saved as '<PATH>/fully.qualified.name.java'. Default for .java sources.

· 'exact' - Result will be saved exactly to '<PATH>'. Default for everything else.

· 'default' - Saving uses the defaults mentioned above.

WARNING:

· JRD wa designed to overwrite existing classed, with all limits hot swap have.

· And to add new, not yet present, classes.

· You can try to add add already existing class, to workaround hotswap limitations, but there is no guarantee, such class will be ever picked up.

Referenced By

The man pages java-runtime-decompiler-hex(1), jrd(1) and jrd-hex(1) are aliases of java-runtime-decompiler(1).

2024-09-24