src/java.base/share/classes/sun/security/util/BitArray.java
changeset 59141 bd436284147d
parent 47216 71c04702a3d5
--- a/src/java.base/share/classes/sun/security/util/BitArray.java	Tue Nov 19 23:22:27 2019 +0100
+++ b/src/java.base/share/classes/sun/security/util/BitArray.java	Wed Nov 20 08:12:14 2019 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, 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
@@ -241,6 +241,10 @@
      *  Returns a string representation of this BitArray.
      */
     public String toString() {
+        if (length == 0) {
+            return "";
+        }
+
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
         for (int i = 0; i < repn.length - 1; i++) {