diff --git a/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java b/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java index 41d9fbb0816..863b8cd7aff 100644 --- a/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java +++ b/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java @@ -226,15 +226,13 @@ class LinuxWatchService } // no modifiers supported at this time - if (modifiers.length > 0) { - for (WatchEvent.Modifier modifier: modifiers) { - if (modifier == null) - return new NullPointerException(); - if (!ExtendedOptions.SENSITIVITY_HIGH.matches(modifier) && - !ExtendedOptions.SENSITIVITY_MEDIUM.matches(modifier) && - !ExtendedOptions.SENSITIVITY_LOW.matches(modifier)) { - return new UnsupportedOperationException("Modifier not supported"); - } + for (WatchEvent.Modifier modifier : modifiers) { + if (modifier == null) + return new NullPointerException(); + if (!ExtendedOptions.SENSITIVITY_HIGH.matches(modifier) && + !ExtendedOptions.SENSITIVITY_MEDIUM.matches(modifier) && + !ExtendedOptions.SENSITIVITY_LOW.matches(modifier)) { + return new UnsupportedOperationException("Modifier not supported"); } } diff --git a/src/java.base/share/classes/java/nio/file/spi/FileSystemProvider.java b/src/java.base/share/classes/java/nio/file/spi/FileSystemProvider.java index 448843ba547..17caff30b03 100644 --- a/src/java.base/share/classes/java/nio/file/spi/FileSystemProvider.java +++ b/src/java.base/share/classes/java/nio/file/spi/FileSystemProvider.java @@ -411,13 +411,11 @@ public abstract class FileSystemProvider { public InputStream newInputStream(Path path, OpenOption... options) throws IOException { - if (options.length > 0) { - for (OpenOption opt: options) { - // All OpenOption values except for APPEND and WRITE are allowed - if (opt == StandardOpenOption.APPEND || - opt == StandardOpenOption.WRITE) - throw new UnsupportedOperationException("'" + opt + "' not allowed"); - } + for (OpenOption opt : options) { + // All OpenOption values except for APPEND and WRITE are allowed + if (opt == StandardOpenOption.APPEND || + opt == StandardOpenOption.WRITE) + throw new UnsupportedOperationException("'" + opt + "' not allowed"); } ReadableByteChannel rbc = Files.newByteChannel(path, options); if (rbc instanceof FileChannelImpl) { diff --git a/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java b/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java index 93157421e5c..663e30cb0c5 100644 --- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java +++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java @@ -627,11 +627,9 @@ final class JrtPath implements Path { } final InputStream newInputStream(OpenOption... options) throws IOException { - if (options.length > 0) { - for (OpenOption opt : options) { - if (opt != READ) { - throw new UnsupportedOperationException("'" + opt + "' not allowed"); - } + for (OpenOption opt : options) { + if (opt != READ) { + throw new UnsupportedOperationException("'" + opt + "' not allowed"); } } return jrtfs.newInputStream(this); diff --git a/src/java.base/share/classes/sun/nio/fs/PollingWatchService.java b/src/java.base/share/classes/sun/nio/fs/PollingWatchService.java index 582462c36c1..f86626d196a 100644 --- a/src/java.base/share/classes/sun/nio/fs/PollingWatchService.java +++ b/src/java.base/share/classes/sun/nio/fs/PollingWatchService.java @@ -119,20 +119,18 @@ class PollingWatchService // Extended modifiers may be used to specify the sensitivity level int sensitivity = DEFAULT_POLLING_INTERVAL; - if (modifiers.length > 0) { - for (WatchEvent.Modifier modifier: modifiers) { - if (modifier == null) - throw new NullPointerException(); + for (WatchEvent.Modifier modifier : modifiers) { + if (modifier == null) + throw new NullPointerException(); - if (ExtendedOptions.SENSITIVITY_HIGH.matches(modifier)) { - sensitivity = ExtendedOptions.SENSITIVITY_HIGH.parameter(); - } else if (ExtendedOptions.SENSITIVITY_MEDIUM.matches(modifier)) { - sensitivity = ExtendedOptions.SENSITIVITY_MEDIUM.parameter(); - } else if (ExtendedOptions.SENSITIVITY_LOW.matches(modifier)) { - sensitivity = ExtendedOptions.SENSITIVITY_LOW.parameter(); - } else { - throw new UnsupportedOperationException("Modifier not supported"); - } + if (ExtendedOptions.SENSITIVITY_HIGH.matches(modifier)) { + sensitivity = ExtendedOptions.SENSITIVITY_HIGH.parameter(); + } else if (ExtendedOptions.SENSITIVITY_MEDIUM.matches(modifier)) { + sensitivity = ExtendedOptions.SENSITIVITY_MEDIUM.parameter(); + } else if (ExtendedOptions.SENSITIVITY_LOW.matches(modifier)) { + sensitivity = ExtendedOptions.SENSITIVITY_LOW.parameter(); + } else { + throw new UnsupportedOperationException("Modifier not supported"); } } diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java index d8bfca02fe7..2cfaa5a36ca 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022, 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 @@ -653,10 +653,8 @@ public class AquaFileChooserUI extends FileChooserUI { int selectableCount = 0; // Double-check that all the list selections are valid for this mode // Directories can be selected in the list regardless of mode - if (rows.length > 0) { - for (final int element : rows) { - if (isSelectableForMode(chooser, (File)fFileList.getValueAt(element, 0))) selectableCount++; - } + for (final int element : rows) { + if (isSelectableForMode(chooser, (File) fFileList.getValueAt(element, 0))) selectableCount++; } if (selectableCount > 0) { final File[] files = new File[selectableCount]; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/Assumptions.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/Assumptions.java index 688d1e732c3..ddbd7ba9805 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/Assumptions.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/Assumptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022, 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 @@ -89,10 +89,8 @@ public final class Assumptions implements Iterable { public void recordTo(Assumptions target) { assert canRecordTo(target); - if (assumptions.length > 0) { - for (Assumption assumption : assumptions) { - target.record(assumption); - } + for (Assumption assumption : assumptions) { + target.record(assumption); } } diff --git a/src/jdk.jconsole/share/classes/sun/tools/jconsole/inspector/XTree.java b/src/jdk.jconsole/share/classes/sun/tools/jconsole/inspector/XTree.java index aaa1ab6a6bd..d133e1cf8bb 100644 --- a/src/jdk.jconsole/share/classes/sun/tools/jconsole/inspector/XTree.java +++ b/src/jdk.jconsole/share/classes/sun/tools/jconsole/inspector/XTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2022, 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 @@ -649,7 +649,7 @@ public class XTree extends JTree { Messages.NOTIFICATIONS, null); notifications.setUserObject(notificationsUO); node.insert(notifications, childIndex++); - if (ni != null && ni.length > 0) { + if (ni != null) { for (MBeanNotificationInfo mbni : ni) { DefaultMutableTreeNode notification = new DefaultMutableTreeNode(); diff --git a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java index e14eba3863e..806c8d352bf 100644 --- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java +++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java @@ -744,11 +744,9 @@ final class ZipPath implements Path { InputStream newInputStream(OpenOption... options) throws IOException { - if (options.length > 0) { - for (OpenOption opt : options) { - if (opt != READ) - throw new UnsupportedOperationException("'" + opt + "' not allowed"); - } + for (OpenOption opt : options) { + if (opt != READ) + throw new UnsupportedOperationException("'" + opt + "' not allowed"); } return zfs.newInputStream(getResolvedPath()); }