Java Doc for CodeIterator.java in  » Byte-Code » Javassist » javassist » bytecode » 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 » Javassist » javassist.bytecode 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javassist.bytecode.CodeIterator

CodeIterator
public class CodeIterator implements Opcode(Code)
An iterator for editing a code attribute.

If there are multiple CodeIterators referring to the same Code_attribute, then inserting a gap by one CodeIterator will break the other CodeIterator.

This iterator does not provide remove(). If a piece of code in a Code_attribute is unnecessary, it should be overwritten with NOP.
See Also:   CodeAttribute.iterator



Field Summary
protected  byte[]bytecode
    
protected  CodeAttributecodeAttr
    
protected  intcurrentPos
    
protected  intendPos
    

Constructor Summary
protected  CodeIterator(CodeAttribute ca)
    

Method Summary
public  intappend(byte[] code)
     Appends the given bytecode sequence at the end.
Parameters:
  code - the bytecode appended.
public  voidappend(ExceptionTable et, int offset)
     Copies and appends the entries in the given exception table at the end of the exception table in the code attribute edited by this object.
public  voidappendGap(int gapLength)
     Appends a gap at the end of the bytecode sequence.
public  voidbegin()
     Moves to the first instruction.
public  intbyteAt(int index)
     Returns the unsigned 8bit value at the given index.
public  CodeAttributeget()
     Returns a Code attribute read with this iterator.
public  intgetCodeLength()
     Returns code_length of Code_attribute.
public  booleanhasNext()
     Returns true if there is more instructions.
public  intinsert(byte[] code)
     Inserts the given bytecode sequence before the next instruction that would be returned by next() (not before the instruction returned by tha last call to next()). Branch offsets and the exception table are also updated.

If the next instruction is at the beginning of a block statement, then the bytecode is inserted within that block.

An extra gap may be inserted at the end of the inserted bytecode sequence for adjusting alignment if the code attribute includes LOOKUPSWITCH or TABLESWITCH.
Parameters:
  code - inserted bytecode sequence.

public  voidinsert(int pos, byte[] code)
     Inserts the given bytecode sequence before the instruction at the given index pos.
public  voidinsert(ExceptionTable et, int offset)
     Copies and inserts the entries in the given exception table at the beginning of the exception table in the code attribute edited by this object.
public  intinsertEx(byte[] code)
     Inserts the given bytecode sequence exclusively before the next instruction that would be returned by next() (not before the instruction returned by tha last call to next()). Branch offsets and the exception table are also updated.

If the next instruction is at the beginning of a block statement, then the bytecode is excluded from that block.

An extra gap may be inserted at the end of the inserted bytecode sequence for adjusting alignment if the code attribute includes LOOKUPSWITCH or TABLESWITCH.
Parameters:
  code - inserted bytecode sequence.

public  voidinsertEx(int pos, byte[] code)
     Inserts the given bytecode sequence exclusively before the instruction at the given index pos.
public  intinsertExGap(int length)
     Inserts an exclusive gap before the next instruction that would be returned by next() (not before the instruction returned by tha last call to next()). Branch offsets and the exception table are also updated. The inserted gap is filled with NOP.
public  intinsertExGap(int pos, int length)
     Inserts an exclusive gap in front of the instruction at the given index pos. Branch offsets and the exception table are also updated. The inserted gap is filled with NOP.
public  intinsertGap(int length)
     Inserts a gap before the next instruction that would be returned by next() (not before the instruction returned by tha last call to next()). Branch offsets and the exception table are also updated. The inserted gap is filled with NOP.
public  intinsertGap(int pos, int length)
     Inserts a gap in front of the instruction at the given index pos. Branch offsets and the exception table are also updated. The inserted gap is filled with NOP.
static  byte[]insertGap(byte[] code, int where, int gapLength, boolean exclusive, ExceptionTable etable, CodeAttribute ca)
    
public  intlookAhead()
     Obtains the value that the next call to next() will return.
public  voidmove(int index)
     Moves to the given index.
public  intnext()
     Returns the index of the next instruction (not the operand following the current opcode).
static  intnextOpcode(byte[] code, int index)
     Calculates the index of the next opcode.
public  ints16bitAt(int index)
     Returns the signed 16bit value at the given index.
public  ints32bitAt(int index)
     Returns the signed 32bit value at the given index.
public  intskipConstructor()
     Moves to the instruction for either super() or this().
public  intskipSuperConstructor()
     Moves to the instruction for super().
public  intskipThisConstructor()
     Moves to the instruction for this().
public  intu16bitAt(int index)
     Returns the unsigned 16bit value at the given index.
protected  voidupdateCursors(int pos, int length)
     Is called when a gap is inserted.
