Examples of JavacFileManager


Examples of com.sun.tools.javac.file.JavacFileManager

            if (!useSymbolFile) {
                Options options = Options.instance(c);
                options.put("ignore.symbol.file", "true");
            }

            return new JavacFileManager(c, false, null);
        } finally {
            if (resetProperties) {
                if (prev == null) {
                    System.getProperties().remove("useJavaUtilZip");
                } else {
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

        else
            System.setProperty("useJavaUtilZip", "true");
        Options options = Options.instance(ctx);
        if (symFileKind == IGNORE_SYMBOL_FILE)
            options.put("ignore.symbol.file", "true");
        JavacFileManager fm = new JavacFileManager(ctx, false, null);
        List<File> path = getPath(System.getProperty(classpathProperty));
        fm.setLocation(CLASS_PATH, path);
        return fm;
    }
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

            if (!files.isEmpty()) {
                // add filenames to fileObjects
                comp = JavaCompiler.instance(context);
                List<JavaFileObject> otherFiles = List.nil();
                JavacFileManager dfm = (JavacFileManager)fileManager;
                for (JavaFileObject fo : dfm.getJavaFileObjectsFromFiles(files))
                    otherFiles = otherFiles.prepend(fo);
                for (JavaFileObject fo : otherFiles)
                    fileObjects = fileObjects.prepend(fo);
            }
            comp.compile(fileObjects,
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

            context.put(DiagnosticListener.class, diagnosticListener);
        PrintWriter pw = (charset == null)
                ? new PrintWriter(System.err, true)
                : new PrintWriter(new OutputStreamWriter(System.err, charset), true);
        context.put(Log.outKey, pw);
        return new JavacFileManager(context, true, charset);
    }
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

    /** Parse contents of file.
     *  @param filename     The name of the file to be parsed.
     */
    @Deprecated
    public JCTree.JCCompilationUnit parse(String filename) {
        JavacFileManager fm = (JavacFileManager)fileManager;
        return parse(fm.getJavaFileObjectsFromStrings(List.of(filename)).iterator().next());
    }
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

                else
                    origOptions.put(s, value);
            }
            origOptions = Collections.unmodifiableMap(origOptions);

            JavacFileManager fm = (JavacFileManager) context.get(JavaFileManager.class);
            {
                // Note: it might be necessary to check for an empty
                // component ("") of the source path or class path

                String sourceDest = options.get("-s");
                if (fm.hasLocation(StandardLocation.SOURCE_PATH)) {
                    for(File f: fm.getLocation(StandardLocation.SOURCE_PATH))
                        augmentedSourcePath += (f + File.pathSeparator);
                    augmentedSourcePath += (sourceDest == null)?".":sourceDest;
                } else {
                    augmentedSourcePath = ".";

                    if (sourceDest != null)
                        augmentedSourcePath += (File.pathSeparator + sourceDest);
                }

                String classDest = options.get("-d");
                if (fm.hasLocation(StandardLocation.CLASS_PATH)) {
                    for(File f: fm.getLocation(StandardLocation.CLASS_PATH))
                        baseClassPath += (f + File.pathSeparator);
                    // put baseClassPath into map to handle any
                    // value needed for the classloader
                    options.put("-classpath", baseClassPath);

                    augmentedClassPath = baseClassPath + ((classDest == null)?".":classDest);
                } else {
                    baseClassPath = ".";
                    if (classDest != null)
                        augmentedClassPath = baseClassPath + (File.pathSeparator + classDest);
                }
                assert options.get("-classpath") != null;
            }

            /*
             * Create base and augmented class loaders
             */
            ClassLoader augmentedAptCL = null;
            {
            /*
             * Use a url class loader to look for classes on the
             * user-specified class path. Prepend computed bootclass
             * path, which includes extdirs, to the URLClassLoader apt
             * uses.
             */
                String aptclasspath = "";
                String bcp = "";
                Iterable<? extends File> bootclasspath = fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH);

                if (bootclasspath != null) {
                    for(File f: bootclasspath)
                        bcp += (f + File.pathSeparator);
                }
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

        // of test classes come from the same class loader. This is important
        // because the test performs class checks on the instances of classes
        // found in the context for each round or processing.
        context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
            public JavaFileManager make(Context c) {
                return new JavacFileManager(c, true, null) {
                    @Override
                    protected ClassLoader getClassLoader(URL[] urls) {
                        return new URLClassLoader(urls, T7021650.class.getClassLoader());
                    }
                };
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

     *
     * @param file a file
     * @return a JavaFileObject from the standard file manager.
     */
    public JavaFileObject asJavaFileObject(File file) {
        JavacFileManager fm = (JavacFileManager)context.get(JavaFileManager.class);
        return fm.getRegularFile(file);
    }
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

        long msec = System.currentTimeMillis();

        ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
        try {
            JavacFileManager fm = (JavacFileManager)fileManager;
            //parse all files
            ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
            for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
                if (classesAsDecls) {
                    if (! l.head.endsWith(".java") ) { // process as class file
                        ClassSymbol cs = reader.enterClass(names.fromString(l.head));
                        try {
                            cs.complete();
                        } catch(Symbol.CompletionFailure cf) {
                            bark.aptError("CantFindClass", l);
                            continue;
                        }

                        classes.append(cs); // add to list of classes
                        continue;
                    }
                }
                JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next();
                trees.append(parse(fo));
            }

            //enter symbols for all files
            List<JCCompilationUnit> roots = trees.toList();
View Full Code Here

Examples of com.sun.tools.javac.file.JavacFileManager

        long zfiTime = zfi.getLastModified(TEST_ENTRY_NAME);

        check(je, jarEntryTime, zfi + ":" + TEST_ENTRY_NAME.getPath(), zfiTime);

        Context context = new Context();
        JavacFileManager fm = new JavacFileManager(context, false, null);
        ZipFileIndexArchive zfia = new ZipFileIndexArchive(fm, zfi);
        JavaFileObject jfo =
            zfia.getFileObject(TEST_ENTRY_NAME.dirname(),
                                   TEST_ENTRY_NAME.basename());
        long jfoTime = jfo.getLastModified();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.