inLocale
is null
*/
public String getDisplayVariant(Locale inLocale) {
- if (baseLocale.getVariant().length() == 0)
+ if (baseLocale.getVariant().isEmpty())
return "";
LocaleResources lr = LocaleProviderAdapter
@@ -1998,14 +1998,14 @@ public final class Locale implements Cloneable, Serializable {
// The display name consists of a main name, followed by qualifiers.
// Typically, the format is "MainName (Qualifier, Qualifier)" but this
// depends on what pattern is stored in the display locale.
- String mainName = null;
- String[] qualifierNames = null;
+ String mainName;
+ String[] qualifierNames;
// The main name is the language, or if there is no language, the script,
// then if no script, the country. If there is no language/script/country
// (an anomalous situation) then the display name is simply the variant's
// display name.
- if (languageName.length() == 0 && scriptName.length() == 0 && countryName.length() == 0) {
+ if (languageName.isEmpty() && scriptName.isEmpty() && countryName.isEmpty()) {
if (variantNames.length == 0) {
return "";
} else {
@@ -2013,13 +2013,13 @@ public final class Locale implements Cloneable, Serializable {
}
}
ArrayListFtpProtocolException
*/
public sun.net.ftp.FtpClient changeDirectory(String remoteDirectory) throws sun.net.ftp.FtpProtocolException, IOException {
- if (remoteDirectory == null || "".equals(remoteDirectory)) {
+ if (remoteDirectory == null || remoteDirectory.isEmpty()) {
throw new IllegalArgumentException("directory can't be null or empty");
}
@@ -1738,7 +1738,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
* @throws IOException if an error occurs during the transmission.
*/
public long getSize(String path) throws sun.net.ftp.FtpProtocolException, IOException {
- if (path == null || path.length() == 0) {
+ if (path == null || path.isEmpty()) {
throw new IllegalArgumentException("path can't be null or empty");
}
issueCommandCheck("SIZE " + path);
diff --git a/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java b/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java
index 2f726c6817c..75a226ae7e0 100644
--- a/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java
+++ b/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java
@@ -238,7 +238,7 @@ public class DefaultProxySelector extends ProxySelector {
if (phost != null && phost.length() != 0)
break;
}
- if (phost == null || phost.length() == 0) {
+ if (phost == null || phost.isEmpty()) {
/**
* No system property defined for that
* protocol. Let's check System Proxy
@@ -267,7 +267,7 @@ public class DefaultProxySelector extends ProxySelector {
nprop.hostsSource = null;
nprop.pattern = null;
}
- } else if (nphosts.length() != 0) {
+ } else if (!nphosts.isEmpty()) {
// add the required default patterns
// but only if property no set. If it
// is empty, leave empty.
diff --git a/src/java.base/share/classes/sun/net/www/HeaderParser.java b/src/java.base/share/classes/sun/net/www/HeaderParser.java
index f9db1df64de..a4b2ab50497 100644
--- a/src/java.base/share/classes/sun/net/www/HeaderParser.java
+++ b/src/java.base/share/classes/sun/net/www/HeaderParser.java
@@ -226,7 +226,7 @@ public class HeaderParser {
for (int i=0; k.hasNext(); i++) {
String key = k.next();
String val = findValue (i);
- if (val != null && "".equals (val)) {
+ if (val != null && val.isEmpty()) {
val = null;
}
sb.append(" {").append(key).append(val == null ? "" : "," + val)
diff --git a/src/java.base/share/classes/sun/net/www/MimeEntry.java b/src/java.base/share/classes/sun/net/www/MimeEntry.java
index 44b7c49b3fa..5690db0fb78 100644
--- a/src/java.base/share/classes/sun/net/www/MimeEntry.java
+++ b/src/java.base/share/classes/sun/net/www/MimeEntry.java
@@ -201,9 +201,7 @@ public class MimeEntry implements Cloneable {
}
private boolean isStarred(String typeName) {
- return (typeName != null)
- && (typeName.length() > 0)
- && (typeName.endsWith("/*"));
+ return typeName != null && typeName.endsWith("/*");
}
/**
@@ -300,7 +298,7 @@ public class MimeEntry implements Cloneable {
}
String extensions = getExtensionsAsList();
- if (extensions.length() > 0) {
+ if (!extensions.isEmpty()) {
sj.add("file_extensions=" + extensions);
}
diff --git a/src/java.base/share/classes/sun/net/www/MimeLauncher.java b/src/java.base/share/classes/sun/net/www/MimeLauncher.java
index a2cfefab33c..452e3a1e4d0 100644
--- a/src/java.base/share/classes/sun/net/www/MimeLauncher.java
+++ b/src/java.base/share/classes/sun/net/www/MimeLauncher.java
@@ -162,7 +162,7 @@ class MimeLauncher extends Thread {
location the application. If a valid path is not found, it
returns false else true. */
private boolean findExecutablePath(String str) {
- if (str == null || str.length() == 0) {
+ if (str == null || str.isEmpty()) {
return false;
}
diff --git a/src/java.base/share/classes/sun/net/www/ParseUtil.java b/src/java.base/share/classes/sun/net/www/ParseUtil.java
index 9ff0c2a4f6c..92f2965b136 100644
--- a/src/java.base/share/classes/sun/net/www/ParseUtil.java
+++ b/src/java.base/share/classes/sun/net/www/ParseUtil.java
@@ -536,8 +536,7 @@ public final class ParseUtil {
throws URISyntaxException
{
if (scheme != null) {
- if ((path != null)
- && ((path.length() > 0) && (path.charAt(0) != '/')))
+ if (path != null && !path.isEmpty() && path.charAt(0) != '/')
throw new URISyntaxException(s,
"Relative path in absolute URI");
}
diff --git a/src/java.base/share/classes/sun/net/www/http/HttpClient.java b/src/java.base/share/classes/sun/net/www/http/HttpClient.java
index 57d734e5166..8b1a81a6df1 100644
--- a/src/java.base/share/classes/sun/net/www/http/HttpClient.java
+++ b/src/java.base/share/classes/sun/net/www/http/HttpClient.java
@@ -603,7 +603,7 @@ public class HttpClient extends NetworkClient {
StringBuilder result = new StringBuilder(128);
result.append(url.getProtocol());
result.append(":");
- if (url.getAuthority() != null && url.getAuthority().length() > 0) {
+ if (url.getAuthority() != null && !url.getAuthority().isEmpty()) {
result.append("//");
result.append(url.getAuthority());
}
@@ -619,7 +619,7 @@ public class HttpClient extends NetworkClient {
} else {
fileName = url.getFile();
- if ((fileName == null) || (fileName.length() == 0)) {
+ if ((fileName == null) || (fileName.isEmpty())) {
fileName = "/";
} else if (fileName.charAt(0) == '?') {
/* HTTP/1.1 spec says in 5.1.2. about Request-URI:
diff --git a/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java b/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java
index 6abb4de2778..228af24e81d 100644
--- a/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java
+++ b/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java
@@ -341,7 +341,7 @@ public class FtpURLConnection extends URLConnection {
path.charAt(0) == '/') {
path = path.substring(1);
}
- if (path == null || path.length() == 0) {
+ if (path == null || path.isEmpty()) {
path = "./";
}
if (!path.endsWith("/")) {
@@ -555,7 +555,7 @@ public class FtpURLConnection extends URLConnection {
}
decodePath(url.getPath());
- if (filename == null || filename.length() == 0) {
+ if (filename == null || filename.isEmpty()) {
throw new IOException("illegal filename for a PUT");
}
try {
diff --git a/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java b/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java
index 725a1f89880..5aa670fded9 100644
--- a/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java
+++ b/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java
@@ -248,7 +248,7 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone
this.realm = realm;
String urlPath = url.getPath();
- if (urlPath.length() == 0)
+ if (urlPath.isEmpty())
this.path = urlPath;
else {
this.path = reducePath (urlPath);
diff --git a/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java b/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java
index 7d49792b099..077a95e3d47 100644
--- a/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java
+++ b/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java
@@ -279,7 +279,7 @@ class DigestAuthentication extends AuthenticationInfo {
if (s == null || !s.equals("true"))
return false;
String newNonce = p.findValue ("nonce");
- if (newNonce == null || "".equals(newNonce)) {
+ if (newNonce == null || newNonce.isEmpty()) {
return false;
}
params.setNonce (newNonce);
@@ -323,7 +323,7 @@ class DigestAuthentication extends AuthenticationInfo {
+ authMethod.substring(1).toLowerCase();
}
String algorithm = p.findValue("algorithm");
- if (algorithm == null || "".equals(algorithm)) {
+ if (algorithm == null || algorithm.isEmpty()) {
algorithm = "MD5"; // The default, accoriding to rfc2069
}
params.setAlgorithm (algorithm);
@@ -451,7 +451,7 @@ class DigestAuthentication extends AuthenticationInfo {
}
/* Check if there is a nextnonce field */
String nextnonce = p.findValue ("nextnonce");
- if (nextnonce != null && ! "".equals(nextnonce)) {
+ if (nextnonce != null && !nextnonce.isEmpty()) {
params.setNonce (nextnonce);
}
diff --git a/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
index ad728fb3da1..16e548dc588 100644
--- a/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
+++ b/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
@@ -3026,7 +3026,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
// Filtering only if there is a cookie handler. [Assumption: the
// cookie handler will store/retrieve the HttpOnly cookies]
- if (cookieHandler == null || value.length() == 0)
+ if (cookieHandler == null || value.isEmpty())
return value;
JavaNetHttpCookieAccess access =
diff --git a/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java b/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java
index 06c0e491465..50cdc97cdfd 100644
--- a/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java
+++ b/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java
@@ -143,7 +143,7 @@ final class HttpsClient extends HttpClient
String cipherString =
GetPropertyAction.privilegedGetProperty("https.cipherSuites");
- if (cipherString == null || "".equals(cipherString)) {
+ if (cipherString == null || cipherString.isEmpty()) {
ciphers = null;
} else {
StringTokenizer tokenizer;
@@ -167,7 +167,7 @@ final class HttpsClient extends HttpClient
String protocolString =
GetPropertyAction.privilegedGetProperty("https.protocols");
- if (protocolString == null || "".equals(protocolString)) {
+ if (protocolString == null || protocolString.isEmpty()) {
protocols = null;
} else {
StringTokenizer tokenizer;
@@ -187,7 +187,7 @@ final class HttpsClient extends HttpClient
private String getUserAgent() {
String userAgent =
GetPropertyAction.privilegedGetProperty("https.agent");
- if (userAgent == null || userAgent.length() == 0) {
+ if (userAgent == null || userAgent.isEmpty()) {
userAgent = "JSSE";
}
return userAgent;
diff --git a/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java b/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java
index c7446082edd..29dac993a8d 100644
--- a/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java
+++ b/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java
@@ -66,7 +66,7 @@ public class JavaRuntimeURLConnection extends URLConnection {
JavaRuntimeURLConnection(URL url) throws IOException {
super(url);
String path = url.getPath();
- if (path.length() == 0 || path.charAt(0) != '/')
+ if (path.isEmpty() || path.charAt(0) != '/')
throw new MalformedURLException(url + " missing path or /");
if (path.length() == 1) {
this.module = null;
diff --git a/src/java.base/share/classes/sun/nio/ch/Net.java b/src/java.base/share/classes/sun/nio/ch/Net.java
index 856efce30b9..fe8b12670e2 100644
--- a/src/java.base/share/classes/sun/nio/ch/Net.java
+++ b/src/java.base/share/classes/sun/nio/ch/Net.java
@@ -403,14 +403,8 @@ public class Net {
public static boolean isFastTcpLoopbackRequested() {
String loopbackProp = GetPropertyAction
- .privilegedGetProperty("jdk.net.useFastTcpLoopback");
- boolean enable;
- if ("".equals(loopbackProp)) {
- enable = true;
- } else {
- enable = Boolean.parseBoolean(loopbackProp);
- }
- return enable;
+ .privilegedGetProperty("jdk.net.useFastTcpLoopback", "false");
+ return loopbackProp.isEmpty() ? true : Boolean.parseBoolean(loopbackProp);
}
// -- Socket operations --
diff --git a/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java b/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java
index 0e325414f5d..679f5857132 100644
--- a/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java
+++ b/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java
@@ -73,7 +73,7 @@ public abstract class AbstractFileSystemProvider extends FileSystemProvider {
throws IOException
{
String[] s = split(attribute);
- if (s[0].length() == 0)
+ if (s[0].isEmpty())
throw new IllegalArgumentException(attribute);
DynamicFileAttributeView view = getFileAttributeView(file, s[0], options);
if (view == null)
@@ -86,7 +86,7 @@ public abstract class AbstractFileSystemProvider extends FileSystemProvider {
throws IOException
{
String[] s = split(attributes);
- if (s[0].length() == 0)
+ if (s[0].isEmpty())
throw new IllegalArgumentException(attributes);
DynamicFileAttributeView view = getFileAttributeView(file, s[0], options);
if (view == null)
diff --git a/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java b/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java
index 3886aa1b114..a349b08ccf6 100644
--- a/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java
+++ b/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java
@@ -83,7 +83,7 @@ abstract class AbstractUserDefinedFileAttributeView
names = list();
break;
} else {
- if (name.length() == 0)
+ if (name.isEmpty())
throw new IllegalArgumentException();
names.add(name);
}
diff --git a/src/java.base/share/classes/sun/security/jca/GetInstance.java b/src/java.base/share/classes/sun/security/jca/GetInstance.java
index a5e5602dc4d..fd513c47edb 100644
--- a/src/java.base/share/classes/sun/security/jca/GetInstance.java
+++ b/src/java.base/share/classes/sun/security/jca/GetInstance.java
@@ -75,7 +75,7 @@ public class GetInstance {
public static Service getService(String type, String algorithm,
String provider) throws NoSuchAlgorithmException,
NoSuchProviderException {
- if ((provider == null) || (provider.length() == 0)) {
+ if (provider == null || provider.isEmpty()) {
throw new IllegalArgumentException("missing provider");
}
Provider p = Providers.getProviderList().getProvider(provider);
diff --git a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java
index 2f52c8b2ca8..ffa06f51fb5 100644
--- a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java
+++ b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java
@@ -114,7 +114,7 @@ final class ProviderConfig {
}
private boolean hasArgument() {
- return argument.length() != 0;
+ return !argument.isEmpty();
}
// should we try to load this provider?
diff --git a/src/java.base/share/classes/sun/security/jca/ProviderList.java b/src/java.base/share/classes/sun/security/jca/ProviderList.java
index 68597c891b2..5b17366d5de 100644
--- a/src/java.base/share/classes/sun/security/jca/ProviderList.java
+++ b/src/java.base/share/classes/sun/security/jca/ProviderList.java
@@ -175,7 +175,7 @@ public final class ProviderList {
while ((entry = Security.getProperty("security.provider." + i)) != null) {
entry = entry.trim();
- if (entry.length() == 0) {
+ if (entry.isEmpty()) {
System.err.println("invalid entry for " +
"security.provider." + i);
break;
@@ -200,7 +200,7 @@ public final class ProviderList {
// Load config entries for use when getInstance is called
entry = Security.getProperty("jdk.security.provider.preferred");
- if (entry != null && (entry = entry.trim()).length() > 0) {
+ if (entry != null && !(entry = entry.trim()).isEmpty()) {
String[] entries = entry.split(",");
if (ProviderList.preferredPropList == null) {
ProviderList.preferredPropList = new PreferredList();
diff --git a/src/java.base/share/classes/sun/security/provider/ConfigFile.java b/src/java.base/share/classes/sun/security/provider/ConfigFile.java
index 450a4292cff..080a44f8c89 100644
--- a/src/java.base/share/classes/sun/security/provider/ConfigFile.java
+++ b/src/java.base/share/classes/sun/security/provider/ConfigFile.java
@@ -626,7 +626,7 @@ public final class ConfigFile extends Configuration {
return url.openStream();
} catch (Exception e) {
String file = url.getPath();
- if (url.getHost().length() > 0) { // For Windows UNC
+ if (!url.getHost().isEmpty()) { // For Windows UNC
file = "//" + url.getHost() + file;
}
if (debugConfig != null) {
@@ -651,7 +651,7 @@ public final class ConfigFile extends Configuration {
return value;
}
String s = PropertyExpander.expand(value);
- if (s == null || s.length() == 0) {
+ if (s == null || s.isEmpty()) {
throw ioException(
"Configuration.Error.Line.line.system.property.value.expanded.to.empty.value",
linenum, value);
diff --git a/src/java.base/share/classes/sun/security/provider/PolicyParser.java b/src/java.base/share/classes/sun/security/provider/PolicyParser.java
index 017f667698f..3edb35a3a9f 100644
--- a/src/java.base/share/classes/sun/security/provider/PolicyParser.java
+++ b/src/java.base/share/classes/sun/security/provider/PolicyParser.java
@@ -391,9 +391,9 @@ public class PolicyParser {
out.print("keystore \"");
out.print(keyStoreUrlString);
out.print('"');
- if (keyStoreType != null && keyStoreType.length() > 0)
+ if (keyStoreType != null && !keyStoreType.isEmpty())
out.print(", \"" + keyStoreType + "\"");
- if (keyStoreProvider != null && keyStoreProvider.length() > 0)
+ if (keyStoreProvider != null && !keyStoreProvider.isEmpty())
out.print(", \"" + keyStoreProvider + "\"");
out.println(";");
out.println();
@@ -446,7 +446,7 @@ public class PolicyParser {
String alias = aliases.nextToken().trim();
if (alias.equals(","))
cctr++;
- else if (alias.length() > 0)
+ else if (!alias.isEmpty())
actr++;
}
if (actr <= cctr)
diff --git a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java
index ac3a9f86a1a..d4360724ac7 100644
--- a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java
+++ b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java
@@ -113,7 +113,7 @@ abstract class SeedGenerator {
+ "generator: " + e.toString());
}
}
- } else if (egdSource.length() != 0) {
+ } else if (!egdSource.isEmpty()) {
try {
instance = new URLSeedGenerator(egdSource);
if (debug != null) {
diff --git a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java
index c68c9c530b1..b0d82dadbf4 100644
--- a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java
+++ b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java
@@ -440,7 +440,7 @@ final class CertificateMessage {
// It is not necessary to check the certificate update if
// endpoint identification is enabled.
String identityAlg = chc.sslConfig.identificationProtocol;
- if ((identityAlg == null || identityAlg.length() == 0) &&
+ if ((identityAlg == null || identityAlg.isEmpty()) &&
!isIdentityEquivalent(x509Certs[0],
chc.reservedServerCerts[0])) {
chc.conContext.fatal(Alert.BAD_CERTIFICATE,
diff --git a/src/java.base/share/classes/sun/security/ssl/ClientHello.java b/src/java.base/share/classes/sun/security/ssl/ClientHello.java
index ba4456207b2..96bbef5db59 100644
--- a/src/java.base/share/classes/sun/security/ssl/ClientHello.java
+++ b/src/java.base/share/classes/sun/security/ssl/ClientHello.java
@@ -491,7 +491,7 @@ final class ClientHello {
// It is fine to move on with abbreviate handshake if
// endpoint identification is enabled.
String identityAlg = chc.sslConfig.identificationProtocol;
- if ((identityAlg == null || identityAlg.length() == 0)) {
+ if (identityAlg == null || identityAlg.isEmpty()) {
if (isEmsAvailable) {
if (!session.useExtendedMasterSecret) {
// perform full handshake instead
diff --git a/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java b/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java
index 2318c53200b..8bc3e95bcac 100644
--- a/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java
+++ b/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java
@@ -253,7 +253,7 @@ final class DHKeyExchange {
static {
String property = GetPropertyAction.privilegedGetProperty(
"jdk.tls.ephemeralDHKeySize");
- if (property == null || property.length() == 0) {
+ if (property == null || property.isEmpty()) {
useLegacyEphemeralDHKeys = false;
useSmartEphemeralDHKeys = false;
customizedDHKeySize = -1;
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java b/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java
index dc206d07398..f6d1e3575af 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java
@@ -237,7 +237,7 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
public boolean permits(Set
*
- * public static void main(String[] args) {
- * if (args.length != 0) {
- * System.out.println("Must specify recording file.");
- * return;
+ * public static void main(String[] args) throws IOException {
+ * if (args.length != 1) {
+ * System.err.println("Must specify a recording file.");
+ * return;
* }
- * try (RecordingFile f = new RecordingFile(Paths.get(args[0]))) {
- * Map{@literal <}String, SimpleEntry{@literal <}String, Integer{@literal >}{@literal >} histogram = new HashMap{@literal <}{@literal >}();
- * int total = 0;
- * while (f.hasMoreEvents()) {
- * RecordedEvent event = f.readEvent();
- * if (event.getEventType().getName().equals("jdk.ExecutionSample")) {
- * RecordedStackTrace s = event.getStackTrace();
- * if (s != null) {
- * RecordedFrame topFrame= s.getFrames().get(0);
- * if (topFrame.isJavaFrame()) {
- * RecordedMethod method = topFrame.getMethod();
- * String methodName = method.getType().getName() + "#" + method.getName() + " " + method.getDescriptor();
- * Entry entry = histogram.computeIfAbsent(methodName, u -{@literal >} new SimpleEntry{@literal <}String, Integer{@literal >}(methodName, 0));
- * entry.setValue(entry.getValue() + 1);
- * total++;
- * }
- * }
- * }
- * }
- * List{@literal <}SimpleEntry{@literal <}String, Integer{@literal >}{@literal >} entries = new ArrayList{@literal <}{@literal >}(histogram.values());
- * entries.sort((u, v) -{@literal >} v.getValue().compareTo(u.getValue()));
- * for (SimpleEntry{@literal <}String, Integer{@literal >} c : entries) {
- * System.out.printf("%2.0f%% %s\n", 100 * (float) c.getValue() / total, c.getKey());
- * }
- * System.out.println("\nSample count: " + total);
- * } catch (IOException ioe) {
- * System.out.println("Error reading file " + args[0] + ". " + ioe.getMessage());
- * }
- * }
+ *
+ * RecordingFile.readAllEvents(Path.of(args[0])).stream()
+ * .filter(e -> e.getEventType().getName().equals("jdk.ExecutionSample"))
+ * .map(e -> e.getStackTrace())
+ * .filter(s -> s != null)
+ * .map(s -> s.getFrames().get(0))
+ * .filter(f -> f.isJavaFrame())
+ * .map(f -> f.getMethod())
+ * .collect(
+ * Collectors.groupingBy(m -> m.getType().getName() + "." + m.getName() + " " + m.getDescriptor(),
+ * Collectors.counting()))
+ * .entrySet()
+ * .stream()
+ * .sorted((a, b) -> b.getValue().compareTo(a.getValue()))
+ * .forEach(e -> System.out.printf("%8d %s\n", e.getValue(), e.getKey()));
+ * }
*
*
*
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java
index d549bb1f96d..e9f6d2a9a60 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java
@@ -516,4 +516,11 @@ public final class JVM {
* @param emitAll emit all samples in old object queue
*/
public native void emitOldObjectSamples(long cutoff, boolean emitAll);
+
+ /**
+ * Test if a chunk rotation is warranted.
+ *
+ * @return if it is time to perform a chunk rotation
+ */
+ public native boolean shouldRotateDisk();
}
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataHandler.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataHandler.java
index c5387f04e1c..831b4444c6d 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataHandler.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataHandler.java
@@ -100,7 +100,7 @@ final class MetadataHandler extends DefaultHandler implements EntityResolver {
final Map