0

出于某种原因,我想通过 adb 在 Android Runtime (ART) 上运行Dacapo Benchmark 。以下是运行的步骤:

# convert all .class bytecode in dacapo.jar to .dex bytecode
java -jar dx.jar --dex --output=classes.dex $(find . -name "*.class") 

adb push classes.dex /sdcard/dacapo

# run the 'fop' benchmark
adb shell app_process -Djava.class.path=/sdcard/dacapo/classes.dex /sdcard/dacapo Harness fop 

但是,我得到了异常信息:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.net.URL.getProtocol()' on a null object reference
        at org.dacapo.harness.CommandLineArgs.extractBenchmarkSet(Unknown Source:52)
        at org.dacapo.harness.CommandLineArgs.<init>(Unknown Source:600)
        at org.dacapo.harness.TestHarness.main(Unknown Source:64)
        at java.lang.reflect.Method.invoke(Native Method)
        at Harness.main(Unknown Source:91)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:399)

我查看了 Dacapo 的源代码,找到了异常的来源:

public class CommandLineArgs{
    static List<String> extractBenchmarkSet() throws IOException {
        List<String> benchmarks = new ArrayList<String>();
        URL url = CommandLineArgs.class.getClassLoader().getResource("cnf");
        String protocol = url.getProtocol();
        ...
    }

}

如您所见,getResource("cnf")返回一个null引用。原因是dacapo.jar中有一些资源,但是dx.jar没有任何资源文件,只能将.class转为.dex。

我也尝试将cnf资源放入/sdcard//sdcard/dacapo但仍然失败。

那么如何让 .dex 字节码访问cnf资源呢?

4

0 回答 0