Java Code Examples for com.sun.tools.javac.code.Flags#ACYCLIC

The following examples show how to use com.sun.tools.javac.code.Flags#ACYCLIC . 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: Modules.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void setupAutomaticModule(ModuleSymbol msym) throws CompletionFailure {
    try {
        ListBuffer<Directive> directives = new ListBuffer<>();
        ListBuffer<ExportsDirective> exports = new ListBuffer<>();
        Set<String> seenPackages = new HashSet<>();

        for (JavaFileObject clazz : fileManager.list(msym.classLocation, "", EnumSet.of(Kind.CLASS,Kind.DEX_CALSS), true)) {
            String binName = fileManager.inferBinaryName(msym.classLocation, clazz);
            String pack = binName.lastIndexOf('.') != (-1) ? binName.substring(0, binName.lastIndexOf('.')) : ""; //unnamed package????
            if (seenPackages.add(pack)) {
                ExportsDirective d = new ExportsDirective(syms.enterPackage(msym, names.fromString(pack)), null);
                //TODO: opens?
                directives.add(d);
                exports.add(d);
            }
        }

        msym.exports = exports.toList();
        msym.provides = List.nil();
        msym.requires = List.nil();
        msym.uses = List.nil();
        msym.directives = directives.toList();
        msym.flags_field |= Flags.ACYCLIC;
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
 
Example 2
Source File: Modules.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void checkCyclicDependencies(JCModuleDecl mod) {
    for (JCDirective d : mod.directives) {
        JCRequires rd;
        if (!d.hasTag(Tag.REQUIRES) || (rd = (JCRequires) d).directive == null)
            continue;
        Set<ModuleSymbol> nonSyntheticDeps = new HashSet<>();
        List<ModuleSymbol> queue = List.of(rd.directive.module);
        while (queue.nonEmpty()) {
            ModuleSymbol current = queue.head;
            queue = queue.tail;
            if (!nonSyntheticDeps.add(current))
                continue;
            current.complete();
            if ((current.flags() & Flags.ACYCLIC) != 0)
                continue;
            Assert.checkNonNull(current.requires, current::toString);
            for (RequiresDirective dep : current.requires) {
                if (!dep.flags.contains(RequiresFlag.EXTRA))
                    queue = queue.prepend(dep.module);
            }
        }
        if (nonSyntheticDeps.contains(mod.sym)) {
            log.error(rd.moduleName.pos(), Errors.CyclicRequires(rd.directive.module));
        }
        mod.sym.flags_field |= Flags.ACYCLIC;
    }
}
 
Example 3
Source File: Modules.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void setupAutomaticModule(ModuleSymbol msym) throws CompletionFailure {
    try {
        ListBuffer<Directive> directives = new ListBuffer<>();
        ListBuffer<ExportsDirective> exports = new ListBuffer<>();
        Set<String> seenPackages = new HashSet<>();

        for (JavaFileObject clazz : fileManager.list(msym.classLocation, "", EnumSet.of(Kind.CLASS), true)) {
            String binName = fileManager.inferBinaryName(msym.classLocation, clazz);
            String pack = binName.lastIndexOf('.') != (-1) ? binName.substring(0, binName.lastIndexOf('.')) : ""; //unnamed package????
            if (seenPackages.add(pack)) {
                ExportsDirective d = new ExportsDirective(syms.enterPackage(msym, names.fromString(pack)), null);
                //TODO: opens?
                directives.add(d);
                exports.add(d);
            }
        }

        msym.exports = exports.toList();
        msym.provides = List.nil();
        msym.requires = List.nil();
        msym.uses = List.nil();
        msym.directives = directives.toList();
        msym.flags_field |= Flags.ACYCLIC;
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
 
Example 4
Source File: Modules.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void checkCyclicDependencies(JCModuleDecl mod) {
    for (JCDirective d : mod.directives) {
        JCRequires rd;
        if (!d.hasTag(Tag.REQUIRES) || (rd = (JCRequires) d).directive == null)
            continue;
        Set<ModuleSymbol> nonSyntheticDeps = new HashSet<>();
        List<ModuleSymbol> queue = List.of(rd.directive.module);
        while (queue.nonEmpty()) {
            ModuleSymbol current = queue.head;
            queue = queue.tail;
            if (!nonSyntheticDeps.add(current))
                continue;
            current.complete();
            if ((current.flags() & Flags.ACYCLIC) != 0)
                continue;
            Assert.checkNonNull(current.requires, current::toString);
            for (RequiresDirective dep : current.requires) {
                if (!dep.flags.contains(RequiresFlag.EXTRA))
                    queue = queue.prepend(dep.module);
            }
        }
        if (nonSyntheticDeps.contains(mod.sym)) {
            log.error(rd.moduleName.pos(), Errors.CyclicRequires(rd.directive.module));
        }
        mod.sym.flags_field |= Flags.ACYCLIC;
    }
}