Details
-
Backport
-
Resolution: Won't Fix
-
P3
-
6
Description
javax.tools.FileObject.toUri() generates URI without schema under Solaris OS.
A URI generated by a FileObject produced by a StandardJavaFileManager should start with 'file:'.
(Potentially it can be java.io.File problem)
test:
----------------------
import javax.tools.*;
import java.util.*;
import java.io.*;
import java.net.URI;
class test5 {
public static void main(String[] argv){
JavaCompilerTool compiler = ToolProvider.getSystemJavaCompilerTool();
StandardJavaFileManager mgr = compiler.getStandardFileManager( new DiagnosticCollector<JavaFileObject>() );
System.out.println( new File( new File(".").toURI() ).getAbsolutePath() );
mgr.setLocation(StandardJavaFileManager.StandardLocation.CLASS_OUTPUT,
Collections.singleton(new File( new File(".").toURI())));
try {
FileObject fo = mgr.getFileForOutput(StandardJavaFileManager.StandardLocation.CLASS_OUTPUT,
"", URI.create("file.to.delete"), null);
System.out.println( fo.toUri() );
} catch( IOException x ){
x.printStackTrace(System.out);
}
}
}
----------------------
output under Solaris:
----------------------
it162333@~/tests>java -cp . test5
/home/it162333/tests/.
/home/it162333/tests/./file.to.delete
----------------------
output under Windows:
----------------------
Z:\tests>z:/lnks/jdk6/bin/java.exe -cp . test5
Z:\tests\.
file:/Z:/tests/./file.to.delete
----------------------
tests failed
> api/javax_tools/FileObject/index.html#All[delete0001]
> api/javax_tools/FileObject/index.html#All[getCharContent0001]
> api/javax_tools/FileObject/index.html#All[getCharContent0002]
> api/javax_tools/FileObject/index.html#All[getInputStream0001]
> api/javax_tools/FileObject/index.html#All[getLastModified0001]
> api/javax_tools/FileObject/index.html#All[getOutputStream0001]
> api/javax_tools/FileObject/index.html#All[openReader0001]
> api/javax_tools/FileObject/index.html#All[openWriter0001]
> api/javax_tools/FileObject/index.html#All[toUri0001]
> api/javax_tools/JavaFileObject/index.html#All[getKind0001]
Failing Test: javac/api/JFOTest05
Also FileObject.toUri() generates URI with one extra '.', which is not required.
Please see the attached testcase
<testcase>
import javax.tools.*;
import static javax.tools.StandardLocation.*;
import static javax.tools.JavaFileObject.Kind.*;
public class T6419926 {
public static void main(String... arg) throws Exception {
JavaCompilerTool javac =
ToolProvider.getSystemJavaCompilerTool();
JavaFileManager jfm = javac.getStandardFileManager(null);
JavaFileObject jfo =
jfm.getJavaFileForInput(CLASS_PATH,"Foo",SOURCE);
System.out.println(jfo.toUri().toURL()); // to check - generates URI without schema.
if(!jfo.toUri().toString().equals(jfo.toUri().resolve(
jfo.toUri()).toString())) // Extra dot is not required.
throw new Exception("Check the generated URI");
}
}
</testcase>
Failing Tests: javac/api/JFOTest05, javac/api/JFOTest06
failing testcases: javac/api/JavaFileObject/JFOTest05 , javac/api/JavaFileObject/JFOTest06
A URI generated by a FileObject produced by a StandardJavaFileManager should start with 'file:'.
(Potentially it can be java.io.File problem)
test:
----------------------
import javax.tools.*;
import java.util.*;
import java.io.*;
import java.net.URI;
class test5 {
public static void main(String[] argv){
JavaCompilerTool compiler = ToolProvider.getSystemJavaCompilerTool();
StandardJavaFileManager mgr = compiler.getStandardFileManager( new DiagnosticCollector<JavaFileObject>() );
System.out.println( new File( new File(".").toURI() ).getAbsolutePath() );
mgr.setLocation(StandardJavaFileManager.StandardLocation.CLASS_OUTPUT,
Collections.singleton(new File( new File(".").toURI())));
try {
FileObject fo = mgr.getFileForOutput(StandardJavaFileManager.StandardLocation.CLASS_OUTPUT,
"", URI.create("file.to.delete"), null);
System.out.println( fo.toUri() );
} catch( IOException x ){
x.printStackTrace(System.out);
}
}
}
----------------------
output under Solaris:
----------------------
it162333@~/tests>java -cp . test5
/home/it162333/tests/.
/home/it162333/tests/./file.to.delete
----------------------
output under Windows:
----------------------
Z:\tests>z:/lnks/jdk6/bin/java.exe -cp . test5
Z:\tests\.
file:/Z:/tests/./file.to.delete
----------------------
tests failed
> api/javax_tools/FileObject/index.html#All[delete0001]
> api/javax_tools/FileObject/index.html#All[getCharContent0001]
> api/javax_tools/FileObject/index.html#All[getCharContent0002]
> api/javax_tools/FileObject/index.html#All[getInputStream0001]
> api/javax_tools/FileObject/index.html#All[getLastModified0001]
> api/javax_tools/FileObject/index.html#All[getOutputStream0001]
> api/javax_tools/FileObject/index.html#All[openReader0001]
> api/javax_tools/FileObject/index.html#All[openWriter0001]
> api/javax_tools/FileObject/index.html#All[toUri0001]
> api/javax_tools/JavaFileObject/index.html#All[getKind0001]
Failing Test: javac/api/JFOTest05
Also FileObject.toUri() generates URI with one extra '.', which is not required.
Please see the attached testcase
<testcase>
import javax.tools.*;
import static javax.tools.StandardLocation.*;
import static javax.tools.JavaFileObject.Kind.*;
public class T6419926 {
public static void main(String... arg) throws Exception {
JavaCompilerTool javac =
ToolProvider.getSystemJavaCompilerTool();
JavaFileManager jfm = javac.getStandardFileManager(null);
JavaFileObject jfo =
jfm.getJavaFileForInput(CLASS_PATH,"Foo",SOURCE);
System.out.println(jfo.toUri().toURL()); // to check - generates URI without schema.
if(!jfo.toUri().toString().equals(jfo.toUri().resolve(
jfo.toUri()).toString())) // Extra dot is not required.
throw new Exception("Check the generated URI");
}
}
</testcase>
Failing Tests: javac/api/JFOTest05, javac/api/JFOTest06
failing testcases: javac/api/JavaFileObject/JFOTest05 , javac/api/JavaFileObject/JFOTest06
Attachments
Issue Links
- backport of
-
JDK-6419926 JSR 199: FileObject.toUri() generates URI without schema (Solaris)
- Closed
- duplicates
-
JDK-2141204 JSR 199: FileObject.toUri() generates URI without schema (Solaris)
- Closed