HOME

TheInfoList



OR:

Javassist (Java programming assistant) is a
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
library A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vi ...
providing a means to manipulate the Java bytecode of an application. In this sense Javassist provides the support for structural reflection, i.e. the ability to change the
implementation Implementation is the realization of an application, or execution of a plan, idea, model, design, specification, standard, algorithm, or policy. Industry-specific definitions Computer science In computer science, an implementation is a real ...
of a class at run time. Bytecode manipulation is performed at load-time through a provided class loader. Javassist enables Java programs to define a new class at runtime and to modify a class file when the JVM loads it. Unlike other similar bytecode editors, Javassist provides two levels of API: source level and bytecode level. Using the source-level API, programmers can edit a class file without knowledge of the specifications of the Java bytecode; the whole API is designed with only the vocabulary of the Java language. Programmers can even specify inserted bytecode in the form of Java source text; Javassist compiles it on the fly. On the other hand, the bytecode-level API allows the users to directly edit a class file as other editors.


Uses

Javassist can be used for the following: * For specifying the bytecode using source code – can compile a fragment of source text online (e.g., just a single statement) * For
aspect-oriented programming In computing, aspect-oriented programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It does so by adding behavior to existing code (an advice) ''without'' modifying ...
(AOP) – can introduce new methods into a class and insert before/after/around advice at both the caller and callee sides * For reflection at runtime – can use a metaobject that controls method calls on base-level objects * For remote method invocation – can call a method on a remote object running on a web server, an alternative to Java RMI that does not need a stub compiler such as


See also

* ObjectWeb ASM * Byte Code Engineering Library


References


External links

Java (programming language) libraries {{compu-lang-stub