Skip to content

Commit 630371a

Browse files
committed
Distinguish resources with actual content vs resources where only the
access has been registered.
1 parent 9e3ca64 commit 630371a

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Resources.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,10 @@ public String getModuleName() {
219219
}
220220

221221
/**
222-
* The object used to mark a resource as reachable according to the metadata. It can be obtained
223-
* when accessing the {@link Resources#resources} map, and it means that even though the
224-
* resource was correctly specified in the configuration, accessing it will return null.
222+
* A resource marked with the NEGATIVE_QUERY_MARKER is a resource included in the image
223+
* according to the resource configuration, but it does not actually exist. Trying to access it
224+
* at runtime will return {@code null} and not throw a
225+
* {@link com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError}.
225226
*/
226227
public static final ResourceStorageEntryBase NEGATIVE_QUERY_MARKER = new ResourceStorageEntryBase();
227228

@@ -231,7 +232,7 @@ public String getModuleName() {
231232
* correctly specified in the configuration, but we do not want to throw directly (for example
232233
* when we try to check all the modules for a resource).
233234
*/
234-
private static final ResourceStorageEntryBase MISSING_METADATA_MARKER = new ResourceStorageEntryBase();
235+
public static final ResourceStorageEntryBase MISSING_METADATA_MARKER = new ResourceStorageEntryBase();
235236

236237
/**
237238
* Embedding a resource into an image is counted as a modification. Since all resources are

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/resources/ResourceStorageEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
public final class ResourceStorageEntry extends ResourceStorageEntryBase {
3737

38-
private static byte[][] EMPTY_DATA = new byte[0][];
38+
private static final byte[][] EMPTY_DATA = new byte[0][];
3939

4040
private final boolean isDirectory;
4141
private final boolean fromJar;

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ private void printAnalysisStatistics(AnalysisUniverse universe, Collection<Strin
522522
}
523523
}
524524
if (resourceCount > 0) {
525-
l().a("%,9d %s found with %s total size", resourceCount, resourceCount == 1 ? "resource" : "resources", ByteFormattingUtil.bytesToHuman(totalResourceSize)).println();
525+
l().a("%,9d %s registered with %s total size", resourceCount, resourceCount == 1 ? "resource access" : "resource accesses", ByteFormattingUtil.bytesToHuman(totalResourceSize)).println();
526526
}
527527
int numLibraries = libraries.size();
528528
if (numLibraries > 0) {
@@ -592,10 +592,15 @@ public void printCreationEnd(int imageFileSize, int heapObjectCount, long imageH
592592
String format = "%9s (%5.2f%%) for ";
593593
l().a(format, ByteFormattingUtil.bytesToHuman(codeAreaSize), Utils.toPercentage(codeAreaSize, imageFileSize))
594594
.doclink("code area", "#glossary-code-area").a(":%,10d compilation units", numCompilations).println();
595-
int numResources = Resources.currentLayer().resources().size();
595+
int numResources = 0;
596+
for (ConditionalRuntimeValue<ResourceStorageEntryBase> entry : Resources.currentLayer().resources().getValues()) {
597+
if (entry.getValueUnconditionally() != Resources.NEGATIVE_QUERY_MARKER && entry.getValueUnconditionally() != Resources.MISSING_METADATA_MARKER) {
598+
numResources++;
599+
}
600+
}
596601
recordJsonMetric(ImageDetailKey.IMAGE_HEAP_RESOURCE_COUNT, numResources);
597602
l().a(format, ByteFormattingUtil.bytesToHuman(imageHeapSize), Utils.toPercentage(imageHeapSize, imageFileSize))
598-
.doclink("image heap", "#glossary-image-heap").a(":%,9d objects and %,d resources", heapObjectCount, numResources).println();
603+
.doclink("image heap", "#glossary-image-heap").a(":%,9d objects and %,d resource%s", heapObjectCount, numResources, numResources == 1 ? "" : "s").println();
599604
long otherBytes = imageFileSize - codeAreaSize - imageHeapSize;
600605
if (debugInfoSize > 0) {
601606
recordJsonMetric(ImageDetailKey.DEBUG_INFO_SIZE, debugInfoSize); // Optional metric

0 commit comments

Comments
 (0)