Skip to content
Permalink
Browse files
8274394: Use Optional.isEmpty instead of !Optional.isPresent in jdk.j…
…link

Reviewed-by: alanb, mchung
  • Loading branch information
turbanoff authored and Mandy Chung committed Sep 28, 2021
1 parent 94f5e80 commit 6f4cefbcbaad38dcacd4e047c6c232a0a7a2c19c
Showing 5 changed files with 8 additions and 8 deletions.
@@ -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);

1 comment on commit 6f4cefb

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 6f4cefb Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.