test/tools/javac/scope/HashCollisionTest.java

changeset 858
96d4226bdd60
parent 767
7e3e9f6d013f
child 962
0ff2bbd38f10
equal deleted inserted replaced
857:3aa269645199 858:96d4226bdd60
45 // set up basic environment for test 45 // set up basic environment for test
46 Context context = new Context(); 46 Context context = new Context();
47 JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab 47 JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab
48 names = Names.instance(context); // Name.Table impls tied to an instance of Names 48 names = Names.instance(context); // Name.Table impls tied to an instance of Names
49 symtab = Symtab.instance(context); 49 symtab = Symtab.instance(context);
50 scopeCounter = ScopeCounter.instance(context);
51 50
52 // determine hashMask for an empty scope 51 // determine hashMask for an empty scope
53 Scope emptyScope = new Scope(symtab.unnamedPackage); // any owner will do 52 Scope emptyScope = new Scope(symtab.unnamedPackage); // any owner will do
54 Field sHashMask = Scope.class.getDeclaredField("hashMask"); 53 Field sHashMask = Scope.class.getDeclaredField("hashMask");
55 sHashMask.setAccessible(true); 54 sHashMask.setAccessible(true);
169 /** 168 /**
170 * Create a class symbol, init the members scope, and add it to owner's scope. 169 * Create a class symbol, init the members scope, and add it to owner's scope.
171 */ 170 */
172 ClassSymbol createClass(Name name, Symbol owner) { 171 ClassSymbol createClass(Name name, Symbol owner) {
173 ClassSymbol sym = new ClassSymbol(0, name, owner); 172 ClassSymbol sym = new ClassSymbol(0, name, owner);
174 sym.members_field = new ClassScope(sym, scopeCounter); 173 sym.members_field = new Scope(sym);
175 if (owner != symtab.unnamedPackage) 174 if (owner != symtab.unnamedPackage)
176 owner.members().enter(sym); 175 owner.members().enter(sym);
177 return sym; 176 return sym;
178 } 177 }
179 178
245 int MAX_TRIES = 100; // max tries to find a hash clash before giving up. 244 int MAX_TRIES = 100; // max tries to find a hash clash before giving up.
246 int scopeHashMask; 245 int scopeHashMask;
247 246
248 Names names; 247 Names names;
249 Symtab symtab; 248 Symtab symtab;
250 ScopeCounter scopeCounter;
251 } 249 }

mercurial