facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.79k stars 2k forks source link

Maven build success but fail with infer #1420

Open Anderson-Xia opened 3 years ago

Anderson-Xia commented 3 years ago

Hello, author! I am testing my project with infer, and it has been successfully built by maven install. However when I run 'mvn clean' and then 'infer -- mvn install', some compilation errors occur like this. Similar situations also occur in some other projects. They can not be built again with infer.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:3.0.0:run (process-deps) on project jetty-unixsocket: An Ant BuildException has occured: java.util.regex.PatternSyntaxException: Dangling meta character '' near index 0 [ERROR] (.):(.):jar:(.):(.):.$ [ERROR] ^ [ERROR] around Ant part ...<replaceregexp file="/data/bugDetection/bugdata/second/src/jetty/jetty.project-jetty-9.4.36.v20210114/jetty-unixsocket/target/deps.txt" match="(.):(.):jar:(.):(.):.*$" replace="maven://\1/\2/\4/jar/\3|lib/jnr/\2-\4-\3.jar" byline="true" />... @ 5:249 in /data/bugDetection/bugdata/second/src/jetty/jetty.project-jetty-9.4.36.v20210114/jetty-unixsocket/target/antrun/build-main.xml [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :jetty-unixsocket Usage Error: Maven command failed: mvn install -DskipTests -Dmaven.javadoc.skip=true -Dcheckstyle.skip=true -P infer-capture *** exited with code 1 44781: Error while running epilogue "restoring Maven's pom.xml to its original state": (Unix.Unix_error "No such file or directory" rename "((src /data/bugDetection/bugdata/second/src/jetty/jetty.project-jetty-9.4.36.v20210114/aggregates/jetty-all/pom.xml.infer-orig) (dst /data/bugDetection/bugdata/second/src/jetty/jetty.project-jetty-9.4.36.v20210114/aggregates/jetty-all/pom.xml))"). Powering through...

jiseongg commented 3 years ago

I have similar issues. I'm running Infer on huge amount of Java open-source projects and in most cases, mvn clean install ... succeeds but infer capture -- mvn clean install ... fails. I'm trying to list and classify all cases neatly, and maybe I can share my situation here and discuss about it in this thread soon.

jiseongg commented 3 years ago

@Anderson-Xia,

I've tried to run infer capture on some portion of my projects, with Infer built from different tags, tags/v1.1.0 and tags/v1.0.0. The former failed to capture maven build command, but the latter succeeds. Still there are many other projects not resolved with this method, but it may solve your case. I recommend to try it...

Anderson-Xia commented 3 years ago

@jiseongg Thank you for your great recommendation! I'll check if other versions work. Have a nice day, jiseongg.

raul-verdi commented 1 year ago

Similar situation here. When running infer on gh actions I will get errors like (use -source 16 or higher to enable records), even tho the java version is 17.

openjdk 17.0.4.1 2022-08-12
OpenJDK Runtime Environment Temurin-17.0.4.1+1 (build 17.0.4.1+1)
OpenJDK 64-Bit Server VM Temurin-17.0.4.1+1 (build 17.0.4.1+1, mixed mode, sharing)
javac 17.0.4.1

Yet it would seem infer is using java 11.

raul-verdi commented 1 year ago

Ok, infer doesn't know how to get the proper java version on it's own. You need to give it the --java-version param to help him out

mmohajer9 commented 1 year ago

I also have the same problem in some projects. I believe the best thing that worked for me (not always) was to have several versions of java (e.g., 8, 11, 20, etc.) on my machine, and everytime I want to run Infer, I will set the --java-version flag accordingly with my installed java version. I do not know why it is like this, but this was the thing that worked for me for most of the projects that had this problem.

I appreciate it if Infer team fix this issue since it is very confusing.