Java Code Examples for com.sun.tools.javac.util.Assert#checkNonNull()

The following examples show how to use com.sun.tools.javac.util.Assert#checkNonNull() . 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
/** 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 2
public ArchiveContainer(Path archivePath) throws IOException, ProviderNotFoundException, SecurityException {
    this.archivePath = archivePath;
    if (multiReleaseValue != null && archivePath.toString().endsWith(".jar")) {
        Map<String,String> env = Collections.singletonMap("multi-release", multiReleaseValue);
        FileSystemProvider jarFSProvider = fsInfo.getJarFSProvider();
        Assert.checkNonNull(jarFSProvider, "should have been caught before!");
        this.fileSystem = jarFSProvider.newFileSystem(archivePath, env);
    } else {
        this.fileSystem = FileSystems.newFileSystem(archivePath, null);
    }
    packages = new HashMap<>();
    for (Path root : fileSystem.getRootDirectories()) {
        Files.walkFileTree(root, EnumSet.noneOf(FileVisitOption.class), Integer.MAX_VALUE,
                new SimpleFileVisitor<Path>() {
                    @Override
                    public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
                        if (isValid(dir.getFileName())) {
                            packages.put(new RelativeDirectory(root.relativize(dir).toString()), dir);
                            return FileVisitResult.CONTINUE;
                        } else {
                            return FileVisitResult.SKIP_SUBTREE;
                        }
                    }
                });
    }
}
 
Example 3
/** 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 4
/** 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 5
@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 6
/** Create a new toplevel or member class symbol with given name
 *  and owner and enter in `classes' unless already there.
 */
public ClassSymbol enterClass(ModuleSymbol msym, Name name, TypeSymbol owner) {
    Assert.checkNonNull(msym);
    Name flatname = TypeSymbol.formFlatName(name, owner);
    ClassSymbol c = getClass(msym, flatname);
    if (c == null) {
        c = defineClass(name, owner);
        doEnterClass(msym, c);
    } else if ((c.name != name || c.owner != owner) && owner.kind == TYP && c.owner.kind == PCK) {
        // reassign fields of classes that might have been loaded with
        // their flat names.
        c.owner.members().remove(c);
        c.name = name;
        c.owner = owner;
        c.fullname = ClassSymbol.formFullName(name, owner);
    }
    return c;
}
 
Example 7
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 8
public void write(Object owner, Attribute attr, ConstantPool constant_pool) {
    if (attr != null) {
        Assert.checkNonNull(constant_pool);
        Assert.checkNonNull(owner);
        this.constant_pool = constant_pool;
        this.owner = owner;
        attr.accept(this, null);
    }
}
 
Example 9
Source Project: javaide   File: Type.java    License: GNU General Public License v3.0 5 votes vote down vote up
public CapturedType(Name name,
                    Symbol owner,
                    Type upper,
                    Type lower,
                    WildcardType wildcard) {
    super(name, owner, lower);
    this.lower = Assert.checkNonNull(lower);
    this.bound = upper;
    this.wildcard = wildcard;
}
 
Example 10
private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) {
    List<ClassSymbol> classes = List.nil();
    for (JCCompilationUnit unit : units) {
        for (JCTree node : unit.defs) {
            if (node.getTag() == JCTree.CLASSDEF) {
                ClassSymbol sym = ((JCClassDecl) node).sym;
                Assert.checkNonNull(sym);
                classes = classes.prepend(sym);
            }
        }
    }
    return classes.reverse();
}
 
Example 11
Map<Symbol, Symbol> getSymbolMap(LambdaSymbolKind skind) {
    Map<Symbol, Symbol> m = translatedSymbols.get(skind);
    Assert.checkNonNull(m);
    return m;
}
 
Example 12
public Set<ModuleSymbol> allModules() {
    Assert.checkNonNull(allModules);
    return allModules;
}
 
Example 13
public ClassSymbol getClass(ModuleSymbol msym, Name flatName) {
    Assert.checkNonNull(msym, flatName::toString);
    return classes.getOrDefault(flatName, Collections.emptyMap()).get(msym);
}
 
Example 14
/**
 * Create a new TypeMetadata map containing the Entry {@code elem}.
 *
 * @param elem the sole contents of this map
 */
public TypeMetadata(Entry elem) {
    this();
    Assert.checkNonNull(elem);
    contents.put(elem.kind(), elem);
}
 
Example 15
Checker(Env env) {
    this.env = Assert.checkNonNull(env);
    tagStack = new LinkedList<>();
    implicitHeaderLevel = env.implicitHeaderLevel;
}
 
Example 16
public boolean isRootModule(ModuleSymbol module) {
    Assert.checkNonNull(rootModules);
    return rootModules.contains(module);
}
 
Example 17
/** Check to see if a package exists, given its fully qualified name.
 */
public boolean packageExists(ModuleSymbol msym, Name fullname) {
    Assert.checkNonNull(msym);
    return lookupPackage(msym, fullname).exists();
}
 
Example 18
public ClassSymbol getClass(ModuleSymbol msym, Name flatName) {
    Assert.checkNonNull(msym, flatName::toString);
    return Maps.getOrDefault(classes,flatName, Collections.emptyMap()).get(msym);
}
 
Example 19
void checkForAttr(Attributes attrs, String errorMsg, String... attrNames) {
    for (String attrName : attrNames) {
        Assert.checkNonNull(attrs.get(attrName), errorMsg);
    }
}
 
Example 20
void checkForAttr(Attributes attrs, String errorMsg, String... attrNames) {
    for (String attrName : attrNames) {
        Assert.checkNonNull(attrs.get(attrName), errorMsg);
    }
}