test/tools/javac/processing/model/TestExceptions.java

Thu, 25 Aug 2011 17:18:25 -0700

author
schien
date
Thu, 25 Aug 2011 17:18:25 -0700
changeset 1067
f497fac86cf9
parent 554
9d9f26857129
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag jdk8-b02 for changeset b3c059de2a61

darcy@216 1 /*
ohair@554 2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
darcy@216 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
darcy@216 4 *
darcy@216 5 * This code is free software; you can redistribute it and/or modify it
darcy@216 6 * under the terms of the GNU General Public License version 2 only, as
darcy@216 7 * published by the Free Software Foundation.
darcy@216 8 *
darcy@216 9 * This code is distributed in the hope that it will be useful, but WITHOUT
darcy@216 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
darcy@216 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
darcy@216 12 * version 2 for more details (a copy is included in the LICENSE file that
darcy@216 13 * accompanied this code).
darcy@216 14 *
darcy@216 15 * You should have received a copy of the GNU General Public License version
darcy@216 16 * 2 along with this work; if not, write to the Free Software Foundation,
darcy@216 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
darcy@216 18 *
ohair@554 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 20 * or visit www.oracle.com if you need additional information or have any
ohair@554 21 * questions.
darcy@216 22 */
darcy@216 23
darcy@216 24 /*
darcy@216 25 * @test
darcy@216 26 * @bug 6794071
darcy@216 27 * @summary Test that exceptions have a proper parent class
darcy@216 28 * @author Joseph D. Darcy
darcy@216 29 */
darcy@216 30
darcy@216 31 import javax.lang.model.UnknownEntityException;
darcy@216 32 import javax.lang.model.element.*;
darcy@216 33 import javax.lang.model.type.*;
darcy@216 34
darcy@216 35 /*
darcy@216 36 * Verify UnknownFooExceptions can be caught with a common parent
darcy@216 37 * exception.
darcy@216 38 */
darcy@216 39 public class TestExceptions {
darcy@216 40 public static void main(String... args) {
darcy@216 41 RuntimeException[] exceptions = {
darcy@216 42 new UnknownElementException((Element)null, (Object)null),
darcy@216 43 new UnknownAnnotationValueException((AnnotationValue) null, (Object) null),
darcy@216 44 new UnknownTypeException((TypeMirror)null, (Object)null)
darcy@216 45 };
darcy@216 46
darcy@216 47 for(RuntimeException exception : exceptions) {
darcy@216 48 try {
darcy@216 49 throw exception;
darcy@216 50 } catch (UnknownEntityException uee) {
darcy@216 51 ;
darcy@216 52 }
darcy@216 53 }
darcy@216 54 }
darcy@216 55 }

mercurial