diff options
author | Sergio Giro <sgiro@google.com> | 2016-04-11 20:44:38 +0100 |
---|---|---|
committer | Sergio Giro <sgiro@google.com> | 2016-04-11 20:44:38 +0100 |
commit | 7ddf37c01b68ff9d2de3a9dcb637d2b962b442ef (patch) | |
tree | 113cbdff122439ccd8a2a7b40ce0a687e8a104c9 | |
parent | 5a092cffe8570971b6ffc00312446debed5b66c5 (diff) | |
download | bouncycastle-7ddf37c01b68ff9d2de3a9dcb637d2b962b442ef.tar.gz |
Strings: hardcode "\n" as the line separator
For android, it's already hardcoded in System.java
It was trying to use
System.getProperty("line.separator");
causing the class not to be compile-time initializable, causing
performance problems, see bug.
Bug: 28108158
Change-Id: I2a2549ce477d94e95e8239d97307eaaf50c05d6b
-rw-r--r-- | bcprov/src/main/java/org/bouncycastle/util/Strings.java | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/util/Strings.java b/bcprov/src/main/java/org/bouncycastle/util/Strings.java index a42830b3..a9bbc9fc 100644 --- a/bcprov/src/main/java/org/bouncycastle/util/Strings.java +++ b/bcprov/src/main/java/org/bouncycastle/util/Strings.java @@ -13,35 +13,42 @@ import java.util.Vector; */ public final class Strings { - private static String LINE_SEPARATOR; - - static - { - try - { - LINE_SEPARATOR = AccessController.doPrivileged(new PrivilegedAction<String>() - { - public String run() - { - // the easy way - return System.getProperty("line.separator"); - } - }); - - } - catch (Exception e) - { - try - { - // the harder way - LINE_SEPARATOR = String.format("%n"); - } - catch (Exception ef) - { - LINE_SEPARATOR = "\n"; // we're desperate use this... - } - } - } + // BEGIN android-changed + // Was: private static String LINE_SEPARATOR; + // It was using the static block below to initialize, calling System.getProperty, which caused + // BouncyCastleProvider not to be compile-time initializable, thus causing performance problems + // (see b/28108158 ). Anyway, this is already hardcoded in System.java + private static String LINE_SEPARATOR = "\n"; + // END android-changed + // BEGIN android-removed + // static + // { + // try + // { + // LINE_SEPARATOR = AccessController.doPrivileged(new PrivilegedAction<String>() + // { + // public String run() + // { + // // the easy way + // return System.getProperty("line.separator"); + // } + // }); + + // } + // catch (Exception e) + // { + // try + // { + // // the harder way + // LINE_SEPARATOR = String.format("%n"); + // } + // catch (Exception ef) + // { + // LINE_SEPARATOR = "\n"; // we're desperate use this... + // } + // } + // } + // END android-removed public static String fromUTF8ByteArray(byte[] bytes) { |