Java Doc for ClassFileWriter.java in  » Scripting » rhino » org » mozilla » 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 » Scripting » rhino » org.mozilla.classfile 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.mozilla.classfile.ClassFileWriter

ClassFileWriter
public class ClassFileWriter (Code)
ClassFileWriter A ClassFileWriter is used to write a Java class file. Methods are provided to create fields and methods, and within methods to write Java bytecodes.
author:
   Roger Lawrence

Inner Class :public static class ClassFileFormatException extends RuntimeException

Field Summary
final public static  shortACC_PUBLICACC_PRIVATEACC_PROTECTEDACC_STATICACC_FINALACC_SYNCHRONIZEDACC_VOLATILEACC_TRANSIENTACC_NATIVEACC_ABSTRACT
    

Constructor Summary
public  ClassFileWriter(String className, String superClassName, String sourceFileName)
     Construct a ClassFileWriter for a class.

Method Summary
public  intacquireLabel()
    
public  voidadd(int theOpCode)
     Add the single-byte opcode to the current method.
public  voidadd(int theOpCode, int theOperand)
     Add a single-operand opcode to the current method.
public  voidadd(int theOpCode, int theOperand1, int theOperand2)
     Add the given two-operand bytecode to the current method.
public  voidadd(int theOpCode, String className)
    
public  voidadd(int theOpCode, String className, String fieldName, String fieldType)
    
public  voidaddALoad(int local)
     Load object from the given local into stack.
public  voidaddAStore(int local)
     Store object from stack top into the given local.
public  voidaddDLoad(int local)
     Load double from the given local into stack.
public  voidaddDStore(int local)
     Store double from stack top into the given local.
public  voidaddExceptionHandler(int startLabel, int endLabel, int handlerLabel, String catchClassName)
    
public  voidaddFLoad(int local)
     Load float from the given local into stack.
public  voidaddFStore(int local)
     Store float from stack top into the given local.
public  voidaddField(String fieldName, String type, short flags)
     Add a field to the class.
public  voidaddField(String fieldName, String type, short flags, int value)
     Add a field to the class.
public  voidaddField(String fieldName, String type, short flags, long value)
     Add a field to the class.
public  voidaddField(String fieldName, String type, short flags, double value)
     Add a field to the class.
public  voidaddILoad(int local)
     Load integer from the given local into stack.
public  voidaddIStore(int local)
     Store integer from stack top into the given local.
public  voidaddInterface(String interfaceName)
     Add an interface implemented by this class.
public  voidaddInvoke(int theOpCode, String className, String methodName, String methodType)
    
public  voidaddLLoad(int local)
     Load long from the given local into stack.
public  voidaddLStore(int local)
     Store long from stack top into the given local.
public  voidaddLineNumberEntry(short lineNumber)
    
public  voidaddLoadConstant(int k)
     Generate the load constant bytecode for the given integer.
public  voidaddLoadConstant(long k)
     Generate the load constant bytecode for the given long.
public  voidaddLoadConstant(float k)
     Generate the load constant bytecode for the given float.
public  voidaddLoadConstant(double k)
     Generate the load constant bytecode for the given double.
public  voidaddLoadConstant(String k)
     Generate the load constant bytecode for the given string.
public  voidaddLoadThis()
     Load "this" into stack.
public  voidaddPush(int k)
     Generate code to load the given integer on stack.
public  voidaddPush(boolean k)
    
public  voidaddPush(long k)
     Generate code to load the given long on stack.
public  voidaddPush(double k)
     Generate code to load the given double on stack.
public  voidaddPush(String k)
    
public  intaddTableSwitch(int low, int high)
    
public  voidaddVariableDescriptor(String name, String type, int startPC, int register)
     Add Information about java variable to use when generating the local variable table.
public  voidadjustStackTop(int delta)
    
public static  StringclassNameToSignature(String name)
     Convert Java class name in dot notation into "Lname-with-dots-replaced-by-slashes;" form suitable for use as JVM type signatures.
