SpoonLabs / astor

Automatic program repair for Java with generate-and-validate techniques :v::v:: jGenProg (2014) - jMutRepair (2016) - jKali (2016) - DeepRepair (2017) - Cardumen (2018) - 3sfix (2018)
https://hal.archives-ouvertes.fr/hal-01321615/document
GNU General Public License v2.0
205 stars 107 forks source link

Spoon exception about source code level #73

Open surli opened 6 years ago

surli commented 6 years ago

I got the following exception when running astor on project https://github.com/druid-io/druid:

spoon.compiler.ModelBuildingException: Syntax error, annotations are only available if source level is 1.5 or greater at /root/output_astor/AstorMain-server/src/default/io/druid/server/http/CoordinatorDynamicConfigsResource.java:49 at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.report(JDTBasedSpoonCompiler.java:581) at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.reportProblems(JDTBasedSpoonCompiler.java:562) at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:119) at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:100) at fr.inria.astor.core.manipulation.MutationSupporter.buildModel(MutationSupporter.java:91)

Is there an option to specify the source code level wanted in Astor? And will it fix automatically the source code level used inside Spoon?

martinezmatias commented 6 years ago

Hi Simon

Is there an option to specify the source code level wanted in Astor

Yes, the option is 'javacompliancelevel'. For instance, javacompliancelevel=8 corresponds to java 8 (or 1.8).

And will it fix automatically the source code level used inside Spoon? Yes. it passes that property to Spoon.

If the problem continues, write me and I run the example locally to reproduce the error

surli commented 6 years ago

Yes, the option is 'javacompliancelevel'. For instance, javacompliancelevel=8 corresponds to java 8 (or 1.8).

Actually I misreaded my list of arguments yesterday: I'm already using this argument and setting it to 8:

astorArgs.add("-parameters");
astorArgs.add("timezone:Europe/Paris:maxnumbersolutions:3:limitbysuspicious:false:maxmodificationpoints:1000:javacompliancelevel:8:logfilepath:repairnator.astor.log");
martinezmatias commented 6 years ago

So, That means that using this configuration (that uses javacompliancelevel:8) you have the previous exception?

surli commented 6 years ago

That means that using this configuration (that uses javacompliancelevel:8) you have the previous exception?

Exactly

martinezmatias commented 6 years ago

Okey, I am almost sure where is the problem. Astor tries to generate the spoon model using javacompliancelevel (in your case 8). if the compilation fails, Astor tries to compile again using a lower compliance, indicated in property alternativecompliancelevel (by default 4). This is an old feature, that we use it then we executed astor on an old dataset with some subject that required to be compiled in java 1.4. However, in cases like yours, the first compilation could be produced due to a wrong configuration of the source folder or a missing dependency. Could you send me the complete log and the command? There is probably a clue there.

surli commented 6 years ago

Could you send me the complete log and the command? There is probably a clue there.

Actually I don't have right now the logs, as my process fails. I'll try to reproduce the error myself before giving this to you.

However I got the following information: Nopol next tries to repair the same bug ang got an error with Spoon:

spoon.compiler.ModelBuildingException: The method makeRequestMetrics(GenericQueryMetricsFactory, QueryToolChest<T,Query>, Query, String) in the type DruidMetrics is not applicable for the arguments (GenericQueryMetricsFactory, QueryToolChest, Query, String) at /root/workspace/druid-io/druid/352360271/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java:500

Did you catch those exception in Astor for your fallback mechanism you talked about?

martinezmatias commented 6 years ago

Did you catch those exception in Astor for your fallback mechanism you talked about?

I have just commited a change in the mechanism I explained before: we compile only once using 'javacompliancelevel' , if the compilation fails we throws an exception