Java Code Examples for com.sun.tools.javac.util.Assert

The following examples show how to use com.sun.tools.javac.util.Assert. These examples are extracted from open source projects. 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
void checkDefaultInterface(TypeElement te) {
    System.err.println("Checking " + te.getSimpleName());
    Assert.check(te.getModifiers().contains(Modifier.ABSTRACT));
    for (Element e : te.getEnclosedElements()) {
        if (e.getSimpleName().toString().matches("(\\w)_(default|static|abstract)")) {
            boolean abstractExpected = false;
            String methodKind = e.getSimpleName().toString().substring(2);
            switch (methodKind) {
                case "default":
                case "static":
                    break;
                case "abstract":
                    abstractExpected = true;
                    break;
                default:
                    Assert.error("Cannot get here!" + methodKind);
            }
            Assert.check(e.getModifiers().contains(Modifier.ABSTRACT) == abstractExpected);
        }
    }
}
 
Example 2
void checkClassFile(final File cfile, String[] methodsToFind) throws Exception {
    ClassFile classFile = ClassFile.read(cfile);
    int numberOfmethodsFound = 0;
    for (String methodToFind : methodsToFind) {
        for (Method method : classFile.methods) {
            if (method.getName(classFile.constant_pool).equals(methodToFind)) {
                numberOfmethodsFound++;
                Code_attribute code = (Code_attribute) method.attributes.get("Code");
                Assert.check(code.exception_table_length == expectedExceptionTable.length,
                        "The ExceptionTable found has a length different to the expected one");
                int i = 0;
                for (Exception_data entry: code.exception_table) {
                    Assert.check(entry.start_pc == expectedExceptionTable[i][0] &&
                            entry.end_pc == expectedExceptionTable[i][1] &&
                            entry.handler_pc == expectedExceptionTable[i][2] &&
                            entry.catch_type == expectedExceptionTable[i][3],
                            "Exception table entry at pos " + i + " differ from expected.");
                    i++;
                }
            }
        }
    }
    Assert.check(numberOfmethodsFound == 2, "Some seek methods were not found");
}
 
Example 3
Source Project: openjdk-jdk9   Source File: BuildState.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Store references to all artifacts found in the module tree into the maps
 * stored in the build state.
 *
 * @param m The set of modules.
 */
public void flattenArtifacts(Map<String,Module> m) {
    modules = m;
    // Extract all the found packages.
    for (Module i : modules.values()) {
        for (Map.Entry<String,Package> j : i.packages().entrySet()) {
            Package p = packages.get(j.getKey());
            // Check that no two different packages are stored under same name.
            Assert.check(p == null || p == j.getValue());
            p = j.getValue();
            packages.put(j.getKey(),j.getValue());
            for (Map.Entry<String,File> g : p.artifacts().entrySet()) {
                File f = artifacts.get(g.getKey());
                // Check that no two artifacts are stored under the same file.
                Assert.check(f == null || f == g.getValue());
                artifacts.put(g.getKey(), g.getValue());
            }
        }
    }
}
 
Example 4
@Override
public void complete(ClassSymbol sym) {
    Assert.check(proxyOn == sym);
    Attribute.Compound theTarget = null, theRepeatable = null;
    AnnotationDeproxy deproxy;

    try {
        if (target != null) {
            deproxy = new AnnotationDeproxy(proxyOn);
            theTarget = deproxy.deproxyCompound(target);
        }

        if (repeatable != null) {
            deproxy = new AnnotationDeproxy(proxyOn);
            theRepeatable = deproxy.deproxyCompound(repeatable);
        }
    } catch (Exception e) {
        throw new CompletionFailure(sym, ClassReader.this.diagFactory.fragment(Fragments.ExceptionMessage(e.getMessage())));
    }

    sym.getAnnotationTypeMetadata().setTarget(theTarget);
    sym.getAnnotationTypeMetadata().setRepeatable(theRepeatable);
}
 
