Java Doc for ClassFile.java in  » Byte-Code » Cojen » org » cojen » classfile » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Byte Code » Cojen » org.cojen.classfile 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.cojen.classfile.ClassFile

ClassFile
public class ClassFile (Code)
A class used to create Java class files. Call the writeTo method to produce a class file.

See The Java Virtual Machine Specification (ISBN 0-201-63452-X) for information on how class files are structured. Section 4.1 describes the ClassFile structure.
author:
   Brian S O'Neill




Constructor Summary
public  ClassFile(String className)
     By default, the ClassFile defines public, non-final, concrete classes.
public  ClassFile(String className, Class superClass)
     By default, the ClassFile defines public, non-final, concrete classes.
public  ClassFile(String className, String superClassName)
     By default, the ClassFile defines public, non-final, concrete classes.

Method Summary
public  voidaddAttribute(Attribute attr)
     Add an attribute to this class.
public  MethodInfoaddConstructor(Modifiers modifiers, TypeDesc[] params)
     Add a constructor to this class.
public  MethodInfoaddDefaultConstructor()
     Adds a public, no-arg constructor with the code buffer properly defined.
public  FieldInfoaddField(Modifiers modifiers, String fieldName, TypeDesc type)
     Add a field to this class.
public  MethodInfoaddInitializer()
     Add a static initializer to this class.
public  ClassFileaddInnerClass(String fullInnerClassName, String innerClassName)
     Add an inner class to this class.
public  ClassFileaddInnerClass(String fullInnerClassName, String innerClassName, Class superClass)
     Add an inner class to this class.
public  ClassFileaddInnerClass(String fullInnerClassName, String innerClassName, String superClassName)
     Add an inner class to this class.
public  voidaddInterface(String interfaceName)
     Add an interface that this class implements.
public  voidaddInterface(Class i)
     Add an interface that this class implements.
public  MethodInfoaddMethod(Modifiers modifiers, String methodName, TypeDesc ret, TypeDesc[] params)
     Add a method to this class.
public  MethodInfoaddMethod(Modifiers modifiers, String methodName, MethodDesc md)
     Add a method to this class.
public  MethodInfoaddMethod(Method method)
     Add a method to this class.
public  MethodInfoaddMethod(String declaration)
     Add a method to this class by declaration.
public  AnnotationaddRuntimeInvisibleAnnotation(TypeDesc type)
     Add a runtime invisible annotation.
public  AnnotationaddRuntimeVisibleAnnotation(TypeDesc type)
     Add a runtime visible annotation.
public  Attribute[]getAttributes()
    
public  intgetClassDepth()
     Returns a value indicating how deeply nested an inner class is with respect to its outermost enclosing class.
public  StringgetClassName()
    
public  ConstantPoolgetConstantPool()
     Provides access to the ClassFile's ContantPool.
public  MethodInfo[]getConstructors()
     Returns all the constructors defined in this class.
public  FieldInfo[]getFields()
     Returns all the fields defined in this class.
public  MethodInfogetInitializer()
     Returns the static initializer defined in this class or null if there isn't one.
public  StringgetInnerClassName()
     If this ClassFile represents a non-anonymous inner class, returns its short inner class name.
public  ClassFile[]getInnerClasses()
     Returns all the inner classes defined in this class.
public  String[]getInterfaces()
     Returns the names of all the interfaces that this class implements.
public  intgetMajorVersion()
     Returns the major version number of the classfile format.
public  MethodInfo[]getMethods()
     Returns all the methods defined in this class, not including constructors and static initializers.
public  intgetMinorVersion()
     Returns the minor version number of the classfile format.
public  ModifiersgetModifiers()
    
public  ClassFilegetOuterClass()
     Returns null if this ClassFile does not represent an inner class.
public  Annotation[]getRuntimeInvisibleAnnotations()
     Returns all the runtime invisible annotations defined for this class file, or an empty array if none.
public  Annotation[]getRuntimeVisibleAnnotations()
     Returns all the runtime visible annotations defined for this class file, or an empty array if none.
public  SignatureAttrgetSignatureAttr()
     Returns the signature attribute of this classfile, or null if none is defined.
