Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InMemoryJavaFileManager has different behavior than standard java file manager. #47

Open
jasonnn opened this issue Jun 16, 2014 · 2 comments
Labels

Comments

@jasonnn
Copy link

jasonnn commented Jun 16, 2014

The InMemoryJavaFileManager allows locations other than those specified in StandardLocation, whereas the standard manager will throw a null pointer exception if a non standard location is used.
Please look at a simple unit test i made which illustrates this

While it now seems kind of obvious to me that the "standard" manager would only support "standard" locations, it would be nice if compile-testing checked that it's backing file manager was actually able to create a FileObject for the specified location.

@gk5885
Copy link
Contributor

gk5885 commented Jun 16, 2014

Sadly, between javac and eclipse and whatever else, these tools just tend to be somewhat broken in their implementations. Given its contract, the JavaFileManager that comes with javac should have thrown an IllegalArgumentException. So, even if we wanted to mimic the locations supported by that implementation, throwing NullPointerException would just be reproducing their bug.

Out of curiosity, how did this even come up? Filer does the right thing with these locations, so I wouldn't have expected this to be an issue.

@jasonnn
Copy link
Author

jasonnn commented Jun 18, 2014

In my processor, the code which triggered the exception was:

 FileObject of = env.getFiler().createResource(NON_STANDARD_LOCATION, "", "test");

and here is the relevant stack trace...

java.lang.NullPointerException
at com.sun.tools.javac.file.JavacFileManager.getFileForOutput(JavacFileManager.java:785)
at com.sun.tools.javac.file.JavacFileManager.getFileForOutput(JavacFileManager.java:761)
at com.sun.tools.javac.processing.JavacFiler.createResource(JavacFiler.java:428)
...

It looks like javac's filer mostly just delegates to the file manager, so the issue still exists.

@raghsriniv raghsriniv added the P3 label Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants