-
Bug
-
Resolution: Fixed
-
P3
-
5.0
The attached test case fails. The test relies on an encoding
which can't be saved in bugster notes, the code is in a comment,
so here is the code without the comment:
import java.io.File;
import javax.tools.*;
public class TestEncoding {
static boolean error = false;
public static void main(String[] args) {
JavaCompilerTool compiler = ToolProvider.defaultJavaCompiler();
compiler.setFileManager(compiler.getStandardFileManager());
DiagnosticListener dl = new DiagnosticListener() {
public void report(DiagnosticMessage message) {
if (message.getKind() == DiagnosticMessage.Kind.ERROR)
error = true;
System.out.println(message.getSource()
+":"+message.getStartPosition()+":"
+message.getStartPosition()+":"+message.getPosition());
System.out.println(message.toString());
System.out.format("Found problem: %s%n", message.getKey());
System.out.flush();
}
};
String srcdir = System.getProperty("test.src");
String sourceName = new File(srcdir, "TestEncoding.java").getPath();
compiler.setOption("-source", 5);
compiler.setOption("-encoding", "utf-8");
compiler.run(null, dl, null, sourceName);
if (error)
throw new AssertionError("Error reported");
error = false;
compiler.setOption("-source", 5);
compiler.setOption("-encoding", "ascii");
compiler.run(null, dl, null, sourceName);
if (!error)
throw new AssertionError("No error reported");
error = false;
compiler.setOption("-source", 5);
compiler.setOption("-encoding", "utf-8");
compiler.run(null, dl, null, sourceName);
if (error)
throw new AssertionError("Error reported");
}
}
which can't be saved in bugster notes, the code is in a comment,
so here is the code without the comment:
import java.io.File;
import javax.tools.*;
public class TestEncoding {
static boolean error = false;
public static void main(String[] args) {
JavaCompilerTool compiler = ToolProvider.defaultJavaCompiler();
compiler.setFileManager(compiler.getStandardFileManager());
DiagnosticListener dl = new DiagnosticListener() {
public void report(DiagnosticMessage message) {
if (message.getKind() == DiagnosticMessage.Kind.ERROR)
error = true;
System.out.println(message.getSource()
+":"+message.getStartPosition()+":"
+message.getStartPosition()+":"+message.getPosition());
System.out.println(message.toString());
System.out.format("Found problem: %s%n", message.getKey());
System.out.flush();
}
};
String srcdir = System.getProperty("test.src");
String sourceName = new File(srcdir, "TestEncoding.java").getPath();
compiler.setOption("-source", 5);
compiler.setOption("-encoding", "utf-8");
compiler.run(null, dl, null, sourceName);
if (error)
throw new AssertionError("Error reported");
error = false;
compiler.setOption("-source", 5);
compiler.setOption("-encoding", "ascii");
compiler.run(null, dl, null, sourceName);
if (!error)
throw new AssertionError("No error reported");
error = false;
compiler.setOption("-source", 5);
compiler.setOption("-encoding", "utf-8");
compiler.run(null, dl, null, sourceName);
if (error)
throw new AssertionError("Error reported");
}
}