public  StringgetSourceFile()
     Returns the source file of this class file or null if not set.
public  StringgetSuperClassName()
    
public  StringgetTarget()
     Returns the target virtual machine version, or null if unknown.
public  TypeDescgetType()
     Returns a TypeDesc for the type of this ClassFile.
public  booleanisDeprecated()
    
public  booleanisInnerClass()
     Returns true if this ClassFile represents an inner class.
public  booleanisSynthetic()
    
public  voidmarkDeprecated()
     Mark this class as being deprecated by adding a special attribute.
public  voidmarkSynthetic()
     Mark this class as being synthetic by adding a special attribute.
public static  ClassFilereadFrom(InputStream in)
     Reads a ClassFile from the given InputStream.
public static  ClassFilereadFrom(DataInput din)
     Reads a ClassFile from the given DataInput.
public static  ClassFilereadFrom(InputStream in, ClassFileDataLoader loader, AttributeFactory attrFactory)
     Reads a ClassFile from the given InputStream.
public static  ClassFilereadFrom(DataInput din, ClassFileDataLoader loader, AttributeFactory attrFactory)
     Reads a ClassFile from the given DataInput.
public  voidsetModifiers(Modifiers modifiers)
    
public  voidsetSourceFile(String fileName)
     Set the source file of this class file by adding a source file attribute.
public  voidsetTarget(String target)
     Specify what target virtual machine version classfile should generate for.
public  voidsetVersion(int major, int minor)
     Sets the version to use when writing the generated classfile, overriding the target.
public  StringtoString()
    
public  voidwriteTo(OutputStream out)
     Writes the ClassFile to the given OutputStream.
public  voidwriteTo(DataOutput dout)
     Writes the ClassFile to the given DataOutput.


Constructor Detail
ClassFile
public ClassFile(String className)(Code)
By default, the ClassFile defines public, non-final, concrete classes. This constructor creates a ClassFile for a class that extends java.lang.Object.

Use the ClassFile.setModifiers method to change the access modifiers of this class or to turn it into an interface.
Parameters:
  className - Full class name of the form ex: "java.lang.String".




ClassFile
public ClassFile(String className, Class superClass)(Code)
By default, the ClassFile defines public, non-final, concrete classes.

Use the ClassFile.setModifiers method to change the access modifiers of this class or to turn it into an interface.
Parameters:
  className - Full class name of the form ex: "java.lang.String".
Parameters:
  superClass - Super class or interface.




ClassFile
public ClassFile(String className, String superClassName)(Code)
By default, the ClassFile defines public, non-final, concrete classes.

Use the ClassFile.setModifiers method to change the access modifiers of this class or to turn it into an interface.
Parameters:
  className - Full class name of the form ex: "java.lang.String".
Parameters:
  superClassName - Full super class name.





Method Detail
addAttribute
public void addAttribute(Attribute attr)(Code)
Add an attribute to this class.



addConstructor
public MethodInfo addConstructor(Modifiers modifiers, TypeDesc[] params)(Code)
Add a constructor to this class.
Parameters:
  params - May be null if constructor accepts no parameters.



addDefaultConstructor
public MethodInfo addDefaultConstructor()(Code)
Adds a public, no-arg constructor with the code buffer properly defined.



addField
public FieldInfo addField(Modifiers modifiers, String fieldName, TypeDesc type)(Code)
Add a field to this class.



addInitializer
public MethodInfo addInitializer()(Code)
Add a static initializer to this class.



addInnerClass
public ClassFile addInnerClass(String fullInnerClassName, String innerClassName)(Code)
Add an inner class to this class. By default, inner classes are private static.
Parameters:
  fullInnerClassName - Optional full inner class name.
Parameters:
  innerClassName - Optional short inner class name.



addInnerClass
public ClassFile addInnerClass(String fullInnerClassName, String innerClassName, Class superClass)(Code)
Add an inner class to this class. By default, inner classes are private static.
Parameters:
  fullInnerClassName - Optional full inner class name.
Parameters:
  innerClassName - Optional short inner class name.
