-
Bug
-
Resolution: Fixed
-
P4
-
6, 6u10
-
b06
-
generic
-
generic
-
Verified
Tried in Solaris10
<JDK-version>
java version "1.6.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta-b59)
Java HotSpot(TM) Client VM (build 1.6.0-beta-b59, mixed mode)
</JDK-version>
Please see the code
<code>
import java.io.PrintWriter;
import javax.tools.*;
public class Test7 {
public static void main(String... arg) throws Exception {
JavaCompilerTool javac = ToolProvider.defaultJavaCompiler();
JavaFileManager jfm = javac.getStandardFileManager();
JavaFileObject jfo = jfm.getFileForInput("Test8.java");
for(DiagnosticMessage message :
javac.run((PrintWriter)null, jfo).getDiagnostics()) {
System.out.println("Message.getSource :" + message.getSource());
System.out.println("Message.toString :" + message.toString());
}
}
}
</code>
The compile source for the above code
<code>
import java.util.ArrayList;
import java.util.List;
public class Test8 {
public static void main(String[] args) {
List<String> list = new ArrayList();
}
}
</code>
To reproduce the problem, Keep Test7 and Test8 in the same directory.
Note: Test7.java will compile Test8.java.
Test8 will throw NOTE. When the output is NOTE then DiagnosticMessage will give null for getSource. See the output
<output>
bash-3.00$ javac Test7.java
bash-3.00$ java Test7
Message.getSource :null
Message.toString :Note: Test8.java uses unchecked or unsafe operations.
Message.getSource :null
Message.toString :Note: Recompile with -Xlint:unchecked for details.
bash-3.00$
</output>
<JDK-version>
java version "1.6.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta-b59)
Java HotSpot(TM) Client VM (build 1.6.0-beta-b59, mixed mode)
</JDK-version>
Please see the code
<code>
import java.io.PrintWriter;
import javax.tools.*;
public class Test7 {
public static void main(String... arg) throws Exception {
JavaCompilerTool javac = ToolProvider.defaultJavaCompiler();
JavaFileManager jfm = javac.getStandardFileManager();
JavaFileObject jfo = jfm.getFileForInput("Test8.java");
for(DiagnosticMessage message :
javac.run((PrintWriter)null, jfo).getDiagnostics()) {
System.out.println("Message.getSource :" + message.getSource());
System.out.println("Message.toString :" + message.toString());
}
}
}
</code>
The compile source for the above code
<code>
import java.util.ArrayList;
import java.util.List;
public class Test8 {
public static void main(String[] args) {
List<String> list = new ArrayList();
}
}
</code>
To reproduce the problem, Keep Test7 and Test8 in the same directory.
Note: Test7.java will compile Test8.java.
Test8 will throw NOTE. When the output is NOTE then DiagnosticMessage will give null for getSource. See the output
<output>
bash-3.00$ javac Test7.java
bash-3.00$ java Test7
Message.getSource :null
Message.toString :Note: Test8.java uses unchecked or unsafe operations.
Message.getSource :null
Message.toString :Note: Recompile with -Xlint:unchecked for details.
bash-3.00$
</output>
- duplicates
-
JDK-6671152 Diagnostic.getSource() returns null
- Closed
- relates to
-
JDK-6427274 JSR 199: FileObject.openReader throws exception
- Closed
-
JDK-6469079 JSR 199: Diagnostic.getMessage(Locale) includes line numbers
- Closed