final  char[]getCharBuffer(int minimalSize)
    
final public  StringgetClassName()
    
public  intgetCurrentCodeOffset()
     Get the current offset into the code of the current method.
static  StringgetSlashedForm(String name)
    
public  shortgetStackTop()
    
public  booleanisUnderStringSizeLimit(String k)
     Check if k fits limit on string constant size imposed by class file format.
public  voidmarkHandler(int theLabel)
    
public  voidmarkLabel(int label)
    
public  voidmarkLabel(int label, short stackTop)
    
final public  voidmarkTableSwitchCase(int switchStart, int caseIndex)
    
final public  voidmarkTableSwitchCase(int switchStart, int caseIndex, int stackTop)
    
final public  voidmarkTableSwitchDefault(int switchStart)
    
static  intopcodeCount(int opcode)
     Number of operands accompanying the opcode.
static  intputInt16(int value, byte[] array, int offset)
    
static  intputInt32(int value, byte[] array, int offset)
    
static  intputInt64(long value, byte[] array, int offset)
    
public  voidsetFlags(short flags)
     Set the class's flags.
public  voidsetStackTop(short n)
    
public  voidsetTableSwitchJump(int switchStart, int caseIndex, int jumpTarget)
    
static  intstackChange(int opcode)
     The effect on the operand stack of a given opcode.
public  voidstartMethod(String methodName, String type, short flags)
     Add a method and begin adding code. This method must be called before other methods for adding code, exception tables, etc.
public  voidstopMethod(short maxLocals)
     Complete generation of the method. After this method is called, no more code can be added to the method begun with startMethod.