Example 5
void run() throws Exception {
    Context context = new Context();
    JavacFileManager.preRegister(context);
    final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, Arrays.asList(new JavaSource()));
    Iterable<? extends CompilationUnitTree> elements = ct.parse();
    ct.analyze();
    Assert.check(elements.iterator().hasNext());
    JCTree topLevel = (JCTree)elements.iterator().next();
    new TreeScanner() {
        @Override
        public void visitReference(JCMemberReference tree) {
            Assert.check(tree.getOverloadKind() != null);
        }
    }.scan(topLevel);
}
 
Example 6
void checkClassFile(final File cfile, String methodToFind) throws Exception {
    ClassFile classFile = ClassFile.read(cfile);
    boolean methodFound = false;
    for (Method method : classFile.methods) {
        if (method.getName(classFile.constant_pool).equals(methodToFind)) {
            methodFound = true;
            Code_attribute code = (Code_attribute) method.attributes.get("Code");
            LineNumberTable_attribute lnt =
                    (LineNumberTable_attribute) code.attributes.get("LineNumberTable");
            Assert.check(lnt.line_number_table_length == expectedLNT.length,
                    "The LineNumberTable found has a length different to the expected one");
            int i = 0;
            for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) {
                Assert.check(entry.line_number == expectedLNT[i][0] &&
                        entry.start_pc == expectedLNT[i][1],
                        "LNT entry at pos " + i + " differ from expected." +
                        "Found " + entry.line_number + ":" + entry.start_pc +
                        ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]);
                i++;
            }
        }
    }
    Assert.check(methodFound, "The seek method was not found");
}
 
Example 7
/** Create a round (common code). */
private Round(Context context, int number, int priorErrors, int priorWarnings,
        Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
    this.context = context;
    this.number = number;

    compiler = JavaCompiler.instance(context);
    log = Log.instance(context);
    log.nerrors = priorErrors;
    log.nwarnings = priorWarnings;
    if (number == 1) {
        Assert.checkNonNull(deferredDiagnosticHandler);
        this.deferredDiagnosticHandler = deferredDiagnosticHandler;
    } else {
        this.deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
    }

    // the following is for the benefit of JavacProcessingEnvironment.getContext()
    JavacProcessingEnvironment.this.context = context;

    // the following will be populated as needed
    topLevelClasses  = List.nil();
    packageInfoFiles = List.nil();
}
 
Example 8
void checkClassFile(final File cfile, String[] methodsToFind) throws Exception {
    ClassFile classFile = ClassFile.read(cfile);
    int numberOfmethodsFound = 0;
    for (String methodToFind : methodsToFind) {
        for (Method method : classFile.methods) {
            if (method.getName(classFile.constant_pool).equals(methodToFind)) {
                numberOfmethodsFound++;
                Code_attribute code = (Code_attribute) method.attributes.get("Code");
                Assert.check(code.exception_table_length == expectedExceptionTable.length,
                        "The ExceptionTable found has a length different to the expected one");
                int i = 0;
                for (Exception_data entry: code.exception_table) {
                    Assert.check(entry.start_pc == expectedExceptionTable[i][0] &&
                            entry.end_pc == expectedExceptionTable[i][1] &&
                            entry.handler_pc == expectedExceptionTable[i][2] &&
                            entry.catch_type == expectedExceptionTable[i][3],
                            "Exception table entry at pos " + i + " differ from expected.");
                    i++;
                }
            }
        }
    }
    Assert.check(numberOfmethodsFound == 2, "Some seek methods were not found");
}
 
Example 9
void checkClassFile(final File cfile, String methodToFind) throws Exception {
    ClassFile classFile = ClassFile.read(cfile);
    boolean methodFound = false;
    for (Method method : classFile.methods) {
        if (method.getName(classFile.constant_pool).equals(methodToFind)) {
            methodFound = true;
            Code_attribute code = (Code_attribute) method.attributes.get("Code");
            LineNumberTable_attribute lnt =
                    (LineNumberTable_attribute) code.attributes.get("LineNumberTable");
            Assert.check(lnt.line_number_table_length == expectedLNT.length,
                    foundLNTLengthDifferentThanExpMsg);
            int i = 0;
            for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) {
                Assert.check(entry.line_number == expectedLNT[i][0] &&
                        entry.start_pc == expectedLNT[i][1],
                        "LNT entry at pos " + i + " differ from expected." +
                        "Found " + entry.line_number + ":" + entry.start_pc +
                        ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]);
                i++;
            }
        }
    }
    Assert.check(methodFound, seekMethodNotFoundMsg);
}
 
Example 10
private static StringConcat makeConcat(Context context) {
    Target target = Target.instance(context);
    String opt = Options.instance(context).get("stringConcat");
    if (target.hasStringConcatFactory()) {
        if (opt == null) {
            opt = "inline";//"indyWithConstants";
        }
    } else {
        if (opt != null && !"inline".equals(opt)) {
            Assert.error("StringConcatFactory-based string concat is requested on a platform that does not support it.");
        }
        opt = "inline";
    }

    switch (opt) {
        case "inline":
            return new Inline(context);
        case "indy":
            return new IndyPlain(context);
        case "indyWithConstants":
            return new IndyConstants(context);
        default:
            Assert.error("Unknown stringConcat: " + opt);
            throw new IllegalStateException("Unknown stringConcat: " + opt);
    }
}
 
Example 11
void checkClassFile(final File cfile, String[] methodsToFind) throws Exception {
    ClassFile classFile = ClassFile.read(cfile);
    int numberOfmethodsFound = 0;
    for (String methodToFind : methodsToFind) {
        for (Method method : classFile.methods) {
            if (method.getName(classFile.constant_pool).equals(methodToFind)) {
                numberOfmethodsFound++;
                Code_attribute code = (Code_attribute) method.attributes.get("Code");
                Assert.check(code.exception_table_length == expectedExceptionTable.length,
                        "The ExceptionTable found has a length different to the expected one");
                int i = 0;
                for (Exception_data entry: code.exception_table) {
                    Assert.check(entry.start_pc == expectedExceptionTable[i][0] &&
                            entry.end_pc == expectedExceptionTable[i][1] &&
                            entry.handler_pc == expectedExceptionTable[i][2] &&
                            entry.catch_type == expectedExceptionTable[i][3],
                            "Exception table entry at pos " + i + " differ from expected.");
                    i++;
                }
            }
        }
    }
    Assert.check(numberOfmethodsFound == 2, "Some seek methods were not found");
}
 
Example 12
/** Remove all entries of this scope from its table, if shared
 *  with next.
 */
public WriteableScope leave() {
    Assert.check(shared == 0);
    if (table != next.table) return next;
    while (elems != null) {
        int hash = getIndex(elems.sym.name);
        Entry e = table[hash];
        Assert.check(e == elems, elems.sym);
        table[hash] = elems.shadowed;
        elems = elems.sibling;
    }
    Assert.check(next.shared > 0);
    next.shared--;
    next.nelems = nelems;
    // System.out.println("====> leaving scope " + this.hashCode() + " owned by " + this.owner + " to " + next.hashCode());
    // new Error().printStackTrace(System.out);
    return next;
}
 
Example 13
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    for (Element el : roundEnv.getElementsAnnotatedWith(Generate.class)) {
        Generate g = el.getAnnotation(Generate.class);

        Assert.checkNonNull(g);

        try (OutputStream out =
                processingEnv.getFiler().createSourceFile(g.fileName()).openOutputStream()) {
            out.write(g.content().getBytes());
        } catch (IOException ex) {
            throw new IllegalStateException(ex);
        }
    }

    return false;
}
 
