The Byte Code Engineering Library (BCEL) is a project sponsored by the
Apache Foundation
The Apache Software Foundation ( ; ASF) is an American nonprofit corporation (classified as a 501(c)(3) organization in the United States) to support a number of open-source software projects. The ASF was formed from a group of developers of the A ...
previously under their
Jakarta
Jakarta (; , Betawi language, Betawi: ''Jakartè''), officially the Special Capital Region of Jakarta (; ''DKI Jakarta'') and formerly known as Batavia, Dutch East Indies, Batavia until 1949, is the capital and largest city of Indonesia and ...
charter to provide a simple API for decomposing, modifying, and recomposing binary
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
classes (I.e.
bytecode
Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normal ...
). The project was conceived and developed by Markus Dahm prior to officially being donated to the Apache Jakarta foundation on 27 October 2001. It is a part of
Apache Commons The Apache Commons is a project of the Apache Software Foundation, formerly under the Jakarta Project. The purpose of the Commons is to provide reusable, Open-source software, open source Java (software platform), Java software. The Commons is compo ...
.
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 metrics 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
AspectJ is an aspect-oriented programming (AOP) extension for the Java programming language, created at PARC. It is available in Eclipse Foundation open-source projects, both stand-alone and integrated into Eclipse. AspectJ has become a widely ...
)
*
Static code analysis
In computer science, static program analysis (also known as static analysis or static simulation) is the analysis of computer programs performed without executing them, in contrast with dynamic program analysis, which is performed on programs duri ...
:
FindBugs
FindBugs is an open-source static code analyzer created by Bill Pugh and David Hovemeyer which detects possible bugs in Java programs. Potential errors are classified in four ranks: (i) scariest, (ii) scary, (iii) troubling and (iv) of concern ...
uses BCEL to analyze Java bytecode for code idioms which indicate bugs.
See also
*
ObjectWeb ASM
The ASM library is a project of the OW2 consortium. It provides a simple API for decomposing, modifying, and recomposing binary Java classes (i.e. bytecode). The project was originally conceived and developed by Eric Bruneton. ASM is Java-centric ...
*Javassist
External links
*
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.)
{{Apache Software Foundation
Virtualization software
BCEL