test/tools/javac/processing/model/testgetallmembers/Main.java

Print this page




   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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug     6374357 6308351
  27  * @summary PackageElement.getEnclosedElements() throws ClassReader$BadClassFileException
  28  * @author  Peter von der Ah\u00e9
  29  * @run main/othervm -Xmx256m Main
  30  */
  31 
  32 import java.io.File;
  33 import java.util.*;
  34 import javax.lang.model.SourceVersion;
  35 import javax.lang.model.element.Element;
  36 import javax.lang.model.element.ElementKind;
  37 import javax.lang.model.element.PackageElement;
  38 import javax.lang.model.element.TypeElement;
  39 import javax.lang.model.util.Elements;
  40 import javax.tools.*;
  41 import com.sun.source.util.JavacTask;
  42 
  43 import static javax.tools.StandardLocation.CLASS_PATH;
  44 import static javax.tools.StandardLocation.PLATFORM_CLASS_PATH;
  45 import static javax.tools.JavaFileObject.Kind.CLASS;
  46 


 101         for (String name : packages) {
 102             PackageElement pe = elements.getPackageElement(name);
 103             for (Element e : pe.getEnclosedElements()) {
 104                 e.getSimpleName().getClass();
 105             }
 106         }
 107         /*
 108          * A few sanity checks based on current values:
 109          *
 110          * packages: 775, classes: 12429 + 5917
 111          *
 112          * As the platform evolves the numbers are likely to grow
 113          * monotonically but in case somebody gets a clever idea for
 114          * limiting the number of packages exposed, this number might
 115          * drop.  So we test low values.
 116          */
 117         System.out.format("packages: %s, classes: %s + %s%n",
 118                           packages.size(), classes, nestedClasses);
 119         if (classes < 9000)
 120             throw new AssertionError("Too few classes in PLATFORM_CLASS_PATH ;-)");
 121         if (packages.size() < 545)
 122             throw new AssertionError("Too few packages in PLATFORM_CLASS_PATH ;-)");
 123         if (nestedClasses < 3000)
 124             throw new AssertionError("Too few nested classes in PLATFORM_CLASS_PATH ;-)");
 125     }
 126 }


   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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug     6374357 6308351 6707027
  27  * @summary PackageElement.getEnclosedElements() throws ClassReader$BadClassFileException
  28  * @author  Peter von der Ah\u00e9
  29  * @run main/othervm -Xmx256m Main
  30  */
  31 
  32 import java.io.File;
  33 import java.util.*;
  34 import javax.lang.model.SourceVersion;
  35 import javax.lang.model.element.Element;
  36 import javax.lang.model.element.ElementKind;
  37 import javax.lang.model.element.PackageElement;
  38 import javax.lang.model.element.TypeElement;
  39 import javax.lang.model.util.Elements;
  40 import javax.tools.*;
  41 import com.sun.source.util.JavacTask;
  42 
  43 import static javax.tools.StandardLocation.CLASS_PATH;
  44 import static javax.tools.StandardLocation.PLATFORM_CLASS_PATH;
  45 import static javax.tools.JavaFileObject.Kind.CLASS;
  46 


 101         for (String name : packages) {
 102             PackageElement pe = elements.getPackageElement(name);
 103             for (Element e : pe.getEnclosedElements()) {
 104                 e.getSimpleName().getClass();
 105             }
 106         }
 107         /*
 108          * A few sanity checks based on current values:
 109          *
 110          * packages: 775, classes: 12429 + 5917
 111          *
 112          * As the platform evolves the numbers are likely to grow
 113          * monotonically but in case somebody gets a clever idea for
 114          * limiting the number of packages exposed, this number might
 115          * drop.  So we test low values.
 116          */
 117         System.out.format("packages: %s, classes: %s + %s%n",
 118                           packages.size(), classes, nestedClasses);
 119         if (classes < 9000)
 120             throw new AssertionError("Too few classes in PLATFORM_CLASS_PATH ;-)");
 121         if (packages.size() < 530)
 122             throw new AssertionError("Too few packages in PLATFORM_CLASS_PATH ;-)");
 123         if (nestedClasses < 3000)
 124             throw new AssertionError("Too few nested classes in PLATFORM_CLASS_PATH ;-)");
 125     }
 126 }