com.sun.tools.javac.nio.JavacPathFileManager Java Examples

The following examples show how to use com.sun.tools.javac.nio.JavacPathFileManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GetTask_FileManagerTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verify that an alternate file manager can be specified:
 * in this case, a PathFileManager.
 */
@Test
public void testFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null);
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    if (t.call()) {
        System.err.println("task succeeded");
        checkFiles(outDir, standardExpectFiles);
    } else {
        throw new Exception("task failed");
    }
}
 
Example #2
Source File: GetTask_FileManagerTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verify that an alternate file manager can be specified:
 * in this case, a PathFileManager.
 */
@Test
public void testFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null);
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    if (t.call()) {
        System.err.println("task succeeded");
        checkFiles(outDir, standardExpectFiles);
    } else {
        throw new Exception("task failed");
    }
}
 
Example #3
Source File: GetTask_FileManagerTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verify that an alternate file manager can be specified:
 * in this case, a PathFileManager.
 */
@Test
public void testFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null);
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    if (t.call()) {
        System.err.println("task succeeded");
        checkFiles(outDir, standardExpectFiles);
    } else {
        throw new Exception("task failed");
    }
}
 
Example #4
Source File: GetTask_FileManagerTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verify that an alternate file manager can be specified:
 * in this case, a PathFileManager.
 */
@Test
public void testFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null);
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    if (t.call()) {
        System.err.println("task succeeded");
        checkFiles(outDir, standardExpectFiles);
    } else {
        throw new Exception("task failed");
    }
}
 
Example #5
Source File: GetTask_FileManagerTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verify that an alternate file manager can be specified:
 * in this case, a PathFileManager.
 */
@Test
public void testFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null);
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    if (t.call()) {
        System.err.println("task succeeded");
        checkFiles(outDir, standardExpectFiles);
    } else {
        throw new Exception("task failed");
    }
}
 
Example #6
Source File: GetTask_FileManagerTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verify that an alternate file manager can be specified:
 * in this case, a PathFileManager.
 */
@Test
public void testFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null);
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    if (t.call()) {
        System.err.println("task succeeded");
        checkFiles(outDir, standardExpectFiles);
    } else {
        throw new Exception("task failed");
    }
}
 
Example #7
Source File: GetTask_FileManagerTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verify that an alternate file manager can be specified:
 * in this case, a PathFileManager.
 */
@Test
public void testFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null);
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    if (t.call()) {
        System.err.println("task succeeded");
        checkFiles(outDir, standardExpectFiles);
    } else {
        throw new Exception("task failed");
    }
}
 
Example #8
Source File: GetTask_FileManagerTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify that exceptions from a bad file manager are thrown as expected.
 */
@Test
public void testBadFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null) {
        @Override
        public Iterable<JavaFileObject> list(Location location,
                String packageName,
                Set<Kind> kinds,
                boolean recurse)
                throws IOException {
            throw new UnexpectedError();
        }
    };
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    try {
        t.call();
        error("call completed without exception");
    } catch (RuntimeException e) {
        Throwable c = e.getCause();
        if (c.getClass() == UnexpectedError.class)
            System.err.println("exception caught as expected: " + c);
        else
            throw e;
    }
}
 
Example #9
Source File: GetTask_FileManagerTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify that exceptions from a bad file manager are thrown as expected.
 */
@Test
public void testBadFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null) {
        @Override
        public Iterable<JavaFileObject> list(Location location,
                String packageName,
                Set<Kind> kinds,
                boolean recurse)
                throws IOException {
            throw new UnexpectedError();
        }
    };
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    try {
        t.call();
        error("call completed without exception");
    } catch (RuntimeException e) {
        Throwable c = e.getCause();
        if (c.getClass() == UnexpectedError.class)
            System.err.println("exception caught as expected: " + c);
        else
            throw e;
    }
}
 
Example #10
Source File: GetTask_FileManagerTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify that exceptions from a bad file manager are thrown as expected.
 */
@Test
public void testBadFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null) {
        @Override
        public Iterable<JavaFileObject> list(Location location,
                String packageName,
                Set<Kind> kinds,
                boolean recurse)
                throws IOException {
            throw new UnexpectedError();
        }
    };
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    try {
        t.call();
        error("call completed without exception");
    } catch (RuntimeException e) {
        Throwable c = e.getCause();
        if (c.getClass() == UnexpectedError.class)
            System.err.println("exception caught as expected: " + c);
        else
            throw e;
    }
}
 
Example #11
Source File: GetTask_FileManagerTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify that exceptions from a bad file manager are thrown as expected.
 */
@Test
public void testBadFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null) {
        @Override
        public Iterable<JavaFileObject> list(Location location,
                String packageName,
                Set<Kind> kinds,
                boolean recurse)
                throws IOException {
            throw new UnexpectedError();
        }
    };
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    try {
        t.call();
        error("call completed without exception");
    } catch (RuntimeException e) {
        Throwable c = e.getCause();
        if (c.getClass() == UnexpectedError.class)
            System.err.println("exception caught as expected: " + c);
        else
            throw e;
    }
}
 
Example #12
Source File: GetTask_FileManagerTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify that exceptions from a bad file manager are thrown as expected.
 */
@Test
public void testBadFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null) {
        @Override
        public Iterable<JavaFileObject> list(Location location,
                String packageName,
                Set<Kind> kinds,
                boolean recurse)
                throws IOException {
            throw new UnexpectedError();
        }
    };
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    try {
        t.call();
        error("call completed without exception");
    } catch (RuntimeException e) {
        Throwable c = e.getCause();
        if (c.getClass() == UnexpectedError.class)
            System.err.println("exception caught as expected: " + c);
        else
            throw e;
    }
}
 
Example #13
Source File: GetTask_FileManagerTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify that exceptions from a bad file manager are thrown as expected.
 */
@Test
public void testBadFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null) {
        @Override
        public Iterable<JavaFileObject> list(Location location,
                String packageName,
                Set<Kind> kinds,
                boolean recurse)
                throws IOException {
            throw new UnexpectedError();
        }
    };
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    try {
        t.call();
        error("call completed without exception");
    } catch (RuntimeException e) {
        Throwable c = e.getCause();
        if (c.getClass() == UnexpectedError.class)
            System.err.println("exception caught as expected: " + c);
        else
            throw e;
    }
}
 
Example #14
Source File: GetTask_FileManagerTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify that exceptions from a bad file manager are thrown as expected.
 */
@Test
public void testBadFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    PathFileManager fm = new JavacPathFileManager(new Context(), false, null) {
        @Override
        public Iterable<JavaFileObject> list(Location location,
                String packageName,
                Set<Kind> kinds,
                boolean recurse)
                throws IOException {
            throw new UnexpectedError();
        }
    };
    Path outDir = getOutDir().toPath();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
    try {
        t.call();
        error("call completed without exception");
    } catch (RuntimeException e) {
        Throwable c = e.getCause();
        if (c.getClass() == UnexpectedError.class)
            System.err.println("exception caught as expected: " + c);
        else
            throw e;
    }
}