langtools/test/tools/javac/6410653/T6410653.java
changeset 42270 3bd3e7e378b5
parent 40308 274367a99f98
child 42408 d6f09ae68eab
equal deleted inserted replaced
42268:3ef9e17b383a 42270:3bd3e7e378b5
    29  * @modules java.compiler
    29  * @modules java.compiler
    30  *          jdk.compiler/com.sun.tools.javac.util
    30  *          jdk.compiler/com.sun.tools.javac.util
    31  */
    31  */
    32 
    32 
    33 import java.lang.reflect.Field;
    33 import java.lang.reflect.Field;
       
    34 import java.lang.reflect.Module;
    34 import java.io.File;
    35 import java.io.File;
    35 import java.io.ByteArrayOutputStream;
    36 import java.io.ByteArrayOutputStream;
    36 import javax.tools.*;
    37 import javax.tools.*;
    37 
    38 
    38 public class T6410653 {
    39 public class T6410653 {
    39     public static void main(String... args) throws Exception {
    40     public static void main(String... args) throws Exception {
    40         File testSrc = new File(System.getProperty("test.src"));
    41         File testSrc = new File(System.getProperty("test.src"));
    41         String source = new File(testSrc, "T6410653.java").getPath();
    42         String source = new File(testSrc, "T6410653.java").getPath();
    42         ClassLoader cl = ToolProvider.getSystemToolClassLoader();
       
    43         Tool compiler = ToolProvider.getSystemJavaCompiler();
    43         Tool compiler = ToolProvider.getSystemJavaCompiler();
    44         Class<?> log = Class.forName("com.sun.tools.javac.util.Log", true, cl);
    44         Module compilerModule = compiler.getClass().getModule();
       
    45         Class<?> log = Class.forName(compilerModule, "com.sun.tools.javac.util.Log");
    45         Field useRawMessages = log.getDeclaredField("useRawMessages");
    46         Field useRawMessages = log.getDeclaredField("useRawMessages");
    46         useRawMessages.setAccessible(true);
    47         useRawMessages.setAccessible(true);
    47         useRawMessages.setBoolean(null, true);
    48         useRawMessages.setBoolean(null, true);
    48         ByteArrayOutputStream out = new ByteArrayOutputStream();
    49         ByteArrayOutputStream out = new ByteArrayOutputStream();
    49         compiler.run(null, null, out, "-d", source, source);
    50         compiler.run(null, null, out, "-d", source, source);