mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-11 05:59:52 +00:00
8298380: Clean up redundant array length checks in JDK code base
Reviewed-by: dholmes, amenkov, serb, vtewari
This commit is contained in:
parent
33d955ad6e
commit
e3c6cf8eaf
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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];
|
||||
|
||||
@ -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<Assumptions.Assumption> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user