The Byte Code Engineering Library (BCEL) is a project sponsored by the Apache Foundation under their Jakarta charter to provide a simple API for decomposing, modifying, and recomposing binary Java classes (I.e. bytecode). The project was originally concieved and developed by Markus Dahm prior to officially being donated to the Apache Jakarta foundation on 27 October 2001. BCEL is Java-centric at present, and does not currently have a backend that exposes other bytecode implementations (such as .NET bytecode, Python bytecode, etc..) Byte-code is a sort of intermediate code that is more abstract than machine code. ... Python is an interpreted programming language created by Guido van Rossum in 1990. ...
Uses
BCEL provides a simple library that exposes the internal aggregate components of a given Java class through its API as object constructs (as opposed to the disassembly of the lower-level opcodes). These objects also expose operations for modifying the binary bytecode, as well as generating new bytecode (via injection of new code into the existing code, or through generation of new classes altogether.) The BCEL library has been used in several diverse applications, such as:
Java Bytecode Decompiling, Obfuscation, and Refactoring
Performance and Profiling
Instrumentation calls that capture performance meterics can be injected into Java class binaries to examine memory/coverage data. (For example, injecting instrumentation at entry/exit points.)
Implementation of New Language Semantics
For example, Aspect-Oriented additions to the Java language have been implemented by using BCEL to decompose class structures for point-cut identification, and then again when reconstituting the class by injecting aspect-related code back into the binary. (See: AspectJ)
In computing, the programming paradigm of aspect_oriented programming (AOP) centers on constructs called aspects, which treat concerns of a separate set of objects, classes, or functions. ...
External links
Jakarta ByteCode Engineering Library - The BCEL Project Home Page.
BCEL-Based Project Listing - A listing of projects that make use of the BCEL Library.
Apache Jakarta Home - The Apache Jakarta Home Page.
AspectJ - The AspectJ Project Home Page. (One of the high-visibility projects that makes use of BCEL.)
It uses BCEL to enhance the bytecode of Java Peer classes to add transparent lifetime management for C++ JNI peers.
BCEL has its rough edges, but it's generally nice to use, and it's a great asset to Java.
The current approach is to reduce the stack-based JVM code to an expression tree format so that the reordering can be done in the translator rather than the generated code (although this changes the semantics of the Java source code wrt parameter evaluation order).
As in intermediate code, it is a form of output code used by programming language implementors to reduce dependence on specific hardware and ease interpretation.
Java code is typically transmitted as bytecode to a receiving machine, which then uses a JIT compiler to translate the bytecode to machine code before execution.
Also of interest are p-Codes, which are just like bytecodes, but may be physically larger than a single byte and may vary in size (much like opcodes on many CPUs).