Example 14
void checkClassFile(final File cfile, String[] methodsToFind) throws Exception {
    ClassFile classFile = ClassFile.read(cfile);
    int numberOfmethodsFound = 0;
    for (String methodToFind : methodsToFind) {
        for (Method method : classFile.methods) {
            if (method.getName(classFile.constant_pool).equals(methodToFind)) {
                numberOfmethodsFound++;
                Code_attribute code = (Code_attribute) method.attributes.get("Code");
                Assert.check(code.exception_table_length == expectedExceptionTable.length,
                        "The ExceptionTable found has a length different to the expected one");
                int i = 0;
                for (Exception_data entry: code.exception_table) {
                    Assert.check(entry.start_pc == expectedExceptionTable[i][0] &&
                            entry.end_pc == expectedExceptionTable[i][1] &&
                            entry.handler_pc == expectedExceptionTable[i][2] &&
                            entry.catch_type == expectedExceptionTable[i][3],
                            "Exception table entry at pos " + i + " differ from expected.");
                    i++;
                }
            }
        }
    }
    Assert.check(numberOfmethodsFound == 2, "Some seek methods were not found");
}
 
Example 15
/** Create a round (common code). */
private Round(Context context, int number, int priorErrors, int priorWarnings,
        Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
    this.context = context;
    this.number = number;

    compiler = JavaCompiler.instance(context);
    log = Log.instance(context);
    log.nerrors = priorErrors;
    log.nwarnings = priorWarnings;
    if (number == 1) {
        Assert.checkNonNull(deferredDiagnosticHandler);
        this.deferredDiagnosticHandler = deferredDiagnosticHandler;
    } else {
        this.deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
    }

    // the following is for the benefit of JavacProcessingEnvironment.getContext()
    JavacProcessingEnvironment.this.context = context;

    // the following will be populated as needed
    topLevelClasses  = List.nil();
    packageInfoFiles = List.nil();
}
 
Example 16
Source Project: openjdk-jdk9   Source File: SymbolMetadata.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void setAttributes(SymbolMetadata other) {
    if (other == null) {
        throw new NullPointerException();
    }
    setDeclarationAttributes(other.getDeclarationAttributes());
    if ((sym.flags() & Flags.BRIDGE) != 0) {
        Assert.check(other.sym.kind == Kind.MTH);
        ListBuffer<TypeCompound> typeAttributes = new ListBuffer<>();
        for (TypeCompound tc : other.getTypeAttributes()) {
            // Carry over only contractual type annotations: i.e nothing interior to method body.
            if (!tc.position.type.isLocal())
                typeAttributes.append(tc);
        }
        setTypeAttributes(typeAttributes.toList());
    } else {
        setTypeAttributes(other.getTypeAttributes());
    }
    if (sym.kind == Kind.TYP) {
        setInitTypeAttributes(other.getInitTypeAttributes());
        setClassInitTypeAttributes(other.getClassInitTypeAttributes());
    }
}
 
Example 17
public boolean process(Set<? extends TypeElement> annotations,
                       RoundEnvironment roundEnv) {
    if (!roundEnv.processingOver()) {
        boolean hasRun = false;
        for (Element element : roundEnv.getRootElements())
            for (TypeElement te : typesIn(element.getEnclosedElements()))
                if (te.getQualifiedName().contentEquals("TestNonInherited.T2")) {
                    hasRun = true;
                    Foo[] foos = te.getAnnotationsByType(Foo.class);
                    System.out.println("  " + te);
                    System.out.println("  " + Arrays.asList(foos));
                    Assert.check(foos.length == 0, "Should not find any instance of @Foo");
                }
        if (!hasRun)
            throw new RuntimeException("The annotation processor could not find the declaration of T2, test broken!");
    }
    return true;
}
 
Example 18
Source Project: TencentKona-8   Source File: Pool.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check consistency of reference kind and symbol (see JVMS 4.4.8)
 */
