8274333: Redundant null comparison after Pattern.split

Reviewed-by: mullan, weijun, rriggs, iris
This commit is contained in:
Andrey Turbanov 2021-11-19 18:49:04 +00:00 committed by Roger Riggs
parent 6677554374
commit 36b59f3814
2 changed files with 9 additions and 10 deletions

View file

@ -34,11 +34,6 @@ package sun.launcher;
* *
*/ */
/**
* A utility package for the java(1), javaw(1) launchers.
* The following are helper methods that the native launcher uses
* to perform checks etc. using JNI, see src/share/bin/java.c
*/
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
@ -88,7 +83,11 @@ import jdk.internal.module.Modules;
import jdk.internal.platform.Container; import jdk.internal.platform.Container;
import jdk.internal.platform.Metrics; import jdk.internal.platform.Metrics;
/**
* A utility package for the java(1), javaw(1) launchers.
* The following are helper methods that the native launcher uses
* to perform checks etc. using JNI, see src/share/bin/java.c
*/
public final class LauncherHelper { public final class LauncherHelper {
// No instantiation // No instantiation
@ -154,8 +153,8 @@ public final class LauncherHelper {
long initialHeapSize, long maxHeapSize, long stackSize) { long initialHeapSize, long maxHeapSize, long stackSize) {
initOutput(printToStderr); initOutput(printToStderr);
String opts[] = optionFlag.split(":"); String[] opts = optionFlag.split(":");
String optStr = (opts.length > 1 && opts[1] != null) String optStr = opts.length > 1
? opts[1].trim() ? opts[1].trim()
: "all"; : "all";
switch (optStr) { switch (optStr) {

View file

@ -57,7 +57,7 @@ public class AlgorithmDecomposer {
String[] transTokens = algorithm.split("/"); String[] transTokens = algorithm.split("/");
for (String transToken : transTokens) { for (String transToken : transTokens) {
if (transToken == null || transToken.isEmpty()) { if (transToken.isEmpty()) {
continue; continue;
} }
@ -70,7 +70,7 @@ public class AlgorithmDecomposer {
String[] tokens = PATTERN.split(transToken); String[] tokens = PATTERN.split(transToken);
for (String token : tokens) { for (String token : tokens) {
if (token == null || token.isEmpty()) { if (token.isEmpty()) {
continue; continue;
} }