/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4992173 4992170
*
* @run shell make_src.sh
* @run shell build.sh
*
* @summary Check getEnclosingClass and other methods
* @author Peter von der Ah\u00e9
*/
/*
* We have five kinds of classes:
* a) Top level classes
* b) Nested classes (static member classes)
* c) Inner classes (non-static member classes)
* d) Local classes (named classes declared within a method)
* e) Anonymous classes
*
* Each one can be within a package or not.
* This gives us a three dimensional space:
* 1. dimension: b-e
* 2. dimension: a-e
* 3. dimension: packages
*
* We make a two dimensional matrix of (b-e)x(a-e) and change the
* package configuration on that:
*
* b c d e
* a x x x x
* b x x x x
* c o x x x where o means "not legal"
* d o x x x
* e o x x x
*/
public class EnclosingClassTest {
c.getSimpleName() + "'");
c.getCanonicalName() + "'");
}
actual + "' matches expected `" +
expected + "'");
}
}
return;
c.getEnclosingMethod(); // make sure it does not crash
c.getEnclosingConstructor(); // make sure it does not crash
c.getCanonicalName(),
if (void.class.equals(c))
return;
"", "",
}
if (annotation != null) {
try {
} catch (AssertionError ex) {
"." + f.getName());
throw ex;
} catch (IllegalAccessException ex) {
throw new RuntimeException(ex);
}
}
}
}
test(new EnclosingClass());
}
}