org.netbeans.modules.classfile |
The org.netbeans.modules.classfile package supports direct
access to a Java Virtual Machine classfile contents. All elements and
attributes of a classfile are accessible from this package's API. This
package only supports read-only access of classfiles at this time.
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.
The classfile library has only four constructors, as the only objects that
can be created by a client are ClassFile objects (one constructor takes
an InputStream of classfile bytes, another takes a filename, and variants
of these two constructors allow creation of Code objects to be suppressed).
The ClassFile object is then queried for its elements. A ClassFile and
its elements should be considered immutable, even though it may be
possible to change one of its objects (if so, it's a bug).
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:
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());
}
}
Related Documentation
|
Java Source File Name | Type | Comment |
Access.java | Class | A utility class defining access flags and access utility methods. |
AccessTest.java | Class | |
Annotation.java | Class | Annotation: a single annotation on a program element. |
AnnotationComponent.java | Class | AnnotationComponent: a single annotation on a program element. |
ArrayElementValue.java | Class | ArrayElementValue: the value portion of an annotation element that
is an array of ElementValue instances. |
AttributeMap.java | Class | Class representing a map of classfile attributes. |
ByteCodes.java | Interface | Constant definitions for the bytecodes defined in the
Java Virtual Machine specification, Chapter 10. |
ClassElementValue.java | Class | ClassElementValue: the value part of a single element for
those annotations that are a class type. |
ClassFile.java | Class | Class representing a Java class file. |
ClassName.java | Class | Class representing the name of a Java class. |
ClassNameTest.java | Class | |
Code.java | Class | The Code attribute of a method. |
ConstantPool.java | Class | Class representing a Java class file constant pool. |
ConstantPoolReader.java | Class | A Java class file constant pool reader. |
ConstantPoolTest.java | Class | |
CPClassInfo.java | Class | A class representing the CONSTANT_Class constant pool type. |
CPDoubleInfo.java | Class | A class representing the CONSTANT_Double constant pool type. |
CPEntry.java | Class | A class representing an entry in a ConstantPool. |
CPFieldInfo.java | Class | A class representing the CONSTANT_Fieldref constant pool type. |
CPFieldMethodInfo.java | Class | The base class for field, method, and interface method constant pool types. |
CPFloatInfo.java | Class | A class representing the CONSTANT_Float constant pool type. |
CPIntegerInfo.java | Class | A class representing the CONSTANT_Integer constant pool type. |
CPInterfaceMethodInfo.java | Class | A class representing the CONSTANT_InterfaceMethodref constant pool type. |
CPLongInfo.java | Class | A class representing the CONSTANT_Long constant pool type. |
CPMethodInfo.java | Class | A class representing the CONSTANT_Methodref constant pool type. |
CPName.java | Class | The base class for all constant pool types which store strings. |
CPNameAndTypeInfo.java | Class | A class representing the CONSTANT_NameAndType constant pool type. |
CPStringInfo.java | Class | A class representing the CONSTANT_String constant pool type. |
CPUTF8Info.java | Class | A class representing the CONSTANT_Utf8 constant pool type. |
ElementValue.java | Class | ElementValue: the value portion of the name-value pair of a
single annotation element. |
EnclosingMethod.java | Class | A class representing the enclosing method of an inner class. |
EnumElementValue.java | Class | EnumElementValue: a single annotation on a program element for
those annotations that are enum constants. |
ExceptionTableEntry.java | Class | An entry in the exception table of a method's code attribute. |
Field.java | Class | Base class for variables and methods. |
InnerClass.java | Class | An InnerClass attribute of a classfile. |
InvalidClassFileAttributeException.java | Class | Thrown when a classfile attribute does not follow the specified format.
This is an RuntimeException subclass rather than an Exception because it
is very unlikely that a classfile can be read without exception (such as
when the classfile is truncated or overwritten) yet have an invalid attribute. |
InvalidClassFormatException.java | Class | Exception thrown when a classfile with an invalid format is detected. |
LocalVariableTableEntry.java | Class | An entry in the local variable table of a method's code attribute. |
LocalVariableTypeTableEntry.java | Class | An entry in the local variable type table of a method's code attribute.
This table is similar to the local variable table, but differs in that
it only contains the type information for those variables that are generic
reference types. |
Method.java | Class | A Java method object. |
NestedElementValue.java | Class | NestedElementValue: an annotation on a program element that is
another annotation. |
Parameter.java | Class | A representation of a parameter to a method declaration. |
ParamNameTest.java | Class | Converted from org.netbeans.jmi.javamodel.getters.ParamNameTest to
directly use classfile API instead of javacore. |
PrimitiveElementValue.java | Class | A PrimitiveElementValue is the value portion of an annotation component
that has a primitive type or String constant. |
StackMapFrame.java | Class | A stack map frame, as defined by a StackMapTable attribute. |
Variable.java | Class | A Java field. |
VerificationTypeInfo.java | Class | VerificationTypeInfo structure, which is defined as a C-like union
in the Java Virtual Machine Specification, section 4.8.4, and is
used to define stack map frame structures. |