當前位置: 首頁>>代碼示例>>Java>>正文


Java ConstPool.getFieldrefName方法代碼示例

本文整理匯總了Java中javassist.bytecode.ConstPool.getFieldrefName方法的典型用法代碼示例。如果您正苦於以下問題:Java ConstPool.getFieldrefName方法的具體用法?Java ConstPool.getFieldrefName怎麽用?Java ConstPool.getFieldrefName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javassist.bytecode.ConstPool的用法示例。


在下文中一共展示了ConstPool.getFieldrefName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: transformInvokevirtualsIntoGetfields

import javassist.bytecode.ConstPool; //導入方法依賴的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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:FieldTransformer.java

示例2: transformInvokevirtualsIntoPutfields

import javassist.bytecode.ConstPool; //導入方法依賴的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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:FieldTransformer.java

示例3: transformInvokevirtualsIntoGetfields

import javassist.bytecode.ConstPool; //導入方法依賴的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;
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:22,代碼來源:FieldTransformer.java

示例4: transformInvokevirtualsIntoPutfields

import javassist.bytecode.ConstPool; //導入方法依賴的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;
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:22,代碼來源:FieldTransformer.java


注:本文中的javassist.bytecode.ConstPool.getFieldrefName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。