langtools/test/tools/javac/api/6440528/T6440528.java
changeset 34560 b6a567b677f7
parent 30730 d3ce7619db2c
child 36526 3b41f1c69604
equal deleted inserted replaced
34481:e0ff9821f1e8 34560:b6a567b677f7
    53         FileObject cls = fm.getFileForOutput(CLASS_OUTPUT,
    53         FileObject cls = fm.getFileForOutput(CLASS_OUTPUT,
    54                                              "com.sun.foo.bar.baz",
    54                                              "com.sun.foo.bar.baz",
    55                                              "package-info.class",
    55                                              "package-info.class",
    56                                              src);
    56                                              src);
    57         File expect = new File(test_src, "package-info.class");
    57         File expect = new File(test_src, "package-info.class");
    58         File got = getUnderlyingFile(cls);
    58         File got = fm.asPath(cls).toFile();
    59         if (!got.equals(expect))
    59         if (!got.equals(expect))
    60             throw new AssertionError(String.format("Expected: %s; got: %s", expect, got));
    60             throw new AssertionError(String.format("Expected: %s; got: %s", expect, got));
    61         System.err.println("Expected: " + expect);
    61         System.err.println("Expected: " + expect);
    62         System.err.println("Got:      " + got);
    62         System.err.println("Got:      " + got);
    63     }
       
    64 
       
    65     private File getUnderlyingFile(FileObject o) throws Exception {
       
    66         Field file = o.getClass().getDeclaredField("file"); // assumes RegularFileObject
       
    67         file.setAccessible(true);
       
    68         return ((Path)file.get(o)).toFile();
       
    69     }
    63     }
    70 
    64 
    71     public static void main(String... args) throws Exception {
    65     public static void main(String... args) throws Exception {
    72         try (T6440528 t = new T6440528()) {
    66         try (T6440528 t = new T6440528()) {
    73             t.test(args);
    67             t.test(args);