本文整理汇总了Java中javassist.bytecode.CodeIterator.u16bitAt方法的典型用法代码示例。如果您正苦于以下问题:Java CodeIterator.u16bitAt方法的具体用法?Java CodeIterator.u16bitAt怎么用?Java CodeIterator.u16bitAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javassist.bytecode.CodeIterator
的用法示例。
在下文中一共展示了CodeIterator.u16bitAt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformInvokevirtualsIntoGetfields
import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
private int transformInvokevirtualsIntoGetfields(ClassFile classfile, CodeIterator iter, int pos) {
final ConstPool constPool = classfile.getConstPool();
final int c = iter.byteAt( pos );
if ( c != Opcode.GETFIELD ) {
return pos;
}
final int index = iter.u16bitAt( pos + 1 );
final String fieldName = constPool.getFieldrefName( index );
final String className = constPool.getFieldrefClassName( index );
if ( !filter.handleReadAccess( className, fieldName ) ) {
return pos;
}
final String fieldReaderMethodDescriptor = "()" + constPool.getFieldrefType( index );
final int fieldReaderMethodIndex = constPool.addMethodrefInfo(
constPool.getThisClassInfo(),
EACH_READ_METHOD_PREFIX + fieldName,
fieldReaderMethodDescriptor
);
iter.writeByte( Opcode.INVOKEVIRTUAL, pos );
iter.write16bit( fieldReaderMethodIndex, pos + 1 );
return pos;
}
示例2: transformInvokevirtualsIntoPutfields
import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
private int transformInvokevirtualsIntoPutfields(ClassFile classfile, CodeIterator iter, int pos) {
final ConstPool constPool = classfile.getConstPool();
final int c = iter.byteAt( pos );
if ( c != Opcode.PUTFIELD ) {
return pos;
}
final int index = iter.u16bitAt( pos + 1 );
final String fieldName = constPool.getFieldrefName( index );
final String className = constPool.getFieldrefClassName( index );
if ( !filter.handleWriteAccess( className, fieldName ) ) {
return pos;
}
final String fieldWriterMethodDescriptor = "(" + constPool.getFieldrefType( index ) + ")V";
final int fieldWriterMethodIndex = constPool.addMethodrefInfo(
constPool.getThisClassInfo(),
EACH_WRITE_METHOD_PREFIX + fieldName,
fieldWriterMethodDescriptor
);
iter.writeByte( Opcode.INVOKEVIRTUAL, pos );
iter.write16bit( fieldWriterMethodIndex, pos + 1 );
return pos;
}
示例3: transformInvokevirtualsIntoGetfields
import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
private int transformInvokevirtualsIntoGetfields(ClassFile classfile,
CodeIterator iter, int pos) {
ConstPool cp = classfile.getConstPool();
int c = iter.byteAt(pos);
if (c != Opcode.GETFIELD) {
return pos;
}
int index = iter.u16bitAt(pos + 1);
String fieldName = cp.getFieldrefName(index);
String className = cp.getFieldrefClassName(index);
if ((!classfile.getName().equals(className))
|| (!readableFields.containsKey(fieldName))) {
return pos;
}
String desc = "()" + (String) readableFields.get(fieldName);
int read_method_index = cp.addMethodrefInfo(cp.getThisClassInfo(),
EACH_READ_METHOD_PREFIX + fieldName, desc);
iter.writeByte(Opcode.INVOKEVIRTUAL, pos);
iter.write16bit(read_method_index, pos + 1);
return pos;
}
示例4: transformInvokevirtualsIntoPutfields
import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
private int transformInvokevirtualsIntoPutfields(ClassFile classfile,
CodeIterator iter, int pos) {
ConstPool cp = classfile.getConstPool();
int c = iter.byteAt(pos);
if (c != Opcode.PUTFIELD) {
return pos;
}
int index = iter.u16bitAt(pos + 1);
String fieldName = cp.getFieldrefName(index);
String className = cp.getFieldrefClassName(index);
if ((!classfile.getName().equals(className))
|| (!writableFields.containsKey(fieldName))) {
return pos;
}
String desc = "(" + (String) writableFields.get(fieldName) + ")V";
int write_method_index = cp.addMethodrefInfo(cp.getThisClassInfo(),
EACH_WRITE_METHOD_PREFIX + fieldName, desc);
iter.writeByte(Opcode.INVOKEVIRTUAL, pos);
iter.write16bit(write_method_index, pos + 1);
return pos;
}
示例5: evalWide
import javassist.bytecode.CodeIterator; //导入方法依赖的package包/类
private void evalWide(int pos, CodeIterator iter, Frame frame, Subroutine subroutine) throws BadBytecode {
int opcode = iter.byteAt(pos + 1);
int index = iter.u16bitAt(pos + 2);
switch (opcode) {
case ILOAD:
evalLoad(Type.INTEGER, index, frame, subroutine);
break;
case LLOAD:
evalLoad(Type.LONG, index, frame, subroutine);
break;
case FLOAD:
evalLoad(Type.FLOAT, index, frame, subroutine);
break;
case DLOAD:
evalLoad(Type.DOUBLE, index, frame, subroutine);
break;
case ALOAD:
evalLoad(Type.OBJECT, index, frame, subroutine);
break;
case ISTORE:
evalStore(Type.INTEGER, index, frame, subroutine);
break;
case LSTORE:
evalStore(Type.LONG, index, frame, subroutine);
break;
case FSTORE:
evalStore(Type.FLOAT, index, frame, subroutine);
break;
case DSTORE:
evalStore(Type.DOUBLE, index, frame, subroutine);
break;
case ASTORE:
evalStore(Type.OBJECT, index, frame, subroutine);
break;
case IINC:
verifyAssignable(Type.INTEGER, frame.getLocal(index));
break;
case RET:
verifyAssignable(Type.RETURN_ADDRESS, frame.getLocal(index));
break;
default:
throw new BadBytecode("Invalid WIDE operand [pos = " + pos + "]: " + opcode);
}
}