Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/jcl/common/mgmtclassloading.c
6000 views
1
/*******************************************************************************
2
* Copyright (c) 1998, 2019 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
#include "jni.h"
24
#include "j9.h"
25
#include "jvminit.h"
26
#include "verbose_api.h"
27
28
jboolean JNICALL
29
Java_com_ibm_java_lang_management_internal_ClassLoadingMXBeanImpl_isVerboseImpl(JNIEnv *env, jobject beanInstance)
30
{
31
J9JavaVM *javaVM = ((J9VMThread *) env)->javaVM;
32
33
return ( (javaVM->verboseLevel & VERBOSE_CLASS) == VERBOSE_CLASS );
34
}
35
36
jlong JNICALL
37
Java_openj9_internal_management_ClassLoaderInfoBaseImpl_getLoadedClassCountImpl(JNIEnv *env, jobject beanInstance)
38
{
39
jlong result = 0;
40
J9JavaLangManagementData *mgmt = ((J9VMThread *) env)->javaVM->managementData;
41
42
omrthread_rwmutex_enter_read(mgmt->managementDataLock);
43
result = (jlong)(mgmt->totalClassLoads - mgmt->totalClassUnloads);
44
omrthread_rwmutex_exit_read(mgmt->managementDataLock);
45
46
return result;
47
}
48
49
jlong JNICALL
50
Java_com_ibm_java_lang_management_internal_ClassLoadingMXBeanImpl_getTotalLoadedClassCountImpl(JNIEnv *env, jobject beanInstance)
51
{
52
J9JavaVM *javaVM = ((J9VMThread *) env)->javaVM;
53
jlong result;
54
J9JavaLangManagementData *mgmt = javaVM->managementData;
55
56
omrthread_rwmutex_enter_read( mgmt->managementDataLock );
57
58
result = (jlong)mgmt->totalClassLoads;
59
60
omrthread_rwmutex_exit_read( mgmt->managementDataLock );
61
62
return result;
63
}
64
65
jlong JNICALL
66
Java_openj9_internal_management_ClassLoaderInfoBaseImpl_getUnloadedClassCountImpl(JNIEnv *env, jobject beanInstance)
67
{
68
J9JavaVM *javaVM = ((J9VMThread *) env)->javaVM;
69
jlong result;
70
J9JavaLangManagementData *mgmt = javaVM->managementData;
71
72
omrthread_rwmutex_enter_read( mgmt->managementDataLock );
73
74
result = (jlong)mgmt->totalClassUnloads;
75
76
omrthread_rwmutex_exit_read( mgmt->managementDataLock );
77
78
return result;
79
}
80
81
void JNICALL
82
Java_com_ibm_java_lang_management_internal_ClassLoadingMXBeanImpl_setVerboseImpl(JNIEnv *env, jobject beanInstance, jboolean value)
83
{
84
J9JavaVM *javaVM = ((J9VMThread *) env)->javaVM;
85
J9VerboseSettings verboseOptions;
86
87
memset(&verboseOptions, 0, sizeof(J9VerboseSettings));
88
if( javaVM->setVerboseState != NULL ) {
89
verboseOptions.vclass = value? VERBOSE_SETTINGS_SET: VERBOSE_SETTINGS_CLEAR;
90
javaVM->setVerboseState( javaVM, &verboseOptions, NULL );
91
}
92
}
93
94