我已将 Java 分析器的源代码下载到 Eclipse 中。
在 where CCTNode node = t.threadLocalCCTNode;
(in getCurrentNode
method) 的行上,我收到以下错误:
t.threadLocalCCTNode cannot be resolved or is not a field
同样在返回Thread.currentThread().bytecodeIndex;
(在getIndex
方法中)的行上,我得到一个类似的错误:
bytecodeIndex cannot be resolved or is not a field
谁能告诉我这两个错误的原因是什么?
该类如下所示:
/**
* Copyright (c) 2010 Aibek Sarimbekov, Philippe Moret, Walter Binder
*
* Permission to copy, use, modify (only the included source files, modification
* of the binaries is not permitted) the software is granted provided this
* copyright notice appears in all copies.
*
* This software is provided "as is" without express or implied warranty, and
* with no claim as to its suitability for any purpose.
*/
package ch.usi.dag.jp2.runtime;
import ch.usi.dag.jborat.runtime.DynamicBypass;
public class JP2Runtime {
private static final String objectConstructorMID;
private static final String currentThreadMID;
static CCTNode main;
static {
objectConstructorMID = "Ljava/lang/Object;.<init>()V".intern();
currentThreadMID = "Ljava/lang/Thread;.currentThread()Ljava/lang/Thread".intern();
}
public static CCTNode getCurrentNode() {
boolean old = DynamicBypass.getAndSet();
try {
Thread t = Thread.currentThread();
CCTNode node = t.threadLocalCCTNode;
if (node == null) {
node = CCTNode.getRoot();
t.threadLocalCCTNode = node;
main = node;
}
return node;
} finally {
DynamicBypass.set(old);
}
}
public static void setCurrentNode(CCTNode node) {
boolean old = DynamicBypass.getAndSet();
try {
Thread.currentThread().threadLocalCCTNode = node;
} finally {
DynamicBypass.set(old);
}
}
public static void setIndex(int index) {
boolean old = DynamicBypass.getAndSet();
try{
Thread.currentThread().bytecodeIndex = index;
}
finally{
DynamicBypass.set(old);
}
}
public static int getIndex() {
boolean old = DynamicBypass.getAndSet();
try {
return Thread.currentThread().bytecodeIndex;}
finally {
DynamicBypass.set(old);
}
}
public static void enableProfiling(){
boolean old = DynamicBypass.getAndSet();
try {
Thread.currentThread().activateBytecodeCounting=true;
}
finally {
DynamicBypass.set(old);
}
}
public static void disableProfiling(){
boolean old = DynamicBypass.getAndSet();
try {
Thread.currentThread().activateBytecodeCounting=false;
}
finally {
DynamicBypass.set(old);
}
}
public static CCTNode invokeProfileInvocation(CCTNode oldNode, String MID, int numberOfBB) {
boolean old = DynamicBypass.getAndSet();
int bytecodeIndex = getIndex();
try {
CCTNode n = oldNode.profileCall(MID, bytecodeIndex, numberOfBB);
Thread.currentThread().threadLocalCCTNode=n;
return n;
} finally {
DynamicBypass.set(old);
}
}
public static void invokeProfileInvocationForObjectConstructor(CCTNode oldNode) {
boolean old = DynamicBypass.getAndSet();
int bytecodeIndex = getIndex();
try {
CCTNode n = oldNode.profileCall(objectConstructorMID, bytecodeIndex, 1);
CCTNode.bbSizes.put(objectConstructorMID, allocateNewArrayWithOneElement());
} finally {
DynamicBypass.set(old);
}
}
public static void invokeProfileInvocationForCurrentThread(CCTNode oldNode) {
boolean old = DynamicBypass.getAndSet();
int bytecodeIndex = getIndex();
try {
CCTNode n = oldNode.profileCall(currentThreadMID, bytecodeIndex, 1);
CCTNode.bbSizes.put(currentThreadMID, allocateNewArrayWithOneElement());
} finally {
DynamicBypass.set(old);
}
}
private static int[] allocateNewArrayWithOneElement() {
int[] array = {1};
return array;
}
}