MAC下Defect4J安装与配置

我使用的是2.0.0版本
项目官网:https://github.com/rjust/defects4j

一、数据集简介

Defects4j数据集是14年由Michael D. Ernst老师及其合作者一起发布的Java运行时缺陷数据集,近年来已经被广泛应用在相关研究中,如近期就有这些论文用到了这个数据集:

Chen, Yizhen, et al. “Effective online software anomaly detection.” Proceedings of the 26th ACM SIGSOFT International Symposium on Software Testing and Analysis. ACM, 2017.

Sohn, Jeongju, and Shin Yoo. “FLUCCS: using code and change metrics to improve fault localization.” Proceedings of the 26th ACM SIGSOFT International Symposium on Software Testing and Analysis. ACM, 2017. [ 1 ] [1] [1]

这个数据集的具体应用场景,后面还会补充。

二、安装和配置

大部分的内容按照github主页“Setting up Defects4J”操作即可,也可以参考下这篇博客:Defects4J数据集安装与需求配置

这里说下安装过程中的几个小点:

1、多版本jdk如何配置

MAC下jdk的版本一般是在这个路径下:

$ ls /Library/Java/JavaVirtualMachines/
jdk-13.0.1.jdk		jdk-15.jdk		jdk1.8.0_231.jdk

可以根据需要给用户配置不同的jdk,涉及到的文件是用户家目录下的“.bash_profile”文件;

和Java相关的配置如下:

export jdk15=/Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
export JAVA_HOME=$jdk15
export PATH=$JAVA_HOME:$JAVA_HOME/jre:$PATH

保存好“.bash_profile”文件然后用下面的命令使配置生效:

source  .bash_profile

其他linux版本配置过程大同小异,/etc/profile是对所有用户生效,并不推荐,如果只有一台电脑,但是需要多个java环境共存,可以添加新的用户,给不同的用户配置不同的java版本。

后面添加

export PATH=$PATH:"path2defects4j"/framework/bin

和java这里的处理思路相同,都是为了省略命令的绝对路径

2、安装需要的包和命令

比如说wget,MAC下是默认没有安装的,可以使用brew命令安装,brew的使用可以参考这篇博客:homebrew是个啥

类似于CentOS里面的yum和Ubuntu里面的apt-get,能自动解决安装包或者命令时的各种依赖。

3、编译出错

使用defects4j compile时出现以下错误:

initialise:

compile:
    [javac] /Users/hh/defect4j/defects4j-master/framework/projects/Chart/Chart.build.xml:57: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 654 source files to /Users/hh/defect4j/defects4j-master/defect_sourcecode/chart_1b_buggy/build
    [javac] 警告: [options] 未与 -source 1.4 一起设置引导类路径
    [javac] 错误: 不再支持源选项 1.4。请使用 7 或更高版本。
    [javac] 错误: 不再支持目标选项 1.4。请使用 7 或更高版本。

BUILD FAILED
/Users/hh/defect4j/defects4j-master/framework/projects/Chart/Chart.build.xml:57: Compile failed; see the compiler error output for details.

网上查了下和java版本冲突有关,把Chart.build.xml里面涉及到的版本改成自己的即可。

$ javac --version
javac 15

我在处理Math这个项目的时候同样遇到了java版本问题,但是修改相关配置后,还是不行,如果有人解决了,烦请告知,多谢!

Math这个项目在编译的时候报错信息如下:

$ defects4j compile
Running ant (compile)...................................................... FAIL
Executed command:  cd /Users/schillerxu/defect4j/defects4j-master/defect_sourcecode/math_1_buggy && /Users/schillerxu/defect4j/defects4j-master/major/bin/ant -f /Users/schillerxu/defect4j/defects4j-master/framework/projects/defects4j.build.xml -Dd4j.home=/Users/schillerxu/defect4j/defects4j-master -Dd4j.dir.projects=/Users/schillerxu/defect4j/defects4j-master/framework/projects -Dbasedir=/Users/schillerxu/defect4j/defects4j-master/defect_sourcecode/math_1_buggy -Dbuild.compiler=javac1.7  compile 2>&1
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Buildfile: /Users/schillerxu/defect4j/defects4j-master/framework/projects/defects4j.build.xml

BUILD FAILED
/Users/schillerxu/defect4j/defects4j-master/framework/projects/defects4j.build.xml:82: The following error occurred while executing this line:
/Users/schillerxu/defect4j/defects4j-master/framework/projects/Math/Math.build.xml:60: Unable to create javax script engine for javascript

Total time: 0 seconds
Cannot compile sources! at /Users/schillerxu/defect4j/defects4j-master/framework/bin/d4j/d4j-compile line 82.
Compilation failed in require at /Users/schillerxu/defect4j/defects4j-master/framework/bin/defects4j line 195.

三、参考资料

[ 1 ] [1] [1] Defects4j数据集的使用
Maven ERROR 不再支持源选项 5,请使用 7 或更高版本的解决办法

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值