Package serp.bytecode

Bytecode Manipuation


Interface Summary
BCEntity Interface implemented by all bytecode entities.
Constants Interface to track constants used in bytecode.
InstructionPtr An entity that maintains ptrs to instructions in a code block.

Class Summary
Annotated An annotated entity.
Annotation A declared annotation.
Annotation.Property An annotation property.
Annotations Java annotation data.
ArrayInstruction Any array load or store instruction.
ArrayLoadInstruction Loads a value from an array onto the stack.
ArrayStoreInstruction Store a value from the stack into an array.
Attribute In bytecode attributes are used to represent anything that is not part of the class structure.
Attributes Abstract superclass for all bytecode entities that hold attributes.
BCClass The BCClass represents a class object in the bytecode framework, in many ways mirroring the Class class of Java reflection.
BCClassLoader Class loader that will attempt to find requested classes in a given Project.
BCField A field of a class.
BCMember A member field or method of a class.
BCMethod A method of a class.
ClassConstantInstruction Pseudo-instruction used to place Class objects onto the stack.
ClassInstruction An instruction that takes as an argument a class to operate on.
CmpInstruction An instruction comparing two stack values.
Code Representation of a code block of a class.
ConstantInstruction An instruction that that loads a constant onto the stack.
ConstantValue A constant value for a member field.
ConvertInstruction A conversion opcode such as i2l, f2i, etc.
Deprecated Attribute signifying that a method or class is deprecated.
ExceptionHandler Represents a try {} catch() {} statement in bytecode.
Exceptions Attribute declaring the checked exceptions a method can throw.
FieldInstruction Instruction that takes as an argument a field to operate on.
GetFieldInstruction Loads a value from a field onto the stack.
GotoInstruction An instruction that specifies a position in the code block to jump to.
IfInstruction An if instruction such as ifnull, ifeq, etc.
IIncInstruction The iinc instruction.
InnerClass Any referenced class that is not a package member is represented by this structure.
InnerClasses Attribute describing all referenced classes that are not package members.
Instruction An opcode in a method of a class.
JumpInstruction An instruction that specifies a position in the code block to jump to.
LineNumber A line number corresponds to a sequence of opcodes that map logically to a line of source code.
LineNumberTable Code blocks compiled from source have line number tables mapping opcodes to source lines.
LoadInstruction Loads a value from the locals table to the stack.
Local A local variable or local variable type.
LocalTable Code blocks compiled from source have local tables mapping locals used in opcodes to their names and descriptions.
LocalVariable A local variable contains the name, description, index and scope of a local used in opcodes.
LocalVariableInstruction An instruction that has an argument of an index into the local variable table of the current frame.
LocalVariableTable Code blocks compiled from source have local variable tables mapping locals used in opcodes to their names and descriptions.
LocalVariableType A local variable type contains the name, signature, index and scope of a generics-using local used in opcodes.
LocalVariableTypeTable Code blocks compiled from source have local variable type tables mapping generics-using locals used in opcodes to their names and signatures.
LookupSwitchInstruction The lookupswitch instruction.
MathInstruction One of the math operations defined in the Constants interface.
MethodInstruction An instruction that invokes a method.
MonitorEnterInstruction The monitorenter instruction.
MonitorExitInstruction The monitorexit instruction.
MonitorInstruction A synchronization instruction.
MultiANewArrayInstruction The multianewarray instruction, which creates a new multi-dimensional array.
NameCache Caching and conversion of names in both internal and external form.
NewArrayInstruction The newarray instruction, which is used to create new arrays of primitive types.
Project The Project represents a working set of classes.
PutFieldInstruction Stores a value from the stack into a field.
RetInstruction The ret instruction is used in the implementation of finally.
ReturnInstruction Returns a value (or void) from a method.
SourceFile Attribute naming the source file for this class.
StackInstruction Represents an instruction that manipulates the stack of the current frame.
StoreInstruction An instruction to store a value from a local variable onto the stack.
SwitchInstruction Contains functionality common to the different switch types (TableSwitch and LookupSwitch).
Synthetic Attribute marking a member as synthetic, or not present in the class source code.
TableSwitchInstruction The tableswitch instruction.
TypedInstruction Any typed instruction.
UnknownAttribute An unrecognized attribute; class files are allowed to contain attributes that are not recognized, and the JVM must ignore them.
WideInstruction The wide instruction, which is used to allow other instructions to index values beyond what they can normally index baed on the length of their arguments.

Package serp.bytecode Description

Bytecode Manipuation

This package contains a framework for Java bytecode manipulation.

Bytecode manipulation is a powerful tool in the arsenal of the Java developer. It can be used for tasks from compiling alternative programming languages to run in a JVM, to creating new classes on the fly at runtime, to instrumenting classes for performance analysis, to debugging, to altering or enhancing the capabilities of existing compiled classes. Traditionally, however, this power has come at a price: modifying bytecode has required an in-depth knowledge of the class file structure and has necessitated very low-level programming techniques. These costs have proven too much for most developers, and bytecode manipulation has been largely ignored by the mainstream.

The goal of the serp bytecode framework is to tap the full power of bytecode modification while lowering its associated costs. The framework provides a set of high-level APIs for manipulating all aspects of bytecode, from large-scale structures like class member fields to the individual instructions that comprise the code of methods. While in order to perform any advanced manipulation, some understanding of the class file format and especially of the JVM instruction set is necessary, the framework makes it as easy as possible to enter the world of bytecode development.

There are several other excellent bytecode frameworks available. Serp excels, however, in the following areas:

Serp is not ideally suited to all applications. Here are a few disadvantages of serp:

The first class that you should study in this package is the Project type. From there, move onto the BCClass, and trace its APIs into BCFields, BCMethods, and finally into actual Code.

Copyright © 2002-2007. All Rights Reserved.