Guide to using the reJ Graphical User Interface

reJ Menus

This is a brief description of the reJ menu functionalities.

File -menu

New.. / Project..

Creates a new project file (this is essentially a .zip or .jar archive which will contain class files). The path and name of the file to be created will be prompted.

New.. / Class..

Creates a new class in the current project. The actual class file will be created the next time the project is saved. A dialog will pop up, enabling the user to select a package, class name and the file to be created.

Open..

Opens a project. In the context of the reJ tool, a project is a set of class files. The "Open" dialog lets the user choose either a single .class file, a folder (in which case all the files contained in the folder and it's subfolders will be considered to be a part of the project) or an archive file. Once the set of files has been opened, the user may navigate among the files and perform actions such as search or obfuscation on the set files, or edit a single file individually.

Save

Saves any unsaved changes in the currently open reJ project.

Save as..

Prompts for a new file to save the currently open project to.

Recent Files

Contains links the files that have been opened / created recently.

Exit

Exit reJ. If there are unsaved changes, the editor will prompt the user about it.

Edit -menu

Undo

Undoes the last action performed in the current context. In the context of a class, this means the last modification of the current file.

Redo

Redoes a previously undoed (undone?) action in the current context.

Insert..

Pops up an insert menu. What will be prompted to insert depends on the context ie. the currently open tab.

In the case of the constant pool tab, new constants can be added to the pool.

In the case of the bytecode editor, user will be prompted to add either a field or a method.

Remove

Removes the selected item (or items) in the current context.

In the Files tab, this removes files from the current project.

In the constant pool tab this removes the selected constant pool entry. Due to the structure of the constant pool, only the last entry at any given time maybe removed.

In the bytecode editor tab this removes the selected fields, methods and or bytecode instructions.

Find..

Context sensitive search, searches the current tab. Currently implemented for the files tab, and the editor tab (as well as the bytecode view of the compare tab).

Find next

Finds the next occurance of a previously search piece of text.

Navigate -menu

Open Type..

Opens a dialog with all the types (classes and interfaces and so on) in the project and in the classpath set in the Preferences dialog and allows the user to choose one. That type is then opened. The dialog allows filtering on the list, also with CamelCase (if the filter string is NPE, for example, NullPointerException will be visible in the list).

Quick Outline..

Displays the major elements of the current file open in the bytecode editor. This includes the class definition as well as the fields and methods of the class. Selecting one item from the list navigates to the corresponding line in the bytecode editor.

Go to..

Prompts for a source code line for the whole file or a pc (program counter) offset in the current method and then navigates to the given line, if such exists.

View -menu

Line Identifier

This option is for choosing what the bytecode editor displays as the identifier of each instruction line. Options are nothing, the source code line (where available) and the pc offset.

Reference Translation

Let's look at the ldc instruction for instance. It loads a constant onto the stack. The instruction has a parameter which is an index into the constant pool of the current class. The index in the constant pool holds the constant.

When reference translation is off, reJ displays the index on the bytecode editor.

When reference translation is in the translate mode, reJ gets the corresponding constant from the given index and displays the constant in the bytecode editor.

When reference translation is in the hybrid mode, reJ displays both the index number and the translated constant value.

Split Mode

The split mode allows to visualize the relationship between Java source code, the binary class file data and the Java bytecode instructions. Currently only works in one direction, with the hexadecimal binary view. That is, whenever any item is selected in the structure view, constantpool view or the bytecode editor view, the corresponding binary data will be highlighted. In the future this synchronization is meant to work in both ways and also for the source code.

Display "extends Object"

Determines whether "extends Object" is displayed or omitted in class declaration and generics declarations.

Display Generics

Determines whether generic type parameters, arguments and definitions are displayed or not. This only applies for the classes/fields/methods which have the generics information included.

Display Varargs

Determines whether varargs are displayed in the java source code format (String ... strs) or as an array dimension (String[] strs).

Tabs

The tab checkboxes control tab visibility.

Tools

Prefrences..

Displays reJ preferences dialog for setting classpath.

Compare..

Displays the fileset compare tab.

Tabs

Files

When you open a reJ project, it normally consists of a set of files. That is, an archive file or a folder (altough it is also possible to open a single .class file). The Files tab is for navigating within this set of files. It shows a tree-hierarchy of the files contained in the fileset and double-clicking any file it will (try to) open it.

The currently open file is displayed in bold.

Structure

This tab offers a structural view of the currently open class file.

The elements within the class file are displayed in the same order as the appear in the class file. It is possible to edit any attribute data with a hex editor and it is possible to change the class version here. (Both by clicking the corresponding node with right mouse-button.)

Constant Pool

The constant pool tab simply lists all the items in the contant pool of the currently open class file. The constant pool is where all the constant values, class/field/method names, etc, are stored. All the element definitions and instructions with certain types of parameters simply refer an index to the constant pool. Entries can be edited, added and removed. Due to the nature of the pool, entries can only be removed from the end.

Hex Editor

The hex editor tab shows the entire class file contents in hex data. It allows viewing and editing of this data. In case the data is edited, when the user leaves this tab, the class file data is reparsed, in order for reJ to be able to display the data in the other types. If the edited data is no longer a legal (in a lenient sense) class file and reJ is unable to parse it, an error will be displayed and the other tabs are blank until the problem is resolved or another file opened.

Editor

The editor is the most complex part of reJ. It displays the contents of the class file in a Java source-like format, starting with import definitions, class definition and so on. Class file version and source file name (where available in the class file) are shown as comments before the class definition.

Note that static blocks of code appear as methods called clinit and constructors appear as methods called init.

Virtually every type of line (that isn't a blank line) has a context sensitive pop-up menu associated to it. You can see the options by clicking with the right mouse-button.

Class, field and method attributes may be changed. Methods, fields and instructions may be added and removed. Instruction parameters can be modified. Code can be copy/pasted within the editor or (exported) to another application as clear text or HTML.

Hovering the mouse on top of an instruction line displays a hint about what the instruction in question does.

There are various navigational options in the context sensitive menus which are discussed below in the section about navigation.

Obfuscation

Some basic obfuscation functionality is available. They are still in a very experimental phase and may cause the obfuscated code to stop working.

There are options to strip linenumber information and strip variable names.

There's a generate new class names option which will give non-descriptive names to all the classes.

Rename classes, methods and fields to legal names looks for names that are illegal in a Java source file, such as reserved words and renames them with legal versions of the names.

Batch mode, when activated is less memory consuming as it saves all the information on the fly. No undo is available if this is checked. In a non- batch mode all the changes made to the classes can be undone. All classes that are modified have to stay in the memory of reJ and this can consume a lot of memory in a large project.

Search

The search tab allows the user to search within the currently open project.

The search results are displayed in a list with a brief description of each result. Double-clicking a line will navigate to the file and line in question in the editor view.

Debug

The debug tab allows connecting to an existing JVM process or launching a new on for the purpose of debugging the JVM. Breakpoints can be set in the bytecode, suspending the execution and stepping in the bytecode is possible.

Compare

The compare functionality is another powerful option of reJ. The user can select two sets of files, for example, and compare them. reJ will present a tree-view of the two sets of files:

Coloring with red or yellow the files that only exist in one of the sets

Coloring with red-and-yellow the files that exist in both sets, but where the files are not identical.

Leaving white the files that exist in both sets and where the files in both sets are equal.

Double-clicking any red-and-white file (one that exists in both sets, but where the files differ) will give a diff-like view of the bytecode, where lines that are equal are displayed with white background and files that only exist in one of the file sets are displayed with yellow or red background.

How to navigate

A relatively big effort has been put into enabling the user to easily navigate through the file set and bytecode. The following highlights some of the navigating functionality.

The Files tab is the most obvious means of navigation. Double-clicking any file name opens that file. The currently open file is shown in bold in the tree view.

The Search tab also allows quick navigation, performing a search and double-clicking on any of the results allows the user to navigate to the file/line in question.

In the Navigate menu, the "Open Type" option (also available via the keyboard shortcut CTRL + SHIFT + T) displays a list of all classes in the current classpath (that is, files in the currently open file set and any file sets defined to be in the classpath in the Preferences dialog). It has a filter for quickly locating the desired file. Selecting a file will navigate to that file.

Also in the Navigate menu, the "Quick outline" option shows a list of highlighted items in the currently open view. It is also available via the keyboard shortcut CTRL + SHIFT + O. Choosing an element will navigate to the element in question.

Still in the Navigate menu, the "Go to" option allows the navigation to a given source code line, or pc offset in the currently open file.

In the context menu of a instruction that refers to a field, method or a class, the "Find definition" does a search for the definition of that field, method or class. The results are displayed in the search tab. "Go to definition" tries to directly navigate to the definition of the referred field, method or class. "Find references" does a search for references to a class, method or field definition.