classfile
This is the home page for the classfile module.
What Does It Do?
The classfile module is a library which supports direct access to a
Java Virtual Machine classfile's contents. All elements and attributes of a
classfile are accessible from this package's API. The classfile library does
not provide any support for the creation or editing of Java classfiles. Other
excellent open-source libraries can be used for that purpose, such as the
Byte Code Engineering Library
from The Apache Jakarta Project.
For NetBeans 4.0, the classfile module has been updated to support the
new classfile attributes in Java 1.5. This includes support for
annotations, enums, and generics.
The classfile library is not actually a NetBeans module, but is only
packaged as one to use NetBeans' Auto Update facility. By being
packaged as a module, other (real) NetBeans modules may list it as
a dependency and require a minimum version to be present on the system.
The classfile library does not use any NetBeans API, only Java core API.
Examples
Here is a simple example which dumps out a classfile:
static void printClass(String classname) {
try {
System.out.println(new ClassFile(classname));
} catch (IOException e) {
System.out.println(e.toString());
e.printStackTrace();
}
}
Here is an example which prints out any synthetic methods in a class (synthetic methods are methods created by the compiler which have no associated source code):
static void printSyntheticMethods(InputStream in) throws IOException {
ClassFile cf = new ClassFile(in);
Iterator iter = cf.getMethods();
while (iter.hasNext()) {
Method m = (Method)iter.next();
if (m.isSynthetic())
System.out.println(m.toString());
}
}
How to get the module
The module can be built from sources. Download it, compile it and
create the jar file using
ant.
Install the classfile.jar file into the
<NetBeans installation
directory>/modules directory.
Want to comment or help?
We are open to your ideas. If you have any questions, suggestions or
improvements regarding this module, feel free to use the
NetBeans mailing lists.