[r12173]: rvmroot / trunk / testing / tests / jni / src / TestGC.c  Maximize  Restore  History

Download this file

84 lines (65 with data), 2.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* This file is part of Jikes RVM (http://jikesrvm.sourceforge.net).
* The Jikes RVM project is distributed under the Common Public License (CPL).
* A copy of the license is included in the distribution, and is also
* available at http://www.opensource.org/licenses/cpl1.0.php
*
* (C) Copyright IBM Corp. 2001
*/
/* Test GC with Native frames on stack
*/
#include <stdio.h>
#include "TestGC.h"
#include <jni.h>
int verbose=1;
/*
* Class: TestGC
* Method: setVerboseOff
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestGC_setVerboseOff
(JNIEnv *env, jclass cls) {
verbose=0;
}
/*
* Class: TestGC
* Method: testgc
* Signature: (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_TestGC_testgc
(JNIEnv * env, jclass cls, jobject obj1, jobject obj2) {
jmethodID methodID;
jclass expectCls;
jboolean matchClass;
jclass systemClass;
systemClass = (*env) -> FindClass(env, "java/lang/System");
if (systemClass == NULL) {
if (verbose)
printf("> FindClass: fail to get class for java/lang/System\n");
return NULL;
}
methodID = (*env) -> GetStaticMethodID(env, systemClass, "gc", "()V");
if (methodID == NULL) {
if (verbose)
printf("> GetStaticMethodID: fail to get method ID for static method System.gc\n");
return NULL;
}
if (verbose)
printf("about to do System.gc\n");
(*env) -> CallStaticVoidMethodA(env, systemClass, methodID, NULL);
if (verbose)
printf("back from System.gc\n");
/* Do a few operations on the moved object to see if it's still valid */
if (verbose) printf("Calling FindClass\n");
expectCls = (*env) -> FindClass(env, "java/lang/String");
if (verbose) printf("Calling IsInstanceOf\n");
matchClass = (*env) -> IsInstanceOf(env, obj1, expectCls);
if (!matchClass)
return NULL;
if (verbose) printf("Calling IsInstanceOf\n");
matchClass = (*env) -> IsInstanceOf(env, obj2, expectCls);
if (!matchClass)
return NULL;
if (verbose) printf("Returning\n");
return obj1;
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks