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() . 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: Symtab.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/** 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 2
Source File: GenerateSuperInterfaceProcessor.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@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 3
Source File: JavacFileManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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 4
Source File: JavacProcessingEnvironment.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/** 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
Source File: JavacProcessingEnvironment.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** 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 6
Source File: JavacProcessingEnvironment.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/** 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 7
Source File: JavacProcessingEnvironment.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
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 8
Source File: JavacProcessingEnvironment.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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 9
Source File: Type.java    From javaide with 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
Source File: AttributeWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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 11
Source File: Symtab.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/** 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 12
Source File: AnnotationsAreNotCopiedToBridgeMethodsTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void checkForAttr(Attributes attrs, String errorMsg, String... attrNames) {
    for (String attrName : attrNames) {
        Assert.checkNonNull(attrs.get(attrName), errorMsg);
    }
}
 
Example 13
Source File: AnnotationsAreNotCopiedToBridgeMethodsTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
void checkForAttr(Attributes attrs, String errorMsg, String... attrNames) {
    for (String attrName : attrNames) {
        Assert.checkNonNull(attrs.get(attrName), errorMsg);
    }
}
 
Example 14
Source File: Symtab.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public ClassSymbol getClass(ModuleSymbol msym, Name flatName) {
    Assert.checkNonNull(msym, flatName::toString);
    return Maps.getOrDefault(classes,flatName, Collections.emptyMap()).get(msym);
}
 
Example 15
Source File: Modules.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public boolean isRootModule(ModuleSymbol module) {
    Assert.checkNonNull(rootModules);
    return rootModules.contains(module);
}
 
Example 16
Source File: Checker.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
Checker(Env env) {
    this.env = Assert.checkNonNull(env);
    tagStack = new LinkedList<>();
    implicitHeaderLevel = env.implicitHeaderLevel;
}
 
Example 17
Source File: TypeMetadata.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 18
Source File: Symtab.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public ClassSymbol getClass(ModuleSymbol msym, Name flatName) {
    Assert.checkNonNull(msym, flatName::toString);
    return classes.getOrDefault(flatName, Collections.emptyMap()).get(msym);
}
 
Example 19
Source File: Modules.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public Set<ModuleSymbol> allModules() {
    Assert.checkNonNull(allModules);
    return allModules;
}
 
Example 20
Source File: LambdaToMethod.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
Map<Symbol, Symbol> getSymbolMap(LambdaSymbolKind skind) {
    Map<Symbol, Symbol> m = translatedSymbols.get(skind);
    Assert.checkNonNull(m);
    return m;
}