Parameters:
  superClass - Super class.



addInnerClass
public ClassFile addInnerClass(String fullInnerClassName, String innerClassName, String superClassName)(Code)
Add an inner class to this class. By default, inner classes are private static.
Parameters:
  fullInnerClassName - Optional full inner class name.
Parameters:
  innerClassName - Optional short inner class name.
Parameters:
  superClassName - Full super class name.



addInterface
public void addInterface(String interfaceName)(Code)
Add an interface that this class implements.
Parameters:
  interfaceName - Full interface name.



addInterface
public void addInterface(Class i)(Code)
Add an interface that this class implements.



addMethod
public MethodInfo addMethod(Modifiers modifiers, String methodName, TypeDesc ret, TypeDesc[] params)(Code)
Add a method to this class.
Parameters:
  ret - Is null if method returns void.
Parameters:
  params - May be null if method accepts no parameters.



addMethod
public MethodInfo addMethod(Modifiers modifiers, String methodName, MethodDesc md)(Code)
Add a method to this class.



addMethod
public MethodInfo addMethod(Method method)(Code)
Add a method to this class. This method is handy for implementing methods defined by a pre-existing interface.



addMethod
public MethodInfo addMethod(String declaration)(Code)
Add a method to this class by declaration.
throws:
  IllegalArgumentException - if declaration syntax is wrong
See Also:   MethodDeclarationParser



addRuntimeInvisibleAnnotation
public Annotation addRuntimeInvisibleAnnotation(TypeDesc type)(Code)
Add a runtime invisible annotation.



addRuntimeVisibleAnnotation
public Annotation addRuntimeVisibleAnnotation(TypeDesc type)(Code)
Add a runtime visible annotation.



getAttributes
public Attribute[] getAttributes()(Code)



getClassDepth
public int getClassDepth()(Code)
Returns a value indicating how deeply nested an inner class is with respect to its outermost enclosing class. For top level classes, 0 is returned. For first level inner classes, 1 is returned, etc.



getClassName
public String getClassName()(Code)



getConstantPool
public ConstantPool getConstantPool()(Code)
Provides access to the ClassFile's ContantPool. The constant pool for this class file.



getConstructors
public MethodInfo[] getConstructors()(Code)
Returns all the constructors defined in this class.



getFields
public FieldInfo[] getFields()(Code)
Returns all the fields defined in this class.



getInitializer
public MethodInfo getInitializer()(Code)
Returns the static initializer defined in this class or null if there isn't one.



getInnerClassName
public String getInnerClassName()(Code)
If this ClassFile represents a non-anonymous inner class, returns its short inner class name.



getInnerClasses
public ClassFile[] getInnerClasses()(Code)
Returns all the inner classes defined in this class. If no inner classes are defined, then an array of length zero is returned.



getInterfaces
public String[] getInterfaces()(Code)
Returns the names of all the interfaces that this class implements.



getMajorVersion
public int getMajorVersion()(Code)
Returns the major version number of the classfile format.



getMethods
public MethodInfo[] getMethods()(Code)
Returns all the methods defined in this class, not including constructors and static initializers.



getMinorVersion
public int getMinorVersion()(Code)
Returns the minor version number of the classfile format.



getModifiers
public Modifiers getModifiers()(Code)



getOuterClass
public ClassFile getOuterClass()(Code)
Returns null if this ClassFile does not represent an inner class.
See Also:   ClassFile.isInnerClass()



getRuntimeInvisibleAnnotations
public Annotation[] getRuntimeInvisibleAnnotations()(Code)
Returns all the runtime invisible annotations defined for this class file, or an empty array if none.



getRuntimeVisibleAnnotations
public Annotation[] getRuntimeVisibleAnnotations()(Code)
Returns all the runtime visible annotations defined for this class file, or an empty array if none.



getSignatureAttr
public SignatureAttr getSignatureAttr()(Code)
Returns the signature attribute of this classfile, or null if none is defined.



getSourceFile
public String getSourceFile()(Code)
Returns the source file of this class file or null if not set.



getSuperClassName
public String getSuperClassName()(Code)



