diff --git a/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java b/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java index 0822b17f0bb..357fc20ec86 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java +++ b/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java @@ -169,9 +169,9 @@ public static int getPreviewFlags(String name, Predicate hasEntry) { * *

Based on the module links, the flags are: *

* diff --git a/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java b/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java index 2cf28b835ce..fb97a869e8b 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java +++ b/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java @@ -325,7 +325,7 @@ private ArrayList processPackagesDirectory(boolean previewMode) { ImageLocation pkgDir = getLocation(offsets.get(i)); int flags = pkgDir.getFlags(); // A package subdirectory is "preview only" if all the modules - // it references have that package marked as preview only. + // it links have that package marked as preview only. // Skipping these entries avoids empty package subdirectories. if (previewMode || !ImageLocation.isPreviewOnly(flags)) { pkgDirs.add(ensureCached(newDirectory(pkgDir.getFullName()))); diff --git a/src/java.base/share/classes/jdk/internal/jimage/ModuleLink.java b/src/java.base/share/classes/jdk/internal/jimage/ModuleLink.java index 57224906179..a6b781d2c95 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/ModuleLink.java +++ b/src/java.base/share/classes/jdk/internal/jimage/ModuleLink.java @@ -98,6 +98,8 @@ public static ModuleLink forEmptyPackage(String moduleName, boolean isPreview) { /** * Returns the appropriate FLAGS_PKG_HAS_XXX_VERSION constant according to * whether the associated package is defined for preview mode. + * + * @param isPreview whether the associated package is defined for preview mode. */ private static int previewFlag(boolean isPreview) { return isPreview ? FLAGS_PKG_HAS_PREVIEW_VERSION : FLAGS_PKG_HAS_NORMAL_VERSION; @@ -261,7 +263,7 @@ public Integer next() { public static void write( List links, IntBuffer buffer, Function nameEncoder) { if (links.isEmpty()) { - throw new IllegalArgumentException("References list must be non-empty"); + throw new IllegalArgumentException("Links list must be non-empty"); } int expectedCapacity = 2 * links.size(); if (buffer.capacity() != expectedCapacity) { @@ -271,13 +273,13 @@ public static void write( // This catches exact duplicates in the list. links.stream().reduce((lhs, rhs) -> { if (lhs.compareTo(rhs) >= 0) { - throw new IllegalArgumentException("References must be strictly ordered: " + links); + throw new IllegalArgumentException("Links must be strictly ordered: " + links); } return rhs; }); - // Distinct references can have the same name (but we don't allow this). + // Distinct links can have the same name (but we don't allow this). if (links.stream().map(ModuleLink::name).distinct().count() != links.size()) { - throw new IllegalArgumentException("Module links names must be unique: " + links); + throw new IllegalArgumentException("Module link names must be unique: " + links); } if (links.stream().filter(ModuleLink::hasResources).count() > 1) { throw new IllegalArgumentException("At most one module link can have resources: " + links); diff --git a/test/jdk/jdk/internal/jimage/ImageLocationTest.java b/test/jdk/jdk/internal/jimage/ImageLocationTest.java index c6837c38265..b6a6bfdb4d3 100644 --- a/test/jdk/jdk/internal/jimage/ImageLocationTest.java +++ b/test/jdk/jdk/internal/jimage/ImageLocationTest.java @@ -48,7 +48,7 @@ public class ImageLocationTest { @ValueSource(strings = { "/modules/modfoo/com", "/modules/modfoo/com/foo/Foo.class"}) - public void getFlags_resourceNames(String name) { + public void getPreviewFlags_resourceNames(String name) { String previewName = previewName(name); int noPreviewFlags = @@ -74,12 +74,12 @@ public void getFlags_resourceNames(String name) { "/modules/modfoo", "/modules/modfoo/META-INF", "/modules/modfoo/META-INF/module-info.class"}) - public void getFlags_zero(String name) { + public void getPreviewFlags_zero(String name) { assertEquals(0, ImageLocation.getPreviewFlags(name, Set.of(name)::contains)); } @Test - public void getFlags_packageFlags() { + public void getPreviewFlags_packageFlags() { assertThrows( IllegalArgumentException.class, () -> ImageLocation.getPreviewFlags("/packages/pkgname", p -> true)); @@ -115,7 +115,7 @@ public void getPackageFlags_previewOnly() { ModuleLink.forEmptyPackage("modbar", true), ModuleLink.forEmptyPackage("modbaz", true)); int previewOnlyFlags = ImageLocation.getPackageFlags(links); - // Note the asymmetry between this and the getFlags() case. Unlike + // Note the asymmetry between this and the getPreviewFlags() case. Unlike // module resources, there is no concept of a separate package directory // existing in the preview namespace, so a single entry serves both // purposes, and hasPreviewVersion() and isPreviewOnly() can both be set. diff --git a/test/jdk/jdk/internal/jimage/ModuleLinkTest.java b/test/jdk/jdk/internal/jimage/ModuleLinkTest.java index e87dd03f37d..d8b561e778c 100644 --- a/test/jdk/jdk/internal/jimage/ModuleLinkTest.java +++ b/test/jdk/jdk/internal/jimage/ModuleLinkTest.java @@ -143,7 +143,7 @@ public void writeBuffer_multiplePackagesWithResources() { @Test public void writeBuffer_badOrdering() { - // Badly ordered because preview references should come first. + // Badly ordered because preview links should come first. List links = Arrays.asList( forEmptyPackage("alpha", false), forEmptyPackage("beta", true)); diff --git a/test/jdk/tools/jlink/whitebox/jdk.jlink/jdk/tools/jlink/internal/ImageResourcesTreeTest.java b/test/jdk/tools/jlink/whitebox/jdk.jlink/jdk/tools/jlink/internal/ImageResourcesTreeTest.java index e62cb0a3363..180cf6480cb 100644 --- a/test/jdk/tools/jlink/whitebox/jdk.jlink/jdk/tools/jlink/internal/ImageResourcesTreeTest.java +++ b/test/jdk/tools/jlink/whitebox/jdk.jlink/jdk/tools/jlink/internal/ImageResourcesTreeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -241,25 +241,25 @@ static void assertContainsResources(Node dirNode, String... resourceNames) { static void assertNonEmptyLink(ModuleLink link, String modName) { assertEquals(modName, link.name(), "Unexpected module name: " + link); - assertTrue(link.hasResources(), "Expected non-empty linkerence: " + link); + assertTrue(link.hasResources(), "Expected non-empty link: " + link); assertFalse(link.isPreviewOnly(), "Expected not preview-only: " + link); } static void assertEmptyLink(ModuleLink link, String modName) { assertEquals(modName, link.name(), "Unexpected module name: " + link); - assertFalse(link.hasResources(), "Expected empty linkerence: " + link); + assertFalse(link.hasResources(), "Expected empty link: " + link); assertFalse(link.isPreviewOnly(), "Expected not preview-only: " + link); } static void assertNonEmptyPreviewOnlyLink(ModuleLink link, String modName) { assertEquals(modName, link.name(), "Unexpected module name: " + link); - assertTrue(link.hasResources(), "Expected empty linkerence: " + link); + assertTrue(link.hasResources(), "Expected non-empty link: " + link); assertTrue(link.isPreviewOnly(), "Expected preview-only: " + link); } static void assertEmptyPreviewOnlyLink(ModuleLink link, String modName) { assertEquals(modName, link.name(), "Unexpected module name: " + link); - assertFalse(link.hasResources(), "Expected empty linkerence: " + link); + assertFalse(link.hasResources(), "Expected empty link: " + link); assertTrue(link.isPreviewOnly(), "Expected preview-only: " + link); } }