public  voidwrite(byte[] code, int index)
     Writes a byte array at the index.
public  voidwrite16bit(int value, int index)
     Writes a 16 bit integer at the index.
public  voidwrite32bit(int value, int index)
     Writes a 32bit integer at the index.
public  voidwriteByte(int value, int index)
     Writes an 8bit value at the given index.

Field Detail
bytecode
protected byte[] bytecode(Code)



codeAttr
protected CodeAttribute codeAttr(Code)



currentPos
protected int currentPos(Code)



endPos
protected int endPos(Code)




Constructor Detail
CodeIterator
protected CodeIterator(CodeAttribute ca)(Code)




Method Detail
append
public int append(byte[] code)(Code)
Appends the given bytecode sequence at the end.
Parameters:
  code - the bytecode appended. the position of the first byte of the appended bytecode.



append
public void append(ExceptionTable et, int offset)(Code)
Copies and appends the entries in the given exception table at the end of the exception table in the code attribute edited by this object.
Parameters:
  offset - the value added to the code positions includedin the entries.



appendGap
public void appendGap(int gapLength)(Code)
Appends a gap at the end of the bytecode sequence.
Parameters:
  gapLength - gap length



begin
public void begin()(Code)
Moves to the first instruction.



byteAt
public int byteAt(int index)(Code)
Returns the unsigned 8bit value at the given index.



get
public CodeAttribute get()(Code)
Returns a Code attribute read with this iterator.



getCodeLength
public int getCodeLength()(Code)
Returns code_length of Code_attribute.



hasNext
public boolean hasNext()(Code)
Returns true if there is more instructions.



insert
public int insert(byte[] code) throws BadBytecode(Code)
Inserts the given bytecode sequence before the next instruction that would be returned by next() (not before the instruction returned by tha last call to next()). Branch offsets and the exception table are also updated.

If the next instruction is at the beginning of a block statement, then the bytecode is inserted within that block.

An extra gap may be inserted at the end of the inserted bytecode sequence for adjusting alignment if the code attribute includes LOOKUPSWITCH or TABLESWITCH.
Parameters:
  code - inserted bytecode sequence. the index indicating the first byte of theinserted byte sequence.




insert
public void insert(int pos, byte[] code) throws BadBytecode(Code)
Inserts the given bytecode sequence before the instruction at the given index pos. Branch offsets and the exception table are also updated.

If the instruction at the given index is at the beginning of a block statement, then the bytecode is inserted within that block.

An extra gap may be inserted at the end of the inserted bytecode sequence for adjusting alignment if the code attribute includes LOOKUPSWITCH or TABLESWITCH.
Parameters:
  pos - the index at which a byte sequence is inserted.
Parameters:
  code - inserted bytecode sequence.




insert
public void insert(ExceptionTable et, int offset)(Code)
Copies and inserts the entries in the given exception table at the beginning of the exception table in the code attribute edited by this object.
Parameters:
  offset - the value added to the code positions includedin the entries.



insertEx
public int insertEx(byte[] code) throws BadBytecode(Code)
Inserts the given bytecode sequence exclusively before the next instruction that would be returned by next() (not before the instruction returned by tha last call to next()). Branch offsets and the exception table are also updated.

If the next instruction is at the beginning of a block statement, then the bytecode is excluded from that block.

An extra gap may be inserted at the end of the inserted bytecode sequence for adjusting alignment if the code attribute includes LOOKUPSWITCH or TABLESWITCH.
Parameters:
  code - inserted bytecode sequence. the index indicating the first byte of theinserted byte sequence.




insertEx
public void insertEx(int pos, byte[] code) throws BadBytecode(Code)
Inserts the given bytecode sequence exclusively before the instruction at the given index pos. Branch offsets and the exception table are also updated.

If the instruction at the given index is at the beginning of a block statement, then the bytecode is excluded from that block.

An extra gap may be inserted at the end of the inserted bytecode sequence for adjusting alignment if the code attribute includes LOOKUPSWITCH or TABLESWITCH.
Parameters:
  pos - the index at which a byte sequence is inserted.
Parameters:
  code - inserted bytecode sequence.




insertExGap
public int insertExGap(int length) throws BadBytecode(Code)
Inserts an exclusive gap before the next instruction that would be returned by next() (not before the instruction returned by tha last call to next()). Branch offsets and the exception table are also updated. The inserted gap is filled with NOP. The gap length may be extended to a multiple of 4.

If the next instruction is at the beginning of a block statement, then the gap is excluded from that block.
Parameters:
  length - gap length the index indicating the first byte of the inserted gap.




insertExGap
public int insertExGap(int pos, int length) throws BadBytecode(Code)
Inserts an exclusive gap in front of the instruction at the given index pos. Branch offsets and the exception table are also updated. The inserted gap is filled with NOP. The gap length may be extended to a multiple of 4.

