0

我已将 Java 分析器的源代码下载到 Eclipse 中。

在 where CCTNode node = t.threadLocalCCTNode;(in getCurrentNodemethod) 的行上,我收到以下错误:

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;
    }
}
4

1 回答 1

0

这意味着代码正在尝试访问对象字段,但对象的类没有定义该字段。

因为t是一个Thread(并且很可能是Thread来自 API 的类),我的 ararchnid 感觉告诉我您使用的是过时的 Java 版本。

检查代码页,看看它是否说明了它需要哪个 JDK/JRE 版本。

于 2012-06-11T08:05:33.363 回答