JDK-6440333 : SimpleJavaFileObject.toString() generates URI with some extra message
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-06-19
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b03Fixed
Related Reports
Relates :  
Relates :  
Description
SimpleJavaFileObject.toString() generates URI with some extra message

<testcase> 
import java.io.File;
import java.net.URI;
import javax.tools.*;
import static javax.tools.StandardLocation.*;
import static javax.tools.JavaFileObject.Kind.*;

class JFO extends SimpleJavaFileObject {
        public JFO(URI uri, Kind kind) {
            super(uri,kind);
        }
} 

public class Foo  {
    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("From JavaFileManager       ->" + jfo.toString());
        SimpleJavaFileObject sjfo = new JFO(jfo.toUri(), SOURCE);
        System.out.println("From SimpleJavaFileObject  ->" + sjfo.toString());
    }
}
</testcase> 
<output>
From JavaFileManager       -> .\Foo.java
From SimpleJavaFileObject  -> file:/Y:/MustangTestDev/tools/jsr199/JavaFileObject/JFOTest05/./Foo.java from JFO
</output>

1) In the output of SimpleJavaFileObject.toString() extra message 'from JFO' is not required.
2) There is inconsistency in the toString() message of JavaFileObject of StandardJavaFileManager and SimpleJavaFileObject.toString(). SimpleJavaFileObject generate more of URI.  

<java-version>
bash-3.00$ java -version
java version "1.6.0-rc"
Java(TM) SE Runtime Environment (build 1.6.0-rc-b88)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b88, mixed mode)
</java-vesrion>

Comments
EVALUATION Since the method isn't internationalized, it would be better to change the returned string to something like: getClass().getName() + "[" + toUri() + "]"
11-10-2006

EVALUATION To fix this problem, the URI returned by toUri() on the file object returned from DefaultFileManager should be fixed, not SimpleJavaFileObject.
10-10-2006

EVALUATION The "from JFO" part is intentional. However, the URI should be normalized.
30-09-2006