langtools/test/tools/javac/T6458749.java
author mcimadamore
Mon, 24 Jan 2011 15:44:51 +0000
changeset 8045 df2ca0edfbaa
parent 6584 c3d25d0ad536
child 30730 d3ce7619db2c
permissions -rw-r--r--
6968793: issues with diagnostics Summary: several diagnostic improvements Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6584
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
     1
/*
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
     2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
     4
 *
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
     8
 *
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    13
 * accompanied this code).
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    14
 *
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    18
 *
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    21
 * questions.
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    22
 */
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    23
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    24
/*
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    25
 * @test
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    26
 * @bug 6458749
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    27
 * @summary  TypeParameterElement.getEnclosedElements() throws NPE within javac
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    28
 * @build T6458749
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    29
 * @compile -processor T6458749 -proc:only T6458749.java
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    30
 */
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    31
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    32
import java.util.Set;
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    33
import javax.annotation.processing.*;
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    34
import javax.lang.model.element.*;
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    35
import javax.lang.model.util.ElementFilter;
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    36
import javax.lang.model.SourceVersion;
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    37
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    38
@SupportedAnnotationTypes("*")
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    39
public class T6458749<T> extends AbstractProcessor {
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    40
    public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    41
        if (!renv.processingOver()) {
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    42
            for(TypeElement e : ElementFilter.typesIn(renv.getRootElements())) {
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    43
                System.out.printf("Element %s:%n", e.toString());
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    44
                try {
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    45
                    for (TypeParameterElement tp : e.getTypeParameters()) {
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    46
                        System.out.printf("Type param %s", tp.toString());
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    47
                        if (! tp.getEnclosedElements().isEmpty()) {
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    48
                            throw new AssertionError("TypeParameterElement.getEnclosedElements() should return empty list");
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    49
                        }
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    50
                    }
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    51
                } catch (NullPointerException npe) {
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    52
                    throw new AssertionError("NPE from TypeParameterElement.getEnclosedElements()", npe);
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    53
                }
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    54
            }
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    55
        }
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    56
        return true;
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    57
    }
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    58
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    59
    public SourceVersion getSupportedSourceVersion() {
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    60
        return SourceVersion.latest();
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    61
    }
c3d25d0ad536 6458749: TypeParameterElement.getEnclosedElements throws NPE within javac.
sundar
parents:
diff changeset
    62
}