@Override public boolean equals(Object other) { if (!(other instanceof SourceFileObject)) return false; SourceFileObject o = (SourceFileObject) other; return name.equals(o.name); }
/** * Check if two file objects are equal. * SourceFileObjects are just placeholder objects for the value of a * SourceFile attribute, and do not directly represent specific files. * Two SourceFileObjects are equal if their names are equal. */ //@Override public boolean equals(Object other) { if (this == other) return true; if (!(other instanceof SourceFileObject)) return false; SourceFileObject o = (SourceFileObject) other; return name.equals(o.name); }
byte[] names = table.names; while (n != null && (n.len != len || !equals(names, n.index, cs, start, len))) n = n.next; if (n == null) {
byte[] names = table.names; while (n != null && (n.len != len || !equals(names, n.index, cs, start, len))) n = n.next; if (n == null) {
/** * Returns a symbol given the type's or packages's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
/** * Returns a symbol given the type's or packages's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
while (n != null && (n.len != nbytes || !equals(names, n.index, names, nc, nbytes))) n = n.next; if (n == null) {
while (n != null && (n.len != nbytes || !equals(names, n.index, names, nc, nbytes))) n = n.next; if (n == null) {
/** Import all classes of a class or package on demand. * @param pos Position to be used for error reporting. * @param tsym The class or package the members of which are imported. * @param toScope The (import) scope in which imported classes * are entered. */ private void importAll(int pos, final TypeSymbol tsym, Env<AttrContext> env) { // Check that packages imported from exist (JLS ???). if (tsym.kind == PCK && tsym.members().elems == null && !tsym.exists()) { // If we can't find java.lang, exit immediately. if (((PackageSymbol)tsym).fullname.equals(names.java_lang)) { JCDiagnostic msg = JCDiagnostic.fragment("fatal.err.no.java.lang"); throw new FatalError(msg); } else { log.error(pos, "doesnt.exist", tsym); } } final Scope fromScope = tsym.members(); final Scope toScope = env.toplevel.starImportScope; for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { if (e.sym.kind == TYP && !toScope.includes(e.sym)) toScope.enter(e.sym, fromScope); } }
/** Import all classes of a class or package on demand. * @param pos Position to be used for error reporting. * @param tsym The class or package the members of which are imported. * @param toScope The (import) scope in which imported classes * are entered. */ private void importAll(int pos, final TypeSymbol tsym, Env<AttrContext> env) { // Check that packages imported from exist (JLS ???). if (tsym.kind == PCK && tsym.members().elems == null && !tsym.exists()) { // If we can't find java.lang, exit immediately. if (((PackageSymbol)tsym).fullname.equals(names.java_lang)) { JCDiagnostic msg = JCDiagnostic.fragment("fatal.err.no.java.lang"); throw new FatalError(msg); } else { log.error(pos, "doesnt.exist", tsym); } } final Scope fromScope = tsym.members(); final Scope toScope = env.toplevel.starImportScope; for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { if (e.sym.kind == TYP && !toScope.includes(e.sym)) toScope.enter(e.sym, fromScope); } }
/** Check that a given method conforms with any method it overrides. * @param tree The tree from which positions are extracted * for errors. * @param m The overriding method. */ void checkOverride(JCTree tree, MethodSymbol m) { ClassSymbol origin = (ClassSymbol)m.owner; if ((origin.flags() & ENUM) != 0 && names.finalize.equals(m.name)) if (m.overrides(syms.enumFinalFinalize, origin, types, false)) { log.error(tree.pos(), "enum.no.finalize"); return; } for (Type t = types.supertype(origin.type); t.tag == CLASS; t = types.supertype(t)) { TypeSymbol c = t.tsym; Scope.Entry e = c.members().lookup(m.name); while (e.scope != null) { if (m.overrides(e.sym, origin, types, false)) checkOverride(tree, m, (MethodSymbol)e.sym, origin); e = e.next(); } } }
/** Check that a given method conforms with any method it overrides. * @param tree The tree from which positions are extracted * for errors. * @param m The overriding method. */ void checkOverride(JCTree tree, MethodSymbol m) { ClassSymbol origin = (ClassSymbol)m.owner; if ((origin.flags() & ENUM) != 0 && names.finalize.equals(m.name)) if (m.overrides(syms.enumFinalFinalize, origin, types, false)) { log.error(tree.pos(), "enum.no.finalize"); return; } for (Type t = types.supertype(origin.type); t.tag == CLASS; t = types.supertype(t)) { TypeSymbol c = t.tsym; Scope.Entry e = c.members().lookup(m.name); while (e.scope != null) { if (m.overrides(e.sym, origin, types, false)) checkOverride(tree, m, (MethodSymbol)e.sym, origin); e = e.next(); } } }