1 /*
   2  * Copyright (c) 2017, 2018, 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  */
  23 
  24 
  25 /*
  26  * @test
  27  * @key stress gc
  28  *
  29  * @summary converted from VM Testbase gc/gctests/LargeObjects/large002.
  30  * VM Testbase keywords: [gc, stress, stressopt, nonconcurrent]
  31  * VM Testbase readme:
  32  * DESCRIPTION
  33  *     The test checks that Garbage Collector correctly does not throw any
  34  *     unexpected exceptions/errors while allocating large objects (classes
  35  *     that have more than 65535 fields and classes that have less than 65535
  36  *     fields). 65535 of fields is a limitation for JVM (see JVM specification
  37  *     Second edition 4.10).
  38  *     Since it is impossible to create one class with about 65535 of fields
  39  *     (javac cannot compile it), a child class extends a parent class, so the
  40  *     fields are devided into two subsets. However, the child class still has
  41  *     about 65535 of fields.
  42  *     The test starts a number of threads. This number is either set in *.cfg
  43  *     file or is calculated by the test itself based on the machine (see
  44  *     nsk.share.gc.Algorithms.getThreadsCount() method). As soon as all threads
  45  *     are started, each thread begins its checking.
  46  *     There are 13 classes to be loaded by each thread. These classes are
  47  *     generated by nsk.share.gc.Generator (see its javadoc for more details).
  48  *     Each class has a huge number of fields, and the number of fields is more than
  49  *     the JVM limitation.
  50  *     The test loads the classes with nsk.share.gc.GCClassUnloader class that
  51  *     extends nsk.share.ClassUnloader and has a bit different algorith of eating
  52  *     heap. As soon as a class is loaded, the test creates an instance of
  53  *     it - allocates an object of that type. Then it drops references to the
  54  *     class and to the instance and tries to unload the class. The test does not
  55  *     expect any exceptions to be thrown.
  56  *
  57  * @library /vmTestbase
  58  *          /test/lib
  59  * @run driver jdk.test.lib.FileInstaller . .
  60  *
  61  * @comment generate and compile nsk.share.gc.newclass.* classes
  62  * @run driver nsk.share.gc.GenClassesBuilder
  63  *
  64  * @run main/othervm
  65  *      -XX:-UseGCOverheadLimit
  66  *      gc.gctests.LargeObjects.large001.large001
  67  *      -largeClassesPath classes
  68  *      -isOverLimitFields true
  69  *      -aggregationDepth 0
  70  *      -t 1
  71  */
  72