7321N/A * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 7321N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7321N/A * This code is free software; you can redistribute it and/or modify it 7321N/A * under the terms of the GNU General Public License version 2 only, as 7321N/A * published by the Free Software Foundation. 7321N/A * This code is distributed in the hope that it will be useful, but WITHOUT 7321N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7321N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7321N/A * version 2 for more details (a copy is included in the LICENSE file that 7321N/A * You should have received a copy of the GNU General Public License version 7321N/A * 2 along with this work; if not, write to the Free Software Foundation, 7321N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7321N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 7321N/A * or visit www.oracle.com if you need additional information or have any 7321N/A * @summary Basher for star-import scopes 7321N/A * Select a random element from an array of choices. 7321N/A * Write a message to stderr. 7321N/A * Write a message to stderr, and dump a scope. 7321N/A * Write an error message to stderr. 7321N/A /** Class to encapsulate a test run. */ 7321N/A * Setup env by creating pseudo-random collection of names, packages and classes. 7321N/A * Set up a random number of names. 7321N/A * Set up a package containing a random number of member elements. 7321N/A// log("setup: created " + c1); 7321N/A// log("setup: created " + c2); 7321N/A// log("package " + p, p.members_field); 7321N/A * Set up a class containing a random number of member elements. 7321N/A// log("setup: created " + c); 7321N/A// log("setup: created " + ic); 7321N/A * Create a star-import scope and a model therof, from the packages and 7321N/A * classes created by setupPackages and setupClasses. 7321N/A * @throws Exception for fatal errors, such as from reflection 7321N/A // if StarImportScope exists, use it, otherwise, for testing legacy code, 7321N/A // fall back on ImportScope 7321N/A// log("importAll", members); 7321N/A // The following lines are taken from MemberEnter.importAll, 7321N/A // before the use of StarImportScope.importAll. 7321N/A// log("star-import scope", starImportScope); 7321N/A * The core of the test. In a random order, move nested classes from 7321N/A * the package in which they created to the class which should own them. 7321N/A // select a random nested class to move from package to class 7321N/A // remove from star import model 7321N/A // owner should be a package 7321N/A// log(sym + " owner: " + sym.owner, sym.owner.members()); 7321N/A// log("outer: " + outerName + " " + outer); 7321N/A // rename and insert into class error(
"no entries for " +
sym.
name +
" found in reference model");
// log(sym.name + "(" + sym + ") removed from reference model"); * Check the contents of a scope // First, check all entries in scope are in map log(
"Warning: " +
sym.
name +
":" +
sym +
" appears to be bogus");
error(
"check: no entries found for " +
sym.
name +
":" +
sym +
" in reference map");
error(
"check: symbol " +
sym.
name +
":" +
sym +
" not found in reference map");
log(
"Warning: " +
bogusCount +
" other bogus entries previously reported");
// Second, check all entries in map are in scope error(
"check: no entries found for " +
name +
" in scope");
error(
"check: symbol " +
sym +
" not found in scope");