annotate test/hotspot/jtreg/vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc001/forcegc001.cpp @ 51792:79dc492c00ab

8210481: Remove #ifdef cplusplus from vmTestbase Summary: Remove all cplusplus ifdefs from vmTestbase Reviewed-by: dholmes, iignatyev, cjplummer, sspitsyn
author jcbeyler
date Mon, 17 Sep 2018 19:36:09 -0700
parents e409244ce72e
children 054a24c46812
rev   line source
iignatyev@50270 1 /*
iignatyev@50270 2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
iignatyev@50270 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
iignatyev@50270 4 *
iignatyev@50270 5 * This code is free software; you can redistribute it and/or modify it
iignatyev@50270 6 * under the terms of the GNU General Public License version 2 only, as
iignatyev@50270 7 * published by the Free Software Foundation.
iignatyev@50270 8 *
iignatyev@50270 9 * This code is distributed in the hope that it will be useful, but WITHOUT
iignatyev@50270 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
iignatyev@50270 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
iignatyev@50270 12 * version 2 for more details (a copy is included in the LICENSE file that
iignatyev@50270 13 * accompanied this code).
iignatyev@50270 14 *
iignatyev@50270 15 * You should have received a copy of the GNU General Public License version
iignatyev@50270 16 * 2 along with this work; if not, write to the Free Software Foundation,
iignatyev@50270 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
iignatyev@50270 18 *
iignatyev@50270 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
iignatyev@50270 20 * or visit www.oracle.com if you need additional information or have any
iignatyev@50270 21 * questions.
iignatyev@50270 22 */
iignatyev@50270 23
iignatyev@50270 24 #include <string.h>
iignatyev@50270 25 #include "jvmti.h"
iignatyev@50270 26 #include "agent_common.h"
iignatyev@50270 27 #include "jni_tools.h"
iignatyev@50270 28 #include "jvmti_tools.h"
iignatyev@50270 29
iignatyev@50270 30 extern "C" {
iignatyev@50270 31
iignatyev@50270 32 /* ============================================================================= */
iignatyev@50270 33
iignatyev@50270 34 static jlong timeout = 0;
iignatyev@50270 35
iignatyev@50270 36 /* ============================================================================= */
iignatyev@50270 37
iignatyev@50270 38 /** Agent algorithm. */
iignatyev@50270 39 static void JNICALL
iignatyev@50270 40 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
iignatyev@50270 41 NSK_DISPLAY0("Wait for objects ready for GC\n");
iignatyev@50270 42 if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout)))
iignatyev@50270 43 return;
iignatyev@50270 44
iignatyev@50270 45 NSK_DISPLAY0(">>> Testcase #1: force GC to collect sofly reachable objects\n");
iignatyev@50270 46 {
iignatyev@50270 47 NSK_DISPLAY0("Call ForceGarbageCollection()\n");
iignatyev@50270 48 if (!NSK_JVMTI_VERIFY(
iignatyev@50270 49 NSK_CPP_STUB1(ForceGarbageCollection, jvmti))) {
iignatyev@50270 50 nsk_jvmti_setFailStatus();
iignatyev@50270 51 return;
iignatyev@50270 52 }
iignatyev@50270 53 NSK_DISPLAY0(" ... returnded\n");
iignatyev@50270 54 }
iignatyev@50270 55
iignatyev@50270 56 NSK_DISPLAY0("Let debugee to finish\n");
iignatyev@50270 57 if (!NSK_VERIFY(nsk_jvmti_resumeSync()))
iignatyev@50270 58 return;
iignatyev@50270 59 }
iignatyev@50270 60
iignatyev@50270 61 /* ============================================================================= */
iignatyev@50270 62
iignatyev@50270 63 /** Agent library initialization. */
iignatyev@50270 64 #ifdef STATIC_BUILD
iignatyev@50270 65 JNIEXPORT jint JNICALL Agent_OnLoad_forcegc001(JavaVM *jvm, char *options, void *reserved) {
iignatyev@50270 66 return Agent_Initialize(jvm, options, reserved);
iignatyev@50270 67 }
iignatyev@50270 68 JNIEXPORT jint JNICALL Agent_OnAttach_forcegc001(JavaVM *jvm, char *options, void *reserved) {
iignatyev@50270 69 return Agent_Initialize(jvm, options, reserved);
iignatyev@50270 70 }
iignatyev@50270 71 JNIEXPORT jint JNI_OnLoad_forcegc001(JavaVM *jvm, char *options, void *reserved) {
iignatyev@50270 72 return JNI_VERSION_1_8;
iignatyev@50270 73 }
iignatyev@50270 74 #endif
iignatyev@50270 75 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
iignatyev@50270 76 jvmtiEnv* jvmti = NULL;
iignatyev@50270 77
iignatyev@50270 78 if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
iignatyev@50270 79 return JNI_ERR;
iignatyev@50270 80
iignatyev@50270 81 timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
iignatyev@50270 82
iignatyev@50270 83 if (!NSK_VERIFY((jvmti =
iignatyev@50270 84 nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
iignatyev@50270 85 return JNI_ERR;
iignatyev@50270 86
iignatyev@50270 87 if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
iignatyev@50270 88 return JNI_ERR;
iignatyev@50270 89
iignatyev@50270 90 return JNI_OK;
iignatyev@50270 91 }
iignatyev@50270 92
iignatyev@50270 93 /* ============================================================================= */
iignatyev@50270 94
iignatyev@50270 95 }