Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8274394: Use Optional.isEmpty instead of !Optional.isPresent in jdk.jlink

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -281,7 +281,7 @@ protected void prepareApplicationFiles(ResourcePool imageContent) throws IOExcep
if (mainClassName == null) {
String path = "/" + module + "/module-info.class";
Optional<ResourcePoolEntry> res = imageContent.findEntry(path);
if (!res.isPresent()) {
if (res.isEmpty()) {
throw new IOException("module-info.class not found for " + module + " module");
}
ByteArrayInputStream stream = new ByteArrayInputStream(res.get().contentBytes());
@@ -293,8 +293,8 @@ protected void prepareApplicationFiles(ResourcePool imageContent) throws IOExcep

if (mainClassName != null) {
// make sure main class exists!
if (!imageContent.findEntry("/" + module + "/" +
mainClassName.replace('.', '/') + ".class").isPresent()) {
if (imageContent.findEntry("/" + module + "/" +
mainClassName.replace('.', '/') + ".class").isEmpty()) {
throw new IllegalArgumentException(module + " does not have main class: " + mainClassName);
}

@@ -397,7 +397,7 @@ private JlinkConfiguration initJlinkConfig() throws BadArgs {
}

ModuleFinder finder = newModuleFinder(options.modulePath, options.limitMods, roots);
if (!finder.find("java.base").isPresent()) {
if (finder.find("java.base").isEmpty()) {
Path defModPath = getDefaultModulePath();
if (defModPath != null) {
options.modulePath.add(defModPath);
@@ -517,7 +517,7 @@ public FileVisitResult postVisitDirectory(Path dir, IOException e)

private static Path toPathLocation(ResolvedModule m) {
Optional<URI> ouri = m.reference().location();
if (!ouri.isPresent())
if (ouri.isEmpty())
throw new InternalError(m + " does not have a location");
URI uri = ouri.get();
return Paths.get(uri);
@@ -54,7 +54,7 @@ public class ResourcePoolManager {
static Attributes readModuleAttributes(ResourcePoolModule mod) {
String p = "/" + mod.name() + "/module-info.class";
Optional<ResourcePoolEntry> content = mod.findEntry(p);
if (!content.isPresent()) {
if (content.isEmpty()) {
throw new PluginException("module-info.class not found for " +
mod.name() + " module");
}
@@ -111,7 +111,7 @@ private void dedupLegalNoticeEntry(ResourcePoolEntry entry) {
.filter(e -> e.linkedTarget() == null)
.filter(e -> Arrays.equals(e.contentBytes(), entry.contentBytes()))
.findFirst();
if (!otarget.isPresent()) {
if (otarget.isEmpty()) {
if (errorIfNotSameContent) {
// all legal notices of the same file name are expected
// to contain the same content
@@ -890,7 +890,7 @@ private class Hasher {
// filter modules resolved from the system module finder
this.modules = config.modules().stream()
.map(ResolvedModule::name)
.filter(mn -> roots.contains(mn) && !system.find(mn).isPresent())
.filter(mn -> roots.contains(mn) && system.find(mn).isEmpty())
.collect(Collectors.toSet());

this.hashesBuilder = new ModuleHashesBuilder(config, modules);