getTarget
public String getTarget()(Code)
Returns the target virtual machine version, or null if unknown.



getType
public TypeDesc getType()(Code)
Returns a TypeDesc for the type of this ClassFile.



isDeprecated
public boolean isDeprecated()(Code)



isInnerClass
public boolean isInnerClass()(Code)
Returns true if this ClassFile represents an inner class.



isSynthetic
public boolean isSynthetic()(Code)



markDeprecated
public void markDeprecated()(Code)
Mark this class as being deprecated by adding a special attribute.



markSynthetic
public void markSynthetic()(Code)
Mark this class as being synthetic by adding a special attribute.



readFrom
public static ClassFile readFrom(InputStream in) throws IOException(Code)
Reads a ClassFile from the given InputStream. With this method, inner classes cannot be loaded, and custom attributes cannot be defined.
Parameters:
  in - source of class file data
throws:
  IOException - for I/O error or if classfile is invalid.
throws:
  ArrayIndexOutOfBoundsException - if a constant pool index is outof range.
throws:
  ClassCastException - if a constant pool index references thewrong type.



readFrom
public static ClassFile readFrom(DataInput din) throws IOException(Code)
Reads a ClassFile from the given DataInput. With this method, inner classes cannot be loaded, and custom attributes cannot be defined.
Parameters:
  din - source of class file data
throws:
  IOException - for I/O error or if classfile is invalid.
throws:
  ArrayIndexOutOfBoundsException - if a constant pool index is outof range.
throws:
  ClassCastException - if a constant pool index references thewrong type.



readFrom
public static ClassFile readFrom(InputStream in, ClassFileDataLoader loader, AttributeFactory attrFactory) throws IOException(Code)
Reads a ClassFile from the given InputStream. A ClassFileDataLoader may be provided, which allows inner class definitions to be loaded. Also, an AttributeFactory may be provided, which allows non-standard attributes to be read. All remaining unknown attribute types are captured, but are not decoded.
Parameters:
  in - source of class file data
Parameters:
  loader - optional loader for reading inner class definitions
Parameters:
  attrFactory - optional factory for reading custom attributes
throws:
  IOException - for I/O error or if classfile is invalid.
throws:
  ArrayIndexOutOfBoundsException - if a constant pool index is outof range.
throws:
  ClassCastException - if a constant pool index references thewrong type.



readFrom
public static ClassFile readFrom(DataInput din, ClassFileDataLoader loader, AttributeFactory attrFactory) throws IOException(Code)
Reads a ClassFile from the given DataInput. A ClassFileDataLoader may be provided, which allows inner class definitions to be loaded. Also, an AttributeFactory may be provided, which allows non-standard attributes to be read. All remaining unknown attribute types are captured, but are not decoded.
Parameters:
  din - source of class file data
Parameters:
  loader - optional loader for reading inner class definitions
Parameters:
  attrFactory - optional factory for reading custom attributes
throws:
  IOException - for I/O error or if classfile is invalid.
throws:
  ArrayIndexOutOfBoundsException - if a constant pool index is outof range.
throws:
  ClassCastException - if a constant pool index references thewrong type.



setModifiers
public void setModifiers(Modifiers modifiers)(Code)



setSourceFile
public void setSourceFile(String fileName)(Code)
Set the source file of this class file by adding a source file attribute. The source doesn't actually have to be a file, but the virtual machine spec names the attribute "SourceFile_attribute".



setTarget
public void setTarget(String target) throws IllegalArgumentException(Code)
Specify what target virtual machine version classfile should generate for. Calling this method changes the major and minor version of the classfile format.
Parameters:
  target - VM version, 1.0, 1.1, etc.
throws:
  IllegalArgumentException - if target is not supported



setVersion
public void setVersion(int major, int minor)(Code)
Sets the version to use when writing the generated classfile, overriding the target.



toString
public String toString()(Code)



writeTo
public void writeTo(OutputStream out) throws IOException(Code)
Writes the ClassFile to the given OutputStream.



writeTo
public void writeTo(DataOutput dout) throws IOException(Code)
Writes the ClassFile to the given DataOutput.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.