Top Description Fields Constructors Methods
org.apache.commons.compress.harmony.unpack200.bytecode

public Class ByteCode

extends ClassFileEntry
Class Inheritance
Imports
java.io.DataOutputStream, .IOException, org.apache.commons.compress.harmony.unpack200.Segment, org.apache.commons.compress.harmony.unpack200.bytecode.forms.ByteCodeForm

A bytecode class file entry.

Field Summary

Modifier and TypeField and Description
private final ByteCodeForm
private int
private int[]
private ClassFileEntry[]
private int[][]
private static ByteCode[]
private int[]
Inherited from org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry:
NONE

Constructor Summary

AccessConstructor and Description
protected
ByteCode(final int opcode)

protected
ByteCode(final int opcode, final ClassFileEntry[] nested)

Method Summary

Modifier and TypeMethod and Description
public void
applyByteCodeTargetFixup(final CodeAttribute
the code attribute
codeAttribute
)

Some ByteCodes (in particular, those with labels need to be fixed up after all the bytecodes in the CodeAttribute have been added.

protected void
public boolean
equals(final Object
the reference object with which to compare.
obj
)

Implements abstract org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry.equals.

Indicates whether some other object is "equal to" this one.
public void
extractOperands(final OperandManager operandManager, final Segment segment, final int codeLength)

public static ByteCode
getByteCode(final int opcode)

protected ByteCodeForm
public int
public int[]
public int
public String
public ClassFileEntry[]
public int[]
getNestedPosition(final int index)

public int[][]
public int
public int[]

Returns:

Some bytecodes.
getRewrite
()

Some bytecodes (the ones with variable lengths) can't have a static rewrite array - they need the ability to update the array.

public int
hashCode()

Implements abstract org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry.hashCode.

Returns a hash code value for the object.
public boolean

Returns:

boolean true if multibytecode, false otherwise
hasMultipleByteCodes
()

This method will answer true if the receiver is a multi-bytecode instruction (such as aload0_putfield_super); otherwise, it will answer false.

public boolean
protected void
resolve(final ClassConstantPool
TODO
pool
)

Overrides org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry.resolve.

Allows the constant pool entries to resolve their nested entries.
public void
setByteCodeIndex(final int
int position in code array.
byteCodeOffset
)

ByteCodes may need to know their position in the code array (in particular, label byte codes need to know where they are in order to calculate their targets).

public void
setByteCodeTargets(final int[]
int index in array
byteCodeTargets
)

Some ByteCodes (in particular, those with labels) have to keep track of byteCodeTargets.

public void
setNested(final ClassFileEntry[] nested)

public void
setNestedPositions(final int[][]
Each subarray specifies a position of a nested element (from the nested[] array) and the length of that element.
nestedPositions
)

nestedPositions is an array of arrays of ints.

public void
setOperand2Bytes(final int
int to set the rewrite bytes to
operand
,
final int
int position in the operands of the rewrite bytes. For a rewrite array of {100, -1, -1, -1} position 0 is the first -1, position 1 is the second -1, etc.
position
)

Given an int operand, set the rewrite bytes for that position and the one immediately following it to a high-byte, low-byte encoding of the operand.

public void
setOperandByte(final int
int to set the rewrite byte to (unsigned)
operand
,
final int
int position in the operands of the rewrite bytes. For a rewrite array of {100, -1, -1, -1} position 0 is the first -1, position 1 is the second -1, etc.
position
)

Given an int operand, treat it as a byte and set the rewrite byte for that position to that value.

public void
setOperandBytes(final int[]
int[] rewrite operand bytes
operands
)

Given an array of ints which correspond to bytes in the operand of the bytecode, set the rewrite bytes of the operand to be the appropriate values.

public void
setOperandSigned2Bytes(final int
int to set the rewrite bytes to
operand
,
final int
int position of the operands in the rewrite bytes
position
)

This is just like setOperandInt, but takes special care when the operand is less than 0 to make sure it's written correctly.

public void
setRewrite(final int[]
Some bytecodes.
rewrite
)

Some bytecodes (the ones with variable lengths) can't have a static rewrite array - they need the ability to update the array.

public String
toString()

Implements abstract org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry.toString.

Returns a string representation of the object.
Inherited from org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry:
objectHashCodewrite

Field Detail

byteCodeFormback to summary
private final ByteCodeForm byteCodeForm
byteCodeOffsetback to summary
private int byteCodeOffset
byteCodeTargetsback to summary
private int[] byteCodeTargets
nestedback to summary
private ClassFileEntry[] nested
nestedPositionsback to summary
private int[][] nestedPositions
noArgByteCodesback to summary
private static ByteCode[] noArgByteCodes
rewriteback to summary
private int[] rewrite

Constructor Detail

ByteCodeback to summary
protected ByteCode(final int opcode)
ByteCodeback to summary
protected ByteCode(final int opcode, final ClassFileEntry[] nested)

Method Detail

applyByteCodeTargetFixupback to summary
public void applyByteCodeTargetFixup(final CodeAttribute codeAttribute)

Some ByteCodes (in particular, those with labels need to be fixed up after all the bytecodes in the CodeAttribute have been added. (This can't be done beforehand because the CodeAttribute needs to be complete before targets can be assigned.)

Parameters
codeAttribute:CodeAttribute

the code attribute

doWriteback to summary
protected void doWrite(final DataOutputStream dos) throws IOException

Implements abstract org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry.doWrite.

Annotations
@Override
equalsback to summary
public boolean equals(final Object obj)

Implements abstract org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
extractOperandsback to summary
public void extractOperands(final OperandManager operandManager, final Segment segment, final int codeLength)
getByteCodeback to summary
public static ByteCode getByteCode(final int opcode)
getByteCodeFormback to summary
protected ByteCodeForm getByteCodeForm()
getByteCodeIndexback to summary
public int getByteCodeIndex()
getByteCodeTargetsback to summary
public int[] getByteCodeTargets()
getLengthback to summary
public int getLength()
getNameback to summary
public String getName()
getNestedClassFileEntriesback to summary
public ClassFileEntry[] getNestedClassFileEntries()

Overrides org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry.getNestedClassFileEntries.

Annotations
@Override
getNestedPositionback to summary
public int[] getNestedPosition(final int index)
getNestedPositionsback to summary
public int[][] getNestedPositions()
getOpcodeback to summary
public int getOpcode()
getRewriteback to summary
public int[] getRewrite()

Some bytecodes (the ones with variable lengths) can't have a static rewrite array - they need the ability to update the array. This method permits their associated bytecode formst to query their rewrite array. Note that this should not be called from bytecodes which have a static rewrite; use the table in ByteCodeForm instead to specify those rewrites.

Returns:int[]

Some bytecodes.

hashCodeback to summary
public int hashCode()

Implements abstract org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
hasMultipleByteCodesback to summary
public boolean hasMultipleByteCodes()

This method will answer true if the receiver is a multi-bytecode instruction (such as aload0_putfield_super); otherwise, it will answer false.

Returns:boolean

boolean true if multibytecode, false otherwise

nestedMustStartClassPoolback to summary
public boolean nestedMustStartClassPool()
resolveback to summary
protected void resolve(final ClassConstantPool pool)

Overrides org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry.resolve.

Doc from org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry.resolve.

Allows the constant pool entries to resolve their nested entries.

Parameters
pool:ClassConstantPool

TODO

Annotations
@Override
setByteCodeIndexback to summary
public void setByteCodeIndex(final int byteCodeOffset)

ByteCodes may need to know their position in the code array (in particular, label byte codes need to know where they are in order to calculate their targets). This method lets the CodeAttribute specify where the byte code is. Since there are no aload0+label instructions, this method doesn't worry about multioperation bytecodes.

Parameters
byteCodeOffset:int

int position in code array.

setByteCodeTargetsback to summary
public void setByteCodeTargets(final int[] byteCodeTargets)

Some ByteCodes (in particular, those with labels) have to keep track of byteCodeTargets. These are initially offsets in the CodeAttribute array relative to the byteCodeOffset, but later get fixed up to point to the absolute position in the CodeAttribute array. This method sets the targets.

Parameters
byteCodeTargets:int[]

int index in array

setNestedback to summary
public void setNested(final ClassFileEntry[] nested)
setNestedPositionsback to summary
public void setNestedPositions(final int[][] nestedPositions)

nestedPositions is an array of arrays of ints. Each subarray specifies a position of a nested element (from the nested[] array) and the length of that element. For instance, one might have a nested of: {CPClass java/lang/Foo, CPFloat 3.14} The nestedPositions would then be: {{0,2},{2,2}} In other words, when the bytecode is resolved, the CPClass will be resolved to an int and inserted at position 0 and 1 of the rewrite arguments (the first occurrences of -1). The CPFloat will be resolved to an int position and inserted at positions 2 and 3 of the rewrite arguments.

Parameters
nestedPositions:int[][]

Each subarray specifies a position of a nested element (from the nested[] array) and the length of that element.

setOperand2Bytesback to summary
public void setOperand2Bytes(final int operand, final int position)

Given an int operand, set the rewrite bytes for that position and the one immediately following it to a high-byte, low-byte encoding of the operand.

Parameters
operand:int

int to set the rewrite bytes to

position:int

int position in the operands of the rewrite bytes. For a rewrite array of {100, -1, -1, -1} position 0 is the first -1, position 1 is the second -1, etc.

setOperandByteback to summary
public void setOperandByte(final int operand, final int position)

Given an int operand, treat it as a byte and set the rewrite byte for that position to that value. Mask of anything beyond 0xFF.

Parameters
operand:int

int to set the rewrite byte to (unsigned)

position:int

int position in the operands of the rewrite bytes. For a rewrite array of {100, -1, -1, -1} position 0 is the first -1, position 1 is the second -1, etc.

setOperandBytesback to summary
public void setOperandBytes(final int[] operands)

Given an array of ints which correspond to bytes in the operand of the bytecode, set the rewrite bytes of the operand to be the appropriate values. All values in operands[] will be masked with 0xFF so they fit into a byte.

Parameters
operands:int[]

int[] rewrite operand bytes

setOperandSigned2Bytesback to summary
public void setOperandSigned2Bytes(final int operand, final int position)

This is just like setOperandInt, but takes special care when the operand is less than 0 to make sure it's written correctly.

Parameters
operand:int

int to set the rewrite bytes to

position:int

int position of the operands in the rewrite bytes

setRewriteback to summary
public void setRewrite(final int[] rewrite)

Some bytecodes (the ones with variable lengths) can't have a static rewrite array - they need the ability to update the array. This method permits that. Note that this should not be called from bytecodes which have a static rewrite; use the table in ByteCodeForm instead to specify those rewrites.

Parameters
rewrite:int[]

Some bytecodes.

toStringback to summary
public String toString()

Implements abstract org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override