Parameters:
  maxLocals - the maximum number of local variable slots(a.k.a.
public  byte[]toByteArray()
     Get the class file as array of bytesto the OutputStream.
public  voidwrite(OutputStream oStream)
     Write the class file to the OutputStream.

Field Detail
ACC_PUBLICACC_PRIVATEACC_PROTECTEDACC_STATICACC_FINALACC_SYNCHRONIZEDACC_VOLATILEACC_TRANSIENTACC_NATIVEACC_ABSTRACT
final public static short ACC_PUBLICACC_PRIVATEACC_PROTECTEDACC_STATICACC_FINALACC_SYNCHRONIZEDACC_VOLATILEACC_TRANSIENTACC_NATIVEACC_ABSTRACT(Code)




Constructor Detail
ClassFileWriter
public ClassFileWriter(String className, String superClassName, String sourceFileName)(Code)
Construct a ClassFileWriter for a class.
Parameters:
  className - the name of the class to write, includingfull package qualification.
Parameters:
  superClassName - the name of the superclass of the classto write, including full package qualification.
Parameters:
  sourceFileName - the name of the source file to use forproducing debug information, or null if debug informationis not desired




Method Detail
acquireLabel
public int acquireLabel()(Code)



add
public void add(int theOpCode)(Code)
Add the single-byte opcode to the current method.
Parameters:
  theOpCode - the opcode of the bytecode



add
public void add(int theOpCode, int theOperand)(Code)
Add a single-operand opcode to the current method.
Parameters:
  theOpCode - the opcode of the bytecode
Parameters:
  theOperand - the operand of the bytecode



add
public void add(int theOpCode, int theOperand1, int theOperand2)(Code)
Add the given two-operand bytecode to the current method.
Parameters:
  theOpCode - the opcode of the bytecode
Parameters:
  theOperand1 - the first operand of the bytecode
Parameters:
  theOperand2 - the second operand of the bytecode



add
public void add(int theOpCode, String className)(Code)



add
public void add(int theOpCode, String className, String fieldName, String fieldType)(Code)



addALoad
public void addALoad(int local)(Code)
Load object from the given local into stack.
Parameters:
  local - number of local register



addAStore
public void addAStore(int local)(Code)
Store object from stack top into the given local.
Parameters:
  local - number of local register



addDLoad
public void addDLoad(int local)(Code)
Load double from the given local into stack.
Parameters:
  local - number of local register



addDStore
public void addDStore(int local)(Code)
Store double from stack top into the given local.
Parameters:
  local - number of local register



addExceptionHandler
public void addExceptionHandler(int startLabel, int endLabel, int handlerLabel, String catchClassName)(Code)



addFLoad
public void addFLoad(int local)(Code)
Load float from the given local into stack.
Parameters:
  local - number of local register



addFStore
public void addFStore(int local)(Code)
Store float from stack top into the given local.
Parameters:
  local - number of local register



addField
public void addField(String fieldName, String type, short flags)(Code)
Add a field to the class.
Parameters:
  fieldName - the name of the field
Parameters:
  type - the type of the field using ...
Parameters:
  flags - the attributes of the field, such as ACC_PUBLIC, etc.bitwise or'd together



addField
public void addField(String fieldName, String type, short flags, int value)(Code)
Add a field to the class.
Parameters:
  fieldName - the name of the field
Parameters:
  type - the type of the field using ...
Parameters:
  flags - the attributes of the field, such as ACC_PUBLIC, etc.bitwise or'd together
Parameters:
  value - an initial integral value



addField
public void addField(String fieldName, String type, short flags, long value)(Code)
Add a field to the class.
Parameters:
  fieldName - the name of the field
Parameters:
  type - the type of the field using ...
Parameters:
  flags - the attributes of the field, such as ACC_PUBLIC, etc.bitwise or'd together
Parameters:
  value - an initial long value



addField
public void addField(String fieldName, String type, short flags, double value)(Code)
Add a field to the class.
Parameters:
  fieldName - the name of the field
Parameters:
  type - the type of the field using ...
Parameters:
  flags - the attributes of the field, such as ACC_PUBLIC, etc.bitwise or'd together
Parameters:
  value - an initial double value



addILoad
public void addILoad(int local)(Code)
Load integer from the given local into stack.
Parameters:
  local - number of local register



addIStore
public void addIStore(int local)(Code)
Store integer from stack top into the given local.
Parameters:
  local - number of local register



addInterface
public void addInterface(String interfaceName)(Code)
Add an interface implemented by this class. This method may be called multiple times for classes that implement multiple interfaces.
Parameters:
  interfaceName - a name of an interface implementedby the class being written, including full packagequalification.



addInvoke
public void addInvoke(int theOpCode, String className, String methodName, String methodType)(Code)



addLLoad
public void addLLoad(int local)(Code)
Load long from the given local into stack.
Parameters:
  local - number of local register



addLStore
public void addLStore(int local)(Code)
Store long from stack top into the given local.
Parameters:
  local - number of local register



addLineNumberEntry
public void addLineNumberEntry(short lineNumber)(Code)



addLoadConstant
public void addLoadConstant(int k)(Code)
Generate the load constant bytecode for the given integer.
Parameters:
  k - the constant



addLoadConstant
public void addLoadConstant(long k)(Code)
Generate the load constant bytecode for the given long.
Parameters:
  k - the constant



addLoadConstant
public void addLoadConstant(float k)(Code)
Generate the load constant bytecode for the given float.
Parameters:
  k - the constant



addLoadConstant
public void addLoadConstant(double k)(Code)
Generate the load constant bytecode for the given double.
Parameters:
  k - the constant



addLoadConstant
public void addLoadConstant(String k)(Code)
Generate the load constant bytecode for the given string.
Parameters:
  k - the constant



addLoadThis
public void addLoadThis()(Code)
Load "this" into stack.



addPush
public void addPush(int k)(Code)
Generate code to load the given integer on stack.
Parameters:
  k - the constant



addPush
public void addPush(boolean k)(Code)



addPush
public void addPush(long k)(Code)
Generate code to load the given long on stack.
Parameters:
  k - the constant



addPush
public void addPush(double k)(Code)
Generate code to load the given double on stack.
Parameters:
  k - the constant



addPush
public void addPush(String k)(Code)
Generate the code to leave on stack the given string even if the string encoding exeeds the class file limit for single string constant
Parameters:
  k - the constant



addTableSwitch
public int addTableSwitch(int low, int high)(Code)



addVariableDescriptor
public void addVariableDescriptor(String name, String type, int startPC, int register)(Code)
Add Information about java variable to use when generating the local variable table.
Parameters:
  name - variable name.
Parameters:
  type - variable type as bytecode descriptor string.
Parameters:
  startPC - the starting bytecode PC where this variable is live,or -1 if it does not have a Java register.
Parameters:
  register - the Java register number of variableor -1 if it does not have a Java register.



adjustStackTop
public void adjustStackTop(int delta)(Code)



classNameToSignature
public static String classNameToSignature(String name)(Code)
Convert Java class name in dot notation into "Lname-with-dots-replaced-by-slashes;" form suitable for use as JVM type signatures.



getCharBuffer
final char[] getCharBuffer(int minimalSize)(Code)



getClassName
final public String getClassName()(Code)



getCurrentCodeOffset
public int getCurrentCodeOffset()(Code)
Get the current offset into the code of the current method. an integer representing the offset



getSlashedForm
static String getSlashedForm(String name)(Code)



getStackTop
public short getStackTop()(Code)



isUnderStringSizeLimit
public boolean isUnderStringSizeLimit(String k)(Code)
Check if k fits limit on string constant size imposed by class file format.
Parameters:
  k - the string constant



markHandler
public void markHandler(int theLabel)(Code)



markLabel
public void markLabel(int label)(Code)



markLabel
public void markLabel(int label, short stackTop)(Code)



markTableSwitchCase
final public void markTableSwitchCase(int switchStart, int caseIndex)(Code)



markTableSwitchCase
final public void markTableSwitchCase(int switchStart, int caseIndex, int stackTop)(Code)



markTableSwitchDefault
final public void markTableSwitchDefault(int switchStart)(Code)



opcodeCount
static int opcodeCount(int opcode)(Code)
Number of operands accompanying the opcode.



putInt16
static int putInt16(int value, byte[] array, int offset)(Code)



putInt32
static int putInt32(int value, byte[] array, int offset)(Code)



putInt64
static int putInt64(long value, byte[] array, int offset)(Code)



setFlags
public void setFlags(short flags)(Code)
Set the class's flags. Flags must be a set of the following flags, bitwise or'd together: ACC_PUBLIC ACC_PRIVATE ACC_PROTECTED ACC_FINAL ACC_ABSTRACT TODO: check that this is the appropriate set
Parameters:
  flags - the set of class flags to set



setStackTop
public void setStackTop(short n)(Code)



setTableSwitchJump
public void setTableSwitchJump(int switchStart, int caseIndex, int jumpTarget)(Code)



stackChange
static int stackChange(int opcode)(Code)
The effect on the operand stack of a given opcode.



startMethod
public void startMethod(String methodName, String type, short flags)(Code)
Add a method and begin adding code. This method must be called before other methods for adding code, exception tables, etc. can be invoked.
Parameters:
  methodName - the name of the method
Parameters:
  type - a string representing the type
Parameters:
  flags - the attributes of the field, such as ACC_PUBLIC, etc.bitwise or'd together



stopMethod
public void stopMethod(short maxLocals)(Code)
Complete generation of the method. After this method is called, no more code can be added to the method begun with startMethod.
Parameters:
  maxLocals - the maximum number of local variable slots(a.k.a. Java registers) used by the method



toByteArray
public byte[] toByteArray()(Code)
Get the class file as array of bytesto the OutputStream.



write
public void write(OutputStream oStream) throws IOException(Code)
Write the class file to the OutputStream.
Parameters:
  oStream - the stream to write to
throws:
  IOException - if writing to the stream produces an exception



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.