3

I am using NETBeans IDE for developing an annotation processor. I have written the annotation processor and then convert it to a JAR and then add this JAR as a referenced library to another java application where i am using the annotations.

Now my question is inside the annotation processor if i want to access the source files( the ones which are annotated) then i try to get a FileObject using the below code

FileObject source = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH,"","demo/MainCopy.java");

but its returning null. Here demo is the package which has the annotated class MainCopy.java . When i read the documentation of StandardLocation class it says for it to work it must be supported , Could somebody help me solve this or guide me as to how to obtain the FileObject.

Thanks

yash6
  • 141
  • 3
  • 14
  • Have you tried just using javac? Have you tried: getResource(StandardLocation.SOURCE_PATH,"demo","MainCopy.java") ? These are just thoughts -- the getResource method specifies that CLASS_OUTPUT and SOURCE_OUTPUT must be supported but remains silent on SOURCE_PATH. – jbunting Feb 05 '13 at 13:25
  • @jbunting , ya i have tries putting "demo" as the second parameter as you have suggested , but its been an abortive attempt. i keep getting null. and have tried using javac too :( – yash6 Feb 06 '13 at 05:42
  • Not much consolation but I've just been through this with the debugger and it seems that `SOURCE_PATH` as a location is not supported in the filer. See also: http://stackoverflow.com/questions/18102444/cannot-load-resources-in-annotation-processor-not-on-classpath – Matthew Sep 12 '16 at 14:20

0 Answers0