Java 如何扫描使用COFOJA编写的合同中使用的注释?
我正在从事一个项目,在这个项目中,我必须使用COFOJA为一个方法编写一个契约,并且我必须使用启发式从契约中生成方法的代码 1我将如何扫描COFOJA中使用的注释,如@requires、@assures等? 2如果生成抽象语法树,AST是否也包含注释/契约语言 EX:考虑以下输入到我的项目Java 如何扫描使用COFOJA编写的合同中使用的注释?,java,eclipse,eclipse-plugin,design-by-contract,Java,Eclipse,Eclipse Plugin,Design By Contract,我正在从事一个项目,在这个项目中,我必须使用COFOJA为一个方法编写一个契约,并且我必须使用启发式从契约中生成方法的代码 1我将如何扫描COFOJA中使用的注释,如@requires、@assures等? 2如果生成抽象语法树,AST是否也包含注释/契约语言 EX:考虑以下输入到我的项目 class Test{ @requires( { a> 0}) @ensures( {a==0 implies fact(a)=1 , and a>0 implies fact(a) = fac
class Test{
@requires( { a> 0})
@ensures( {a==0 implies fact(a)=1 , and a>0 implies fact(a) = fact(a-1)*a } )
public int fact (int a)
{
}
}
// Output of first version of code: (Its a rough estimate of code,)
class Test1{
public int fact (int a)
{
if (a==0)
return 1;
if(a >0)
return a*fact(a-1);
if(a<0) throw new AssertionException("Precondition failed/violated a<0 ");
}
} // end of class
要设置eclipse,请执行以下操作:
对于cofoja: