Guide for plugin usage:
https://corrupt.wiki/rtcv/other-rtc-guides/java-corruptor-plugin
# Java corruptor plugin overview
### Introduction
The Java corruptor is a plugin made to easily corrupt games written in Java. It was written with similarity to the usual RTC experience in mind, so your prior experience with RTC will be applicable when using it. This overview will cover the behavior of the different engines, important facts about Java to keep in mind, and notable differences between the Java corruptor and RTC.
### Prerequisite Java information
The JVM (Java Virtual Machine) is a stack machine, which means that each instruction ran modifies a stack of values. An instruction might switch items around on the top of the stack, remove an item from the stack, add one, add/remove multiple, or any combination of these. It's important that when you corrupt the bytecode, it will result in the stack having the same value on it as it did originally. If you run an instruction that removes a value from the top of the stack, but there are no items left, Java will detect the possibility of that before the program even starts. If you try to return from a method with more than one value on the stack (or any at all in the case of a void), the program won't start. If you replace an instruction that takes a different type of value from the stack than the original, the program won't start either. You can find a list of each instruction, its operands, and its stack behavior [here](https://en.wikipedia.org/wiki/List_of_Java_bytecode_instructions).
## Normal Usage
The Java Corruptor Plugin makes use of FileStub for loading files as input. Its interface is loaded from the Custom Layouts item in the Main menu. The Corruptor comes with custom replacement controls that replaces the main window's usual tools.
## Java blast units
A Java blast unit includes the name of method to corrupt, the index of the instruction to corrupt, a number of instructions to replace at the index, and a list of instructions to place there instead. If the `Replaces` value is set to 0, the instructions will be inserted before the index without removing it.
## General Parameters
**Intensity**
The approximate percentage of instructions to corrupt.
**Launch a program after corrupting**
Lets you choose a program to launch after corrupting the game. For example, you might write a batch script to replace the old JAR file and then launch the game.
**Use last seed**
Lets you corrupt the game with the same random values as last time. This was added for debugging purposes, but can be handy to more easily re-roll a corruption with different settings.
## Re-rolling corruptions
The Java corruptor plugin has a different method of re-rolling blast units. Each unit has the engine used to create it saved within, as well as the engine's settings. You can edit a unit's settings by right-clicking it in the blast editor and clicking "Modify Re-roll Settings". Besides that, units are re-rolled the same way as you normally would in RTC.
## The disassembler
The disassembler can be a useful tool when editing blast units or writing a custom engine. It allows you to read the Java bytecode instructions within a method. It can be opened by clicking the "Open Disassembler" button in the general parameters or by right-clicking a unit's method and clicking "Disassemble this unit's method".
## Engines
Each engine has an effective default configuration except for Vector engine and Nuker engine.
#### Vector Engine
This engine replaces any of the selected limiter instructions with any of the selected value instructions. It only includes instructions that do not have any operands.
**Replaces:** 1 instruction
**Creates:** 1 instruction
#### Arithmetic Engine
This engine adds an extra math operation to be performed on the result of an arithmetic instruction.
**Limiters**
Which operations should be corrupted.
**Operations**
What operations can be added after.
**'Int', 'Float', 'Long', and 'Double' check boxes**
These let you choose.which types should be corrupted. Floats and doubles are generally the best to corrupt. Checking 'int' will also corrupt math done on shorts and bytes.
**Minimum and Maximum**
The engine chooses a random value between these numbers to perform the new operation with. For ints and longs, the value is rounded down.
**Randomize Value at Runtime**
This decides whether the extra operation should be performed with a constant value, or with a different one between the minimum and maximum each time the corrupted code is run.
**Replaces:** 1 instruction
**Creates:** The original instruction, and with 'randomize value at runtime' off, 2 more. With 'randomize value at runtime' on, 9 more.
#### Function Engine
This engine replaces calls to any of the selected limiter functions with any of the selected value instructions. The "POP,random()" option discards the value that would be passed to the original function, and replaces the function with Math.random() which returns a value between 0 and 1.
**Replaces:** 1 instruction
**Creates:** 1 instruction
#### Custom Engine
This engine allows you to create your own engine with regular expressions (regex). You can right the Corruption Engine title bar to pop the window out and resize it for more space, and you can resize the two sections by clicking and dragging between the text boxes. Before corrupting, use the "Check For Errors" button to ensure that the engine won't generate any invalid instructions. It will run your engine on every instruction in the currently loaded JAR, then report back with which lines produced errors and why. If your engine produces invalid instructions in the test, but you decide to corrupt with it anyway, expect a cloud debug box to show up when the plugin fails to parse a broken instruction string.
**Find**
A list of instructions to corrupt. All text in a line after `//` is ignored. Multi-line comments are also supported with `/*` at the beginning and `*/` at the end. Regexes should be put in \
**Replace**
A list of instructions to replace the original ones with. You can reference capture groups in the original like `<$1>`. Multiple references combined like `<$1$2$3>` will not work. To generate a random single-precision floating-point number, use the syntax `