`infer -- javac Hello.java` fails to run when the current path contains whitespaces
I have tried to test infer using Hello.java which was located in Desktop/Hello folder in my mac. And it said "Failed to load any Java source code". (Refer below commands that I tried.).
CD-RWEERASOORI:Desktop rweerasooriya$ infer -v Infer version v0.1.1 Copyright 2009 - present Facebook. All Rights Reserved.
CD-RWEERASOORI:Desktop rweerasooriya$ java -version java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
CD-RWEERASOORI:Desktop rweerasooriya$ cd Hello/ CD-RWEERASOORI:Hello rweerasooriya$ ls Hello.java
CD-RWEERASOORI:Hello rweerasooriya$ infer -- javac Hello.java Fatal error: exception Failure("Failed to load any Java source code") [ERROR] Failure during frontend, original command was
[u'inferJ', u'-g', u'-a', 'infer', u'javac', 'Hello.java']
Traceback (most recent call last):
File "/Users/rweerasooriya/infer-osx-v0.1.1/infer/infer/bin/inferJ", line 19, in
Hi @randikapw, thanks for the detailed report. It looks like a duplicate of #30. The workaround for now is to upgrade java and javac to version 1.7.
Please reopen and update this issue if java and javac 1.7 do not solve it for you.
Thanks @jvillard Just installed latest version of JDK and it worked for me. And I had already followed #30 and reason to open this was i have received different message :) Thanks for quick reply.
@randikapw yes indeed, we removed the "TODO" message in favour of raising the exception you're seeing in a8a8501243742c27b7cec8e6cbf9d5c26d668d70
Actually my main requirement was to try infer for an Eclipse + Android project. And it failed again with same message. Any idea about this?
CD-RWEERASOORI:expandablelistsample rweerasooriya$ java -version java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
CD-RWEERASOORI:expandablelistsample rweerasooriya$ ant debug Buildfile: /Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/build.xml
-set-mode-check:
-set-debug-files:
-check-env: [checkenv] Android SDK Tools Revision 24.1.2 [checkenv] Installed at /Users/rweerasooriya/Desktop/adt-bundle-mac-x86_64-20131030u/sdk
-setup: [echo] Project Name: expandablelistsample [gettype] Project Type: Application
{some content has removed here for short this post }
[propertyfile] Updating property file: /Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/bin/build.prop
-post-build:
debug:
BUILD SUCCESSFUL Total time: 2 seconds
CD-RWEERASOORI:expandablelistsample rweerasooriya$ ant clean Buildfile: /Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/build.xml
{some content has removed here for short this post }
[getlibpath] No Libraries [subant] No sub-builds to iterate on
BUILD SUCCESSFUL Total time: 0 seconds
CD-RWEERASOORI:expandablelistsample rweerasooriya$ infer -- ant debug Fatal error: exception Failure("Failed to load any Java source code") [ERROR] Failure during frontend, original command was
[u'inferJ', u'-g', u'-a', 'capture', u'javac', '-d', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/bin/classes', '-classpath', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/bin/classes:/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/libs/android-support-v4.jar', '-sourcepath', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/src:/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/gen', '-target', '1.5', '-bootclasspath', '/Users/rweerasooriya/Desktop/adt-bundle-mac-x86_64-20131030u/sdk/platforms/android-19/android.jar', '-encoding', 'UTF-8', '-g', '-source', '1.5', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/src/com/example/expandablelistsample/ExpandableListAdapter.java', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/src/com/example/expandablelistsample/MainActivity.java', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/gen/com/example/expandablelistsample/BuildConfig.java', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/gen/com/example/expandablelistsample/R.java']
Traceback (most recent call last):
File "/Users/rweerasooriya/infer-osx-v0.1.1/infer/infer/bin/infer", line 141, in
Now your version of java and javac may be too recent. That'd be #30 again. Does this work if you downgrade java and javac to 1.7?
Hi @randikapw
I'm just curious, but could you show me the output of the following command?
$ javac -verbose Hello.java
Your error messages are similar to those I had before. https://github.com/facebook/infer/pull/94
@jvillard Just downgraded it :( still not working
CD-RWEERASOORI:expandablelistsample rweerasooriya$ export JAVA_HOME=$(/usr/libexec/java_home -v 1.7) CD-RWEERASOORI:expandablelistsample rweerasooriya$ java -version java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode) CD-RWEERASOORI:expandablelistsample rweerasooriya$ ant clean Buildfile: /Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/build.xml
{removed some stuff}
BUILD SUCCESSFUL Total time: 2 seconds
CD-RWEERASOORI:expandablelistsample rweerasooriya$ infer -- ant debug Fatal error: exception Failure("Failed to load any Java source code") [ERROR] Failure during frontend, original command was
[u'inferJ', u'-g', u'-a', 'capture', u'javac', '-d', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/bin/classes', '-classpath', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/bin/classes:/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/libs/android-support-v4.jar', '-sourcepath', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/src:/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/gen', '-target', '1.5', '-bootclasspath', '/Users/rweerasooriya/Desktop/adt-bundle-mac-x86_64-20131030u/sdk/platforms/android-19/android.jar', '-encoding', 'UTF-8', '-g', '-source', '1.5', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/src/com/example/expandablelistsample/ExpandableListAdapter.java', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/src/com/example/expandablelistsample/MainActivity.java', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/gen/com/example/expandablelistsample/BuildConfig.java', '/Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/gen/com/example/expandablelistsample/R.java']
Traceback (most recent call last):
File "/Users/rweerasooriya/infer-osx-v0.1.1/infer/infer/bin/infer", line 141, in
Hi @occho Give me few minutes.. ill post it
Hi @occho, This is the result
CD-RWEERASOORI:expandablelistsample rweerasooriya$ cd ~/Desktop/Hello/
CD-RWEERASOORI:Hello rweerasooriya$ javac -verbose Hello.java [parsing started RegularFileObject[Hello.java]] [parsing completed 15ms] [search path for source files: .] [search path for class files: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/resources.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/rt.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/sunrsasign.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jsse.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jce.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/charsets.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jfr.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/classes,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/dnsns.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/localedata.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunec.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar,/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/zipfs.jar,/System/Library/Java/Extensions/AppleScriptEngine.jar,/System/Library/Java/Extensions/dns_sd.jar,/System/Library/Java/Extensions/j3daudio.jar,/System/Library/Java/Extensions/j3dcore.jar,/System/Library/Java/Extensions/j3dutils.jar,/System/Library/Java/Extensions/jai_codec.jar,/System/Library/Java/Extensions/jai_core.jar,/System/Library/Java/Extensions/mlibwrapper_jai.jar,/System/Library/Java/Extensions/MRJToolkit.jar,/System/Library/Java/Extensions/vecmath.jar,.] [loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Object.class)]] [checking Hello] [loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/AutoCloseable.class)]] [loading ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/String.class)]] [wrote RegularFileObject[Hello.class]] [total 563ms]
CD-RWEERASOORI:Hello rweerasooriya$ infer -- javac -verbose Hello.java Starting analysis (Infer version v0.1.1) Analysis done
1 file analyzed
/Users/rweerasooriya/Desktop/Hello/Hello.java:4: error: NULL_DEREFERENCE object s last assigned on line 3 could be null and is dereferenced at line 4
CD-RWEERASOORI:Hello rweerasooriya$
Thanks @randikapw Well, I'm sorry, I misunderstood. I had thought that you were still stuck with Hello.java.
In my case, verbose output contained characters that the lexer did not expect, which caused parsing errors.
I'll check spaces are allowed for file paths
@occho :+1:
@randikapw I am guessing that the spaces cause the bug. https://github.com/facebook/infer/blob/master/infer/src/java/jVerboseLexer.mll#L25
I mean the spaces in "Review Work Space". /Users/rweerasooriya/Documents/EAG/Review Work Space/expandablelistsample/bin/classes
Interesting! Spaces in the path do indeed seem to be the problem. We will work on fixing this.
I hava the same error.
Fatal error: exception Failure("Failed to load any Java source code")
Traceback (most recent call last):
File "/Users/mengdongsheng/Documents/infer-osx-v0.2.0/infer/infer/bin/infer", line 168, in
java -version java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode) javac -version javac 1.7.0_79
I have tried to test infer using Hello.java in my ubuntu. And it said "Failed to load any Java source code". (Refer below commands that I tried.).
linux1@linux1-X550VL:/opt/test$ infer -v Infer version v0.1.1 Copyright 2009 - present Facebook. All Rights Reserved. linux1@linux1-X550VL:/opt/test$ java -version java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode) linux1@linux1-X550VL:/opt/test$ javac -version javac 1.7.0_79 linux1@linux1-X550VL:/opt/test$ ls -l -rwxrwxr-x 1 linux1 linux1 79 10:55 Hello.java linux1@linux1-X550VL:/opt/test$ infer -- javac Hello.java Fatal error: exception Failure("Failed to load any Java source code") [ERROR] Failure during frontend, original command was
[u'inferJ', u'-g', u'-a', 'infer', u'javac', 'Hello.java']
Traceback (most recent call last):
File "/usr/local/infer-linux64-v0.1.1/infer/infer/bin/inferJ", line 19, in
linux1@linux1-X550VL:/opt/test$
@yolinkxzw it looks like you are running infer -- javac Hello.java from a directory that does not contain the file Hello.java (infer/examples in the distribution).
@Stupidcoding: thanks for the report, that's a bug in the error handling path of javac.py! That doesn't explain the root of your issue though. It doesn't seem like it's an instance of this issue. Could you please open a new one and paste the contents of infer-out/toplevel.log there as well?
@jvillard OK
@yolinkxzw it looks like you are running infer -- javac Hello.java from a directory that does not contain the file Hello.java (infer/examples in the distribution).
I copy Hello.java from directory infer/examples to /opt/test. Maybe, I use chinese ubuntu system, so there is some chinese word confused you. I delete chinese word and paste the error again. please check it again. Thank you!
linux1@linux1-X550VL:/opt/test$ infer -v Infer version v0.1.1 Copyright 2009 - present Facebook. All Rights Reserved. linux1@linux1-X550VL:/opt/test$ java -version java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode) linux1@linux1-X550VL:/opt/test$ javac -version javac 1.7.0_79 linux1@linux1-X550VL:/opt/test$ ls -l -rwxrwxrwx 1 linux1 linux1 79 June 27 10:55 Hello.java linux1@linux1-X550VL:/opt/test$ infer -- javac Hello.java Fatal error: exception Failure("Failed to load any Java source code") [ERROR] Failure during frontend, original command was
[u'inferJ', u'-g', u'-a', 'infer', u'javac', 'Hello.java']
Traceback (most recent call last):
File "/usr/local/infer-linux64-v0.1.1/infer/infer/bin/inferJ", line 19, in
linux1@linux1-X550VL:/opt/test$
@jvillard
I try to use infer v0.2.0, the error changes. and folowing is error.
linux1@linux1-X550VL:/opt/test$ ls -l
-rwxrwxrwx 1 linux1 linux1 79 June 27 10:55 Hello.java
linux1@linux1-X550VL:/opt/test$ infer -- javac Hello.java
Fatal error: exception Failure("Failed to load any Java source code")
Traceback (most recent call last):
File "/usr/local/infer-linux64-v0.2.0/infer/infer/bin/infer", line 168, in
[INFO] Platform: Linux-3.16.0-30-generic-x86_64-with-Ubuntu-14.04-trusty [INFO] PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.7.0_79/bin:/usr/local/infer-linux64-v0.2.0/infer/infer/bin [INFO] SHELL=/bin/bash [INFO] PWD=/opt/test [ERROR] Failure during frontend, original command was
[u'inferJ', u'-g', u'-a', u'infer', u'javac', 'Hello.java']
@yolinkxzw: do you observe the same thing with: infer -- javac -J-Duser.language=en Hello.java ?