961N/A * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 766N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 766N/A * This code is free software; you can redistribute it and/or modify it 766N/A * under the terms of the GNU General Public License version 2 only, as 766N/A * published by the Free Software Foundation. 766N/A * This code is distributed in the hope that it will be useful, but WITHOUT 766N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 766N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 766N/A * version 2 for more details (a copy is included in the LICENSE file that 766N/A * accompanied this code). 766N/A * You should have received a copy of the GNU General Public License version 766N/A * 2 along with this work; if not, write to the Free Software Foundation, 766N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 766N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 766N/A * or visit www.oracle.com if you need additional information or have any 766N/A * @summary Ensure Scope impl can cope with hash collisions 766N/A // set up basic environment for test 766N/A // determine hashMask for an empty scope 766N/A // 1. determine the Name.hashCode of "Entry", and therefore the index of 766N/A // Entry in an empty scope. i.e. name.hashCode() & Scope.hashMask 766N/A // 2. create names of the form *$Entry until we find a name with a 766N/A // hashcode which yields the same index as Entry in an empty scope. 766N/A // Since Name.hashCode is a function of position (and not content) it 766N/A // should work to create successively longer names until one with the 766N/A // desired characteristics is found. 766N/A +
" after " + i +
" tries");
766N/A throw new Exception(
"No potential collision found after " + i +
" tries");
766N/A * Now we can set up the scenario. 766N/A // 3. Create a nested class named Entry 766N/A // 4. Create a package containing a nested class using the name from 2 766N/A // we'll need this later when we "rename" cn 766N/A // 5. Create a star-import scope 766N/A // if StarImportScope exists, use it, otherwise, for testing legacy code, 766N/A // fall back on ImportScope 766N/A // 6. Insert the contents of the package from 4. 766N/A // The following lines are taken from MemberEnter.importAll, 766N/A // before the use of StarImportScope.importAll. 766N/A // 7. Insert the class from 3. 766N/A // 8. Rename the nested class to Entry. so that there is a bogus entry in the star-import scope 766N/A * Check for a (probable) hash collision in an empty scope. 766N/A * Create a class symbol, init the members scope, and add it to owner's scope. 766N/A * Dump the contents of a scope to System.err. 766N/A * Dump the contents of a scope to a stream. 766N/A * Create a string showing the contents of an entry, using the table 766N/A * to help identify cross-references to other entries in the table. 766N/A * @param e the entry to be shown 766N/A * @param table the table containing the other entries 766N/A return "sent";
// sentinel 766N/A * Write a message to stderr. 766N/A int MAX_TRIES =
100;
// max tries to find a hash clash before giving up.