United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7046929 tools/javac/api/T6397104.java fails
JDK-7046929 : tools/javac/api/T6397104.java fails

Details
Type:
Bug
Submit Date:
2011-05-20
Status:
Closed
Updated Date:
2012-05-07
Project Name:
JDK
Resolved Date:
2012-04-20
Component:
tools
OS:
windows_2008,windows_xp
Sub-Component:
javac
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
6u27,7
Fixed Versions:

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

Description
In JDK 6, this test passes on linux/solaris and fails on windows.
In JDK 7, this test has an @ignore.  If that is removed, the test fails on all platforms.

                                    

Comments
SUGGESTED FIX

- Fix the test to expect FileObject.toUri() to return an absolute URI instead of a relative URI.

- Remove the @ignore from the test
                                     
2011-05-20
EVALUATION

The problem is that the test calls FileObject.toUri() and expects to get back a relative URI, which it does on JDK 6 on linux/solaris, but not on JDK 6 on windows, nor on JDK 7.

In JDK 6 on windows, the FileObject's path contains \\ chars which are illegal in a URI, which causes FileObject.toUri() to return an absolute URI instead of a relative URI.

In JDK 7, FileObject.toUri() has been fixed to return an absolute URI - See:
   6419926  JSR 199: FileObject.toUri() generates URI without schema (Solaris)
                                     
2011-05-20
SUGGESTED FIX

diff -r bdfa48f80c82 test/tools/javac/api/T6397104.java
--- a/test/tools/javac/api/T6397104.java	Wed May 11 14:55:02 2011 -0700
+++ b/test/tools/javac/api/T6397104.java	Tue May 24 11:57:46 2011 -0700
@@ -26,10 +26,10 @@
  * @bug     6397104
  * @summary JSR 199: JavaFileManager.getFileForOutput should have sibling argument
  * @author  Peter von der Ah\u00e9
- * @ignore  this test should be rewritten when fixing 6473901
  */
 
 import java.io.File;
+import java.net.URI;
 import java.util.Arrays;
 import javax.tools.*;
 import javax.tools.JavaFileManager.Location;
@@ -52,10 +52,14 @@
             : fm.getJavaFileObjectsFromFiles(Arrays.asList(siblingFile)).iterator().next();
         FileObject fileObject =
             fm.getFileForOutput(location, "java.lang", relName, sibling);
-        if (!fileObject.toUri().getPath().equals(expectedPath))
-            throw new AssertionError("Expected " + expectedPath +
-                                     ", got " + fileObject.toUri().getPath());
-        System.out.format("OK: (%s, %s) => %s%n", siblingFile, relName, fileObject.toUri());
+
+        File expectedFile = new File(expectedPath).getCanonicalFile();
+        File fileObjectFile = new File(fileObject.toUri()).getCanonicalFile();
+
+        if (!fileObjectFile.equals(expectedFile))
+	    throw new AssertionError("Expected " + expectedFile +
+				     ", got " + fileObjectFile);
+	System.out.format("OK: (%s, %s) => %s%n", siblingFile, relName, fileObjectFile);
     }
 
     void test(boolean hasLocation, File siblingFile, String relName, String expectedPath)
                                     
2011-05-20



Hardware and Software, Engineered to Work Together