Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_structs/ClassLoaderClassesIterator.hpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2018 IBM Corp. and others
4
*
5
* This program and the accompanying materials are made available under
6
* the terms of the Eclipse Public License 2.0 which accompanies this
7
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
8
* or the Apache License, Version 2.0 which accompanies this distribution and
9
* is available at https://www.apache.org/licenses/LICENSE-2.0.
10
*
11
* This Source Code may also be made available under the following
12
* Secondary Licenses when the conditions for such availability set
13
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
14
* General Public License, version 2 with the GNU Classpath
15
* Exception [1] and GNU General Public License, version 2 with the
16
* OpenJDK Assembly Exception [2].
17
*
18
* [1] https://www.gnu.org/software/classpath/license.html
19
* [2] http://openjdk.java.net/legal/assembly-exception.html
20
*
21
* 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
22
*******************************************************************************/
23
24
/**
25
* @file
26
* @ingroup GC_Structs
27
*/
28
29
#if !defined(HASHCLASSTABLEITERATOR_HPP_)
30
#define HASHCLASSTABLEITERATOR_HPP_
31
32
#include "j9.h"
33
#include "j9protos.h"
34
#include "modron.h"
35
36
#include "VMClassSlotIterator.hpp"
37
#include "ClassLoaderSegmentIterator.hpp"
38
#include "ClassHeapIterator.hpp"
39
40
class MM_GCExtensionsBase;
41
42
/**
43
* Iterate over all the defined and referenced classes in a ClassLoader.
44
* Note that this also includes array classes of defined classes as well
45
* as system classes (Byte.TYPE, [C, ...) for the system class loader.
46
* Replaced (HCR) classes are not included.
47
*
48
* @ingroup GC_Structs
49
*/
50
class GC_ClassLoaderClassesIterator
51
{
52
private:
53
J9JavaVM* _javaVM; /**< the JavaVM */
54
J9ClassLoader *_classLoader; /**< the loader being iterated */
55
J9Class *_nextClass; /**< the next class to be returned */
56
J9HashTableState _walkState; /**< an opaque state structure used by VM helpers */
57
GC_ClassLoaderSegmentIterator _vmSegmentIterator; /**< used for finding anonymous classes for the anonymous loader */
58
GC_VMClassSlotIterator _vmClassSlotIterator; /**< used for finding system classes for the system loader */
59
enum ScanModes {
60
TABLE_CLASSES,
61
SYSTEM_CLASSES,
62
ANONYMOUS_CLASSES
63
};
64
ScanModes _mode; /**< indicate type of classes to be iterated */
65
66
protected:
67
public:
68
69
private:
70
/**
71
* Find the next class in the JavaVM. This should only be called in SYSTEM_CLASSES mode.
72
* @return the next system class, or NULL if finished
73
*/
74
J9Class *nextSystemClass();
75
76
/**
77
* Find the first class in the loader's table or first Anonymous class from segment.
78
* If none, and if this is the system class loader, switch to SYSTEM_CLASSES mode and
79
* return the first system class.
80
* @return the first table class, first system class, or NULL if no classes
81
*/
82
J9Class *firstClass();
83
84
/**
85
* Find the next anonymous class from segment
86
* @return the next anonymous class or NULL if no classes
87
*/
88
J9Class *nextAnonymousClass();
89
90
/**
91
* Find the next class in the loader's table. If none, and if this is the system class
92
* loader, switch to SYSTEM_CLASSES mode and return the first system class
93
* @return the next table class, first system class, or NULL if no classes
94
*/
95
J9Class *nextTableClass();
96
97
/**
98
* If this is the system class loader, switch from TABLE_CLASSES to SYSTEM_CLASSES mode.
99
* @return true if this is the system class loader, false otherwise
100
*/
101
bool switchToSystemMode();
102
103
protected:
104
105
public:
106
/**
107
* Construct a new iterator for iterating over defined and referenced classes in the
108
* specified ClassLoader
109
* @param extensions[in] the GC extensions
110
* @param classLoader[in] the loader to iterate
111
*/
112
GC_ClassLoaderClassesIterator(MM_GCExtensionsBase *extensions, J9ClassLoader *classLoader);
113
114
/**
115
* Fetch the next defined or referenced class.
116
* @return the next class, or NULL if finished
117
*/
118
J9Class *nextClass();
119
};
120
121
#endif /* HASHCLASSTABLEITERATOR_HPP_ */
122
123
124
125