Skip to content

Commit d00cec4

Browse files
committed
[GR-32118] Replace Heap.getInitializedClasses with Heap.getLoadedClasses.
PullRequest: graal/9223
2 parents bba1178 + 39003e1 commit d00cec4

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ClassHistogramVisitor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ClassHistogramVisitor implements ObjectVisitor {
3636

3737
public ClassHistogramVisitor() {
3838
// NOTE: we cannot use a map because lookups in the visitor must be allocation-free
39-
entries = Heap.getHeap().getInitializedClasses().stream().map(Class::getName).sorted()
39+
entries = Heap.getHeap().getLoadedClasses().stream().map(Class::getName).sorted()
4040
.map(HistogramEntry::new).toArray(HistogramEntry[]::new);
4141
}
4242

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/Heap.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,21 @@ protected Heap() {
100100
/** Returns the number of classes in the heap (initialized as well as uninitialized). */
101101
public abstract int getClassCount();
102102

103-
/** Return a list of all the initialized classes in the heap. */
104-
public List<Class<?>> getInitializedClasses() {
105-
List<Class<?>> allClasses = getAllClasses();
106-
ArrayList<Class<?>> initializedClasses = new ArrayList<>(allClasses.size());
107-
for (Class<?> clazz : allClasses) {
108-
if (DynamicHub.fromClass(clazz).isInitialized()) {
109-
initializedClasses.add(clazz);
103+
/** Returns all loaded classes in the heap (see {@link PredefinedClassesSupport}). */
104+
public List<Class<?>> getLoadedClasses() {
105+
List<Class<?>> all = getAllClasses();
106+
ArrayList<Class<?>> loaded = new ArrayList<>(all.size());
107+
for (Class<?> clazz : all) {
108+
if (DynamicHub.fromClass(clazz).isLoaded()) {
109+
loaded.add(clazz);
110110
}
111111
}
112-
return initializedClasses;
112+
return loaded;
113113
}
114114

115115
/**
116-
* Get all known classes. Intentionally protected to prevent access to uninitialized classes,
117-
* including those that have not been "loaded" yet, see {@link PredefinedClassesSupport}.
116+
* Get all known classes. Intentionally protected to prevent access to classes that have not
117+
* been "loaded" yet, see {@link PredefinedClassesSupport}.
118118
*/
119119
protected abstract List<Class<?>> getAllClasses();
120120

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ private ClassLoader getClassLoader0() {
747747
return (ClassLoader) classLoader;
748748
}
749749

750-
boolean hasClassLoader() {
750+
public boolean isLoaded() {
751751
return classLoader != FROM_COMPANION || (companion.isPresent() && companion.get().hasClassLoader());
752752
}
753753

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/PredefinedClassesSupport.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static void throwIfUnresolvable(Class<?> clazz, ClassLoader classLoader)
136136
return;
137137
}
138138
DynamicHub hub = DynamicHub.fromClass(clazz);
139-
if (!hub.hasClassLoader()) {
139+
if (!hub.isLoaded()) {
140140
throwResolutionError(clazz.getName());
141141
}
142142
if (!isSameOrParent(clazz.getClassLoader(), classLoader)) { // common case: same loader

substratevm/src/com.oracle.svm.jfr/src/com/oracle/svm/jfr/JfrTypeRepository.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public int write(JfrChunkWriter writer) {
6565

6666
private TypeInfo collectTypeInfo() {
6767
TypeInfo typeInfo = new TypeInfo();
68-
for (Class<?> clazz : Heap.getHeap().getInitializedClasses()) {
68+
for (Class<?> clazz : Heap.getHeap().getLoadedClasses()) {
6969
if (JfrTraceId.isUsedPreviousEpoch(clazz)) {
7070
JfrTraceId.clearUsedPreviousEpoch(clazz);
7171
visitClass(typeInfo, clazz);

0 commit comments

Comments
 (0)