1 /* 2 * Copyright (c) 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 * 28 * @summary converted from VM Testbase nsk/jvmti/IterateOverHeap/iterheap002. 29 * VM Testbase keywords: [quick, jpda, jvmti, noras] 30 * VM Testbase readme: 31 * DESCRIPTION 32 * This JVMTI test exercises JVMTI heap function IterateOverHeap(). 33 * This test checks that IterateOverHeap() function with 34 * JVMTI_HEAP_OBJECT_TAGGED filter iterates over all tagged 35 * objects in the heap even is they are not reachable; 36 * and passes correct values to the callback. 37 * The test creates and tags the following tested objects: 38 * root object - root object with 2 chains 39 * chain of reachable objects - tagged/untagged objects to be iterated 40 * chain of unreachable objects - tagged objects to be iterated or GC'ed 41 * The test marks reachable objects with positive tags and 42 * unreachable objects with negative tags. 43 * Also each object in reachable chain is marked with zero tag 44 * (i.e., left untagged). 45 * Unreachable objects are monitored for OBJECT_FREE event to know 46 * if they were not iterated because of garbage collected. 47 * Local JNI references are explicitely deleted to ensure them 48 * not to affect the objects' reachability. 49 * The test supports the following special options: 50 * objects=<number> 51 * - number of objects in each objects chain 52 * info=[none|all|objref|stackref|heaproot|heapobj|tagged] 53 * - print trace message for each invocation of particular callback 54 * COMMENTS 55 * Fixed according to 4960375 bug. 56 * The test updated to match new JVMTI spec 0.2.94. 57 * Fixed the 5005389 bug. 58 * 59 * @library /vmTestbase 60 * /test/lib 61 * @run driver jdk.test.lib.FileInstaller . . 62 * @build ExecDriver 63 * nsk.jvmti.IterateOverHeap.iterheap002 64 * @run main/othervm/native PropertyResolvingWrapper ExecDriver --java 65 * "-agentlib:iterheap002=-waittime=5 objects=4" 66 * nsk.jvmti.IterateOverHeap.iterheap002 67 */ 68 69