test/tools/javac/processing/6430209/b6341534.java

Mon, 14 Nov 2011 15:11:10 -0800

author
ksrini
date
Mon, 14 Nov 2011 15:11:10 -0800
changeset 1138
7375d4979bd3
parent 932
edf03ca74991
child 2525
2eb010b6cb22
permissions
-rw-r--r--

7106166: (javac) re-factor EndPos parser
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 import javax.annotation.processing.*;
    25 import javax.lang.model.SourceVersion;
    26 import javax.lang.model.element.*;
    27 import javax.lang.model.util.*;
    28 import static javax.lang.model.util.ElementFilter.*;
    29 import static javax.tools.Diagnostic.Kind.*;
    30 import java.util.*;
    31 import java.util.Set;
    33 public class b6341534 extends JavacTestingAbstractProcessor {
    34     static int r = 0;
    36     //Create directory 'dir1' and a test class in dir1
    37     public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv)
    38     {
    39         if(!renv.errorRaised() &&  !renv.processingOver()){
    40             r++;
    41             for( TypeElement t : typesIn(renv.getRootElements()) )
    42                 System.out.println("Round"+r+ ": " + t.toString());
    44             try {
    45                 PackageElement PE = eltUtils.getPackageElement("dir1");
    46                 List<? extends Element> LEE = PE.getEnclosedElements();    /* <=This line elicits the error message.  */
    47                 for(Element e : LEE)
    48                     System.out.println("found " + e.toString() + " in dir1.");
    49             }
    50             catch(NullPointerException npe) {
    51                 messager.printMessage(ERROR,npe.toString());
    52                 //npe.printStackTrace();
    53                 return false;
    54             }
    55         }
    56         // on round 1, expect errorRaised == false && processingOver == false
    57         // on round 2, expect errorRaised == true && processingOver == true
    58         if( renv.errorRaised() != renv.processingOver()) {
    59             messager.printMessage(ERROR, "FAILED: round:" + r
    60                 + ", errorRaised:" + renv.errorRaised()
    61                 + ", processingOver:" + renv.processingOver());
    62         }
    63         return true;
    64     }
    65 }

mercurial