If the instruction at the given index is at the beginning of a block statement, then the gap is excluded from that block.
Parameters:
  pos - the index at which a gap is inserted.
Parameters:
  length - gap length. the length of the inserted gap.It might be bigger than length.




insertGap
public int insertGap(int length) throws BadBytecode(Code)
Inserts a gap before the next instruction that would be returned by next() (not before the instruction returned by tha last call to next()). Branch offsets and the exception table are also updated. The inserted gap is filled with NOP. The gap length may be extended to a multiple of 4.

If the next instruction is at the beginning of a block statement, then the gap is inserted within that block.
Parameters:
  length - gap length the index indicating the first byte of the inserted gap.




insertGap
public int insertGap(int pos, int length) throws BadBytecode(Code)
Inserts a gap in front of the instruction at the given index pos. Branch offsets and the exception table are also updated. The inserted gap is filled with NOP. The gap length may be extended to a multiple of 4.

If the instruction at the given index is at the beginning of a block statement, then the gap is inserted within that block.
Parameters:
  pos - the index at which a gap is inserted.
Parameters:
  length - gap length. the length of the inserted gap.It might be bigger than length.




insertGap
static byte[] insertGap(byte[] code, int where, int gapLength, boolean exclusive, ExceptionTable etable, CodeAttribute ca) throws BadBytecode(Code)



lookAhead
public int lookAhead()(Code)
Obtains the value that the next call to next() will return.

This method is side-effects free. Successive calls to lookAhead() return the same value until next() is called.




move
public void move(int index)(Code)
Moves to the given index.

The index of the next instruction is set to the given index. The successive call to next() returns the index that has been given to move().

Note that the index is into the byte array returned by get().getCode().
See Also:   CodeAttribute.getCode




next
public int next() throws BadBytecode(Code)
Returns the index of the next instruction (not the operand following the current opcode).

Note that the index is into the byte array returned by get().getCode().
See Also:   CodeAttribute.getCode
See Also:   CodeIterator.byteAt(int)




nextOpcode
static int nextOpcode(byte[] code, int index) throws BadBytecode(Code)
Calculates the index of the next opcode.



s16bitAt
public int s16bitAt(int index)(Code)
Returns the signed 16bit value at the given index.



s32bitAt
public int s32bitAt(int index)(Code)
Returns the signed 32bit value at the given index.



skipConstructor
public int skipConstructor() throws BadBytecode(Code)
Moves to the instruction for either super() or this().

This method skips all the instructions for computing arguments to super() or this(), which should be placed at the beginning of a constructor body.

This method returns the index of INVOKESPECIAL instruction executing super() or this(). A successive call to next() returns the index of the next instruction following that INVOKESPECIAL.

This method works only for a constructor. the index of the INVOKESPECIAL instruction, or -1if a constructor invocation is not found.




skipSuperConstructor
public int skipSuperConstructor() throws BadBytecode(Code)
Moves to the instruction for super().

This method skips all the instructions for computing arguments to super(), which should be placed at the beginning of a constructor body.

This method returns the index of INVOKESPECIAL instruction executing super(). A successive call to next() returns the index of the next instruction following that INVOKESPECIAL.

This method works only for a constructor. the index of the INVOKESPECIAL instruction, or -1if a super constructor invocation is not foundbut this() is found.




skipThisConstructor
public int skipThisConstructor() throws BadBytecode(Code)
Moves to the instruction for this().

This method skips all the instructions for computing arguments to this(), which should be placed at the beginning of a constructor body.

This method returns the index of INVOKESPECIAL instruction executing this(). A successive call to next() returns the index of the next instruction following that INVOKESPECIAL.

This method works only for a constructor. the index of the INVOKESPECIAL instruction, or -1if a explicit constructor invocation is not foundbut super() is found.




u16bitAt
public int u16bitAt(int index)(Code)
Returns the unsigned 16bit value at the given index.



updateCursors
protected void updateCursors(int pos, int length)(Code)
Is called when a gap is inserted. The default implementation is empty. A subclass can override this method so that cursors will be updated.
Parameters:
  pos - the position where a gap is inserted.
Parameters:
  length - the length of the gap.



write
public void write(byte[] code, int index)(Code)
Writes a byte array at the index.
Parameters:
  code - may be a zero-length array.



write16bit
public void write16bit(int value, int index)(Code)
Writes a 16 bit integer at the index.



write32bit
public void write32bit(int value, int index)(Code)
Writes a 32bit integer at the index.



writeByte
public void writeByte(int value, int index)(Code)
Writes an 8bit value at the given index.



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.