HasStatic是什么意思java,Java Klass.hasGlobalStatics方法代碼示例

import com.sun.squawk.Klass; //導入方法依賴的package包/類

/**

* Convert the code of this method from its Java bytecode form to its

* Squawk bytecode form. This must only be called once and cannot be called

* for an abstract or native Method.

*

* @param translator the translation context

* @param method the method owning this code

* @param index the index of this method in the symbols table of the enclosing class

*/

private void convertPhase1(Translator translator, Method method, int index) {

try {

Assert.that(code != null, "code is null for " + method);

Klass declaringClass = method.getDefiningClass();

ClassFile cf = translator.getClassFile(declaringClass);

/*

* Write trace message.

*/

if (Translator.TRACING_ENABLED && Tracer.isTracing("converting", method.toString())) {

Tracer.traceln("[converting method " + method + "]");

}

/*

* Get or create the constant pool.

*/

ConstantPool constantPool;

if (code == SYNTHESIZED_DEFAULT_CONSTRUCTOR_CODE) {

constantPool = getConstantPoolForSynthesizedConstructor(translator, method.getDefiningClass());

code = getCodeForSynthesizedConstructor();

} else {

constantPool = cf.getConstantPool();

}

/*

* Ensure the parameter and return types are loaded.

*/

translator.load(method.getReturnType());

Klass[] parameterTypes = method.getParameterTypes();

for (int i = 0 ; i < parameterTypes.length ; i++) {

translator.load(parameterTypes[i]);

}

/*

* Get the code parser and build the IR.

*/

codeParser = new CodeParser(translator, method, code, constantPool);

irBuilder = new IRBuilder(translator, codeParser);

IR ir = irBuilder.getIR();

/*

* Add the object references into the table of constants.

*/

objectTable = new ObjectTable(declaringClass);

for (Instruction instruction = ir.getHead() ; instruction != null ; instruction = instruction.getNext()) {

Object object = instruction.getConstantObject();

if (object != null) {

if (instruction instanceof FieldAccessor) { // ignore special cases:

Klass fieldDefiningClass = ((FieldAccessor)instruction).getField().getDefiningClass();

if (fieldDefiningClass.hasGlobalStatics() || fieldDefiningClass == declaringClass) {

// getstatic/putstatic on global globals doesn't really use the class object table

// getstatic/putstatic on "this class" doesn't really use the class object table

continue;

}

}

objectTable.addConstantObject(object);

}

}

/*

* Transform the IR.

*/

IRTransformer transformer = new IRTransformer(ir, method, getFrame());

transformer.transform(translator);

} finally {

code = null; // Allow the code to be garbage collected

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值