Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/jcl/common/java_lang_ref_Finalizer.c
6000 views
1
/*******************************************************************************
2
* Copyright (c) 1998, 2018 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 <string.h>
24
#include "jni.h"
25
#include "jcl.h"
26
#include "jclglob.h"
27
#include "jclprots.h"
28
#include "jcl_internal.h"
29
30
/* java.lang.ref.Finalizer: private native static void runAllFinalizersImpl(); */
31
void JNICALL
32
Java_java_lang_ref_Finalizer_runAllFinalizersImpl(JNIEnv *env, jclass recv)
33
{
34
J9VMThread *currentThread = (J9VMThread*)env;
35
J9JavaVM *vm = currentThread->javaVM;
36
J9MemoryManagerFunctions *mmFuncs = vm->memoryManagerFunctions;
37
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI)
38
J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions;
39
vmFuncs->internalEnterVMFromJNI(currentThread);
40
vmFuncs->internalReleaseVMAccess(currentThread);
41
#endif /* J9VM_INTERP_ATOMIC_FREE_JNI */
42
mmFuncs->j9gc_runFinalizersOnExit(currentThread, TRUE);
43
mmFuncs->j9gc_finalizer_completeFinalizersOnExit(currentThread);
44
}
45
46
/* java.lang.ref.Finalizer: private native static void runFinalizationImpl(); */
47
void JNICALL
48
Java_java_lang_ref_Finalizer_runFinalizationImpl(JNIEnv *env, jclass recv)
49
{
50
J9VMThread *currentThread = (J9VMThread*)env;
51
J9JavaVM *vm = currentThread->javaVM;
52
J9MemoryManagerFunctions *mmFuncs = vm->memoryManagerFunctions;
53
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI)
54
J9InternalVMFunctions *vmFuncs = vm->internalVMFunctions;
55
vmFuncs->internalEnterVMFromJNI(currentThread);
56
vmFuncs->internalReleaseVMAccess(currentThread);
57
#endif /* J9VM_INTERP_ATOMIC_FREE_JNI */
58
mmFuncs->runFinalization(currentThread);
59
}
60
61