-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
6
-
generic
-
generic
Filer.createTextFile(Location,pkg,File,charsetname) appends File to root, '/', is no -s dir options was used to launch processor and Location given is SOURCE_TREE.
Copy below source to testAP.java, compile and run.
javac testAP.java
javac -proc:only -processor testAP testAP.java
% cat testAP.java
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import java.util.Set;
import java.util.Vector;
import java.io.PrintWriter;
import java.io.File;
import static javax.tools.Diagnostic.Kind.*;
import static javax.annotation.processing.Filer.Location.*;
@SupportedSourceVersion(javax.lang.model.SourceVersion.RELEASE_6)
@SupportedAnnotationTypes({"*"})
public class testAP extends AbstractProcessor
{
public static Messager msgr = null;
public static java.io.Writer FW = null;
Filer _filer = null;
File _reportFile = null;
String myfile = "./report.html";
public static String javaFile = null;
public testAP() { }
@Override
public void init(ProcessingEnvironment penv) {
processingEnv = penv;
msgr = penv.getMessager();
_filer = penv.getFiler();
try { _reportFile = new java.io.File(myfile);}
catch(Exception e1) {
System.out.println("Exception trying to create File for " + myfile);
}finally {
try{System.out.println("File Name: " + _reportFile.getCanonicalPath() );}
catch(java.io.IOException ioe){ ioe.printStackTrace(); }
}
try {
// FW = _filer.createTextFile(CLASS_TREE,"", _reportFile ,null);
FW = _filer.createTextFile(SOURCE_TREE,"", _reportFile ,null);
}
catch(FilerException fe) {
System.out.println(fe.toString());
}
catch(Exception some_other_excep) {
msgr.printMessage(ERROR, some_other_excep.toString());
some_other_excep.printStackTrace();
}
}
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv)
{
return true;
}
}
Copy below source to testAP.java, compile and run.
javac testAP.java
javac -proc:only -processor testAP testAP.java
% cat testAP.java
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import java.util.Set;
import java.util.Vector;
import java.io.PrintWriter;
import java.io.File;
import static javax.tools.Diagnostic.Kind.*;
import static javax.annotation.processing.Filer.Location.*;
@SupportedSourceVersion(javax.lang.model.SourceVersion.RELEASE_6)
@SupportedAnnotationTypes({"*"})
public class testAP extends AbstractProcessor
{
public static Messager msgr = null;
public static java.io.Writer FW = null;
Filer _filer = null;
File _reportFile = null;
String myfile = "./report.html";
public static String javaFile = null;
public testAP() { }
@Override
public void init(ProcessingEnvironment penv) {
processingEnv = penv;
msgr = penv.getMessager();
_filer = penv.getFiler();
try { _reportFile = new java.io.File(myfile);}
catch(Exception e1) {
System.out.println("Exception trying to create File for " + myfile);
}finally {
try{System.out.println("File Name: " + _reportFile.getCanonicalPath() );}
catch(java.io.IOException ioe){ ioe.printStackTrace(); }
}
try {
// FW = _filer.createTextFile(CLASS_TREE,"", _reportFile ,null);
FW = _filer.createTextFile(SOURCE_TREE,"", _reportFile ,null);
}
catch(FilerException fe) {
System.out.println(fe.toString());
}
catch(Exception some_other_excep) {
msgr.printMessage(ERROR, some_other_excep.toString());
some_other_excep.printStackTrace();
}
}
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv)
{
return true;
}
}