Class MFieldInsn
- java.lang.Object
-
- xyz.cofe.trambda.bc.mth.MAbstractBC
-
- xyz.cofe.trambda.bc.mth.MFieldInsn
-
- All Implemented Interfaces:
Serializable,xyz.cofe.collection.ImTree<ByteCode>,xyz.cofe.collection.ImTreeWalk<ByteCode>,ByteCode,MethodByteCode,MethodWriter
public class MFieldInsn extends MAbstractBC implements MethodWriter
Доступ к полю объектаthe opcode of the type instruction to be visited. This opcode is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
getstaticOperation
Get static field from classFormat
getstatic indexbyte1 indexbyte2
Forms
getstatic = 178 (0xb2)Operand Stack
..., → ..., value
Description
The unsigned indexbyte1 and indexbyte2 are used to construct an index into the run-time constant pool of the current class (§2.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The run-time constant pool item at that index must be a symbolic reference to a field (§5.1), which gives the name and descriptor of the field as well as a symbolic reference to the class or interface in which the field is to be found. The referenced field is resolved (§5.4.3.2). On successful resolution of the field, the class or interface that declared the resolved field is initialized (§5.5) if that class or interface has not already been initialized. The value of the class or interface field is fetched and pushed onto the operand stack.Linking Exceptions
During resolution of the symbolic reference to the class or interface field, any of the exceptions pertaining to field resolution (§5.4.3.2) can be thrown. Otherwise, if the resolved field is not a static (class) field or an interface field, getstatic throws an IncompatibleClassChangeError.Run-time Exception
Otherwise, if execution of this getstatic instruction causes initialization of the referenced class or interface, getstatic may throw an Error as detailed in §5.5.
putstaticOperation
Set static field in classFormat
putstatic indexbyte1 indexbyte2
Forms
putstatic = 179 (0xb3)Operand Stack
..., value → ...
Description
The unsigned indexbyte1 and indexbyte2 are used to construct an index into the run-time constant pool of the current class (§2.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The run-time constant pool item at that index must be a symbolic reference to a field (§5.1), which gives the name and descriptor of the field as well as a symbolic reference to the class or interface in which the field is to be found. The referenced field is resolved (§5.4.3.2).On successful resolution of the field, the class or interface that declared the resolved field is initialized (§5.5) if that class or interface has not already been initialized.
The type of a value stored by a putstatic instruction must be compatible with the descriptor of the referenced field (§4.3.2). If the field descriptor type is boolean, byte, char, short, or int, then the value must be an int. If the field descriptor type is float, long, or double, then the value must be a float, long, or double, respectively. If the field descriptor type is a reference type, then the value must be of a type that is assignment compatible (JLS §5.2) with the field descriptor type. If the field is final, it must be declared in the current class, and the instruction must occur in the <clinit> method of the current class (§2.9).
The value is popped from the operand stack and undergoes value set conversion (§2.8.3), resulting in value'. The class field is set to value'.
Linking Exceptions
During resolution of the symbolic reference to the class or interface field, any of the exceptions pertaining to field resolution (§5.4.3.2) can be thrown.Otherwise, if the resolved field is not a static (class) field or an interface field, putstatic throws an IncompatibleClassChangeError.
Otherwise, if the field is final, it must be declared in the current class, and the instruction must occur in the <clinit> method of the current class. Otherwise, an IllegalAccessError is thrown.
Run-time Exception
Otherwise, if execution of this putstatic instruction causes initialization of the referenced class or interface, putstatic may throw an Error as detailed in §5.5.Notes
A putstatic instruction may be used only to set the value of an interface field on the initialization of that field. Interface fields may be assigned to only once, on execution of an interface variable initialization expression when the interface is initialized (§5.5, JLS §9.3.1).
getfieldOperation
Fetch field from objectFormat
getfield indexbyte1 indexbyte2
Forms
getfield = 180 (0xb4)Operand Stack
..., objectref → ..., value
Description
The objectref, which must be of type reference, is popped from the operand stack. The unsigned indexbyte1 and indexbyte2 are used to construct an index into the run-time constant pool of the current class (§2.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The run-time constant pool item at that index must be a symbolic reference to a field (§5.1), which gives the name and descriptor of the field as well as a symbolic reference to the class in which the field is to be found. The referenced field is resolved (§5.4.3.2). The value of the referenced field in objectref is fetched and pushed onto the operand stack. The type of objectref must not be an array type. If the field is protected, and it is a member of a superclass of the current class, and the field is not declared in the same run-time package (§5.3) as the current class, then the class of objectref must be either the current class or a subclass of the current class.Linking Exceptions
During resolution of the symbolic reference to the field, any of the errors pertaining to field resolution (§5.4.3.2) can be thrown. Otherwise, if the resolved field is a static field, getfield throws an IncompatibleClassChangeError.Run-time Exception
Otherwise, if objectref is null, the getfield instruction throws a NullPointerException.Notes
The getfield instruction cannot be used to access the length field of an array. The arraylength instruction (§arraylength) is used instead.
putfieldOperation
Set field in objectFormat
putfield indexbyte1 indexbyte2
Forms
putfield = 181 (0xb5)Operand Stack
..., objectref, value → ...
Description
The unsigned indexbyte1 and indexbyte2 are used to construct an index into the run-time constant pool of the current class (§2.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The run-time constant pool item at that index must be a symbolic reference to a field (§5.1), which gives the name and descriptor of the field as well as a symbolic reference to the class in which the field is to be found. The class of objectref must not be an array. If the field is protected, and it is a member of a superclass of the current class, and the field is not declared in the same run-time package (§5.3) as the current class, then the class of objectref must be either the current class or a subclass of the current class.The referenced field is resolved (§5.4.3.2). The type of a value stored by a putfield instruction must be compatible with the descriptor of the referenced field (§4.3.2). If the field descriptor type is boolean, byte, char, short, or int, then the value must be an int. If the field descriptor type is float, long, or double, then the value must be a float, long, or double, respectively. If the field descriptor type is a reference type, then the value must be of a type that is assignment compatible (JLS §5.2) with the field descriptor type. If the field is final, it must be declared in the current class, and the instruction must occur in an instance initialization method (<init>) of the current class (§2.9).
The value and objectref are popped from the operand stack. The objectref must be of type reference. The value undergoes value set conversion (§2.8.3), resulting in value', and the referenced field in objectref is set to value'.
Linking Exceptions
During resolution of the symbolic reference to the field, any of the exceptions pertaining to field resolution (§5.4.3.2) can be thrown.Otherwise, if the resolved field is a static field, putfield throws an IncompatibleClassChangeError.
Otherwise, if the field is final, it must be declared in the current class, and the instruction must occur in an instance initialization method (<init>) of the current class. Otherwise, an IllegalAccessError is thrown.
Run-time Exception
Otherwise, if objectref is null, the putfield instruction throws a NullPointerException.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MFieldInsn()Конструктор по умолчаниюMFieldInsn(int opcode, String owner, String name, String descriptor)MFieldInsn(MFieldInsn sample)Конструктор копирования
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MFieldInsnclone()StringgetDescriptor()StringgetName()intgetOpcode()StringgetOwner()voidsetDescriptor(String descriptor)voidsetName(String name)voidsetOpcode(int opcode)voidsetOwner(String owner)StringtoString()voidwrite(org.objectweb.asm.MethodVisitor v, MethodWriterCtx ctx)
-
-
-
Constructor Detail
-
MFieldInsn
public MFieldInsn()
Конструктор по умолчанию
-
MFieldInsn
public MFieldInsn(MFieldInsn sample)
Конструктор копирования- Parameters:
sample- образец
-
-
Method Detail
-
clone
public MFieldInsn clone()
- Specified by:
clonein interfaceMethodByteCode- Specified by:
clonein classMAbstractBC
-
getOpcode
public int getOpcode()
-
setOpcode
public void setOpcode(int opcode)
-
getOwner
public String getOwner()
-
setOwner
public void setOwner(String owner)
-
getName
public String getName()
-
setName
public void setName(String name)
-
getDescriptor
public String getDescriptor()
-
setDescriptor
public void setDescriptor(String descriptor)
-
write
public void write(org.objectweb.asm.MethodVisitor v, MethodWriterCtx ctx)- Specified by:
writein interfaceMethodWriter
-
-