JavaプロファイラーのソースコードをEclipseにダウンロードしました。
CCTNode node = t.threadLocalCCTNode;
(メソッド内の)行でgetCurrentNode
、次のエラーが発生します。
t.threadLocalCCTNode cannot be resolved or is not a field
Thread.currentThread().bytecodeIndex;
(メソッドで)戻る行でもgetIndex
、同様のエラーが発生します。
bytecodeIndex cannot be resolved or is not a field
誰かがこれらの2つのエラーの原因が何であるかを教えてもらえますか?
クラスは次のようになります。
/**
* 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;
}
}