List of usage examples for com.google.common.collect Multiset hashCode
@Override
int hashCode();
From source file:com.google.devtools.kythe.analyzers.java.JavaEntrySets.java
private int hashSymbol(Symbol sym) { // This method is necessary because Symbol, and most other javac internals, do not overload the // Object#hashCode() method and the default implementation, System#identityHashCode(Object), is // practically useless because it can change across JVM instances. This method instead only // uses stable hashing methods such as String#hashCode(), Multiset#hashCode(), and // Integer#hashCode(). if (symbolHashes.containsKey(sym)) { return symbolHashes.get(sym); }//w w w . ja v a 2 s. c o m Multiset<Integer> hashes = HashMultiset.create(); if (sym.members() != null) { for (Symbol member : sym.members().getSymbols()) { if (member.isPrivate() || member instanceof MethodSymbol && ((MethodSymbol) member).isStaticOrInstanceInit() || ((member.flags_field & (Flags.BRIDGE | Flags.SYNTHETIC)) != 0)) { // Ignore initializers, private members, and synthetic members. It's possible these do // not appear in the symbol's scope outside of its .java source compilation (i.e. they do // not appear in dependent compilations for Bazel's java rules). continue; } // We can't recursively get the result of hashSymbol(member) since the extractor removes all // .class files not directly used by a compilation meaning that member may not be complete. hashes.add(member.getSimpleName().toString().hashCode()); hashes.add(member.kind.ordinal()); } } hashes.add(sym.getQualifiedName().toString().hashCode()); hashes.add(sym.getKind().ordinal()); for (Modifier mod : sym.getModifiers()) { hashes.add(mod.ordinal()); } int h = hashes.hashCode(); symbolHashes.put(sym, h); return h; }