@SuppressWarnings("fallthrough")
private void checkConsistent() {
    boolean staticOk = false;
    int expectedKind = -1;
    Filter<Name> nameFilter = nonInitFilter;
    boolean interfaceOwner = false;
    switch (refKind) {
        case ClassFile.REF_getStatic:
        case ClassFile.REF_putStatic:
            staticOk = true;
        case ClassFile.REF_getField:
        case ClassFile.REF_putField:
            expectedKind = Kinds.VAR;
            break;
        case ClassFile.REF_newInvokeSpecial:
            nameFilter = initFilter;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeInterface:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeStatic:
            interfaceOwner = true;
            staticOk = true;
        case ClassFile.REF_invokeVirtual:
            expectedKind = Kinds.MTH;
            break;
        case ClassFile.REF_invokeSpecial:
            interfaceOwner = true;
            expectedKind = Kinds.MTH;
            break;
    }
    Assert.check(!refSym.isStatic() || staticOk);
    Assert.check(refSym.kind == expectedKind);
    Assert.check(nameFilter.accepts(refSym.name));
    Assert.check(!refSym.owner.isInterface() || interfaceOwner);
}
 
Example 19
private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) {
    List<ClassSymbol> classes = List.nil();
    for (JCCompilationUnit unit : units) {
        for (JCTree node : unit.defs) {
            if (node.hasTag(JCTree.Tag.CLASSDEF)) {
                ClassSymbol sym = ((JCClassDecl) node).sym;
                Assert.checkNonNull(sym);
                classes = classes.prepend(sym);
            }
        }
    }
    return classes.reverse();
}
 
Example 20
/**
 * For a serializable lambda, generate a disambiguating string
 * which maximizes stability across deserialization.
 *
 * @return String to differentiate synthetic lambda method names
 */
private String serializedLambdaDisambiguation() {
    StringBuilder buf = new StringBuilder();
    // Append the enclosing method signature to differentiate
    // overloaded enclosing methods.  For lambdas enclosed in
    // lambdas, the generated lambda method will not have type yet,
    // but the enclosing method's name will have been generated
    // with this same method, so it will be unique and never be
    // overloaded.
    Assert.check(
            owner.type != null ||
            directlyEnclosingLambda() != null);
    if (owner.type != null) {
        buf.append(typeSig(owner.type));
        buf.append(":");
    }

    // Add target type info
    buf.append(types.findDescriptorSymbol(tree.type.tsym).owner.flatName());
    buf.append(" ");

    // Add variable assigned to
    if (assignedTo != null) {
        buf.append(assignedTo.flatName());
        buf.append("=");
    }
    //add captured locals info: type, name, order
    for (Symbol fv : getSymbolMap(CAPTURED_VAR).keySet()) {
        if (fv != self) {
            buf.append(typeSig(fv.type));
            buf.append(" ");
            buf.append(fv.flatName());
            buf.append(",");
        }
    }

    return buf.toString();
}
 
Example 21
/** Return tree simulating the assignment {@code this.name = name}, where
 *  name is the name of a free variable.
 */
JCStatement initField(int pos, Symbol rhs, Symbol lhs) {
    Assert.check(rhs.owner.kind == MTH);
    Assert.check(rhs.owner.owner == lhs.owner);
    make.at(pos);
    return
        make.Exec(
            make.Assign(
                make.Select(make.This(lhs.owner.erasure(types)), lhs),
                make.Ident(rhs)).setType(lhs.erasure(types)));
}
 
Example 22
public static EnumSet<Flag> asFlagSet(long flags) {
    EnumSet<Flag> flagSet = EnumSet.noneOf(Flag.class);
    for (Flag flag : Flag.values()) {
        if ((flags & flag.value) != 0) {
            flagSet.add(flag);
            flags &= ~flag.value;
        }
    }
    Assert.check(flags == 0);
    return flagSet;
}
 
Example 23
Source Project: openjdk-jdk9   Source File: Modules.java    License: GNU General Public License v2.0 5 votes vote down vote up
private Set<ModuleSymbol> retrieveRequiresTransitive(ModuleSymbol msym) {
    Set<ModuleSymbol> requiresTransitive = requiresTransitiveCache.get(msym);

    if (requiresTransitive == null) {
        //the module graph may contain cycles involving automatic modules or --add-reads edges
        requiresTransitive = new HashSet<>();

        Set<ModuleSymbol> seen = new HashSet<>();
        List<ModuleSymbol> todo = List.of(msym);

        while (todo.nonEmpty()) {
            ModuleSymbol current = todo.head;
            todo = todo.tail;
            if (!seen.add(current))
                continue;
            requiresTransitive.add(current);
            current.complete();
            Iterable<? extends RequiresDirective> requires;
            if (current != syms.unnamedModule) {
                Assert.checkNonNull(current.requires, () -> current + ".requires == null; " + msym);
                requires = current.requires;
                for (RequiresDirective rd : requires) {
                    if (rd.isTransitive())
                        todo = todo.prepend(rd.module);
                }
            } else {
                for (ModuleSymbol mod : allModules()) {
                    todo = todo.prepend(mod);
                }
            }
        }

        requiresTransitive.remove(msym);
    }

    return requiresTransitive;
}
 
Example 24
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 25
private Option(String text, String argsNameKey, String descrKey,
        OptionKind kind, OptionGroup group,
        ChoiceKind choiceKind, Set<String> choices,
        ArgKind argKind) {
    this.names = text.trim().split("\\s+");
    Assert.check(names.length >= 1);
    this.primaryName = names[0];
    this.argsNameKey = argsNameKey;
    this.descrKey = descrKey;
    this.kind = kind;
    this.group = group;
    this.choiceKind = choiceKind;
    this.choices = choices;
    this.argKind = argKind;
}
 
Example 26
Source Project: TencentKona-8   Source File: SymbolMetadata.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void setDeclarationAttributes(List<Attribute.Compound> a) {
    Assert.check(pendingCompletion() || !isStarted());
    if (a == null) {
        throw new NullPointerException();
    }
    attributes = a;
}
 
Example 27
Source Project: openjdk-8   Source File: TypeAnnotations.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitNewClass(JCNewClass tree) {
    if (tree.def != null &&
            !tree.def.mods.annotations.isEmpty()) {
        JCClassDecl classdecl = tree.def;
        TypeAnnotationPosition pos = new TypeAnnotationPosition();
        pos.type = TargetType.CLASS_EXTENDS;
        pos.pos = tree.pos;
        if (classdecl.extending == tree.clazz) {
            pos.type_index = -1;
        } else if (classdecl.implementing.contains(tree.clazz)) {
            pos.type_index = classdecl.implementing.indexOf(tree.clazz);
        } else {
            // In contrast to CLASS elsewhere, typarams cannot occur here.
            Assert.error("Could not determine position of tree " + tree);
        }
        Type before = classdecl.sym.type;
        separateAnnotationsKinds(classdecl, tree.clazz.type, classdecl.sym, pos);
        copyNewClassAnnotationsToOwner(tree);
        // classdecl.sym.type now contains an annotated type, which
        // is not what we want there.
        // TODO: should we put this type somewhere in the superclass/interface?
        classdecl.sym.type = before;
    }

    scan(tree.encl);
    scan(tree.typeargs);
    scan(tree.clazz);
    scan(tree.args);

    // The class body will already be scanned.
    // scan(tree.def);
}
 
Example 28
Source Project: openjdk-8   Source File: SymbolMetadata.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void setDeclarationAttributes(List<Attribute.Compound> a) {
    Assert.check(pendingCompletion() || !isStarted());
    if (a == null) {
        throw new NullPointerException();
    }
    attributes = a;
}
 
Example 29
Source Project: openjdk-jdk9   Source File: Modules.java    License: 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;
    }
}
 
Example 30
void runTest(String aJava, String bJava) throws Exception {
    File testClasses = new File(System.getProperty("test.classes"));
    File target1 = new File(testClasses, "T8068517s" + testN++);
    doCompile(target1, aJava, bJava);
    File target2 = new File(testClasses, "T8068517s" + testN++);
    doCompile(target2, bJava, aJava);

    Assert.check(Arrays.equals(Files.readAllBytes(new File(target1, "B.class").toPath()),
                               Files.readAllBytes(new File(target2, "B.class").toPath())));
}