@@ -61,22 +61,24 @@ public boolean equals(Object obj) {
6161
6262 @ SuppressWarnings ("all" )
6363 public static String base64Encode (byte [] bs ) throws Exception {
64+ ClassLoader loader = Thread .currentThread ().getContextClassLoader ();
6465 try {
65- Object encoder = Class .forName ("java.util.Base64" ).getMethod ("getEncoder" ).invoke (null );
66+ Object encoder = Class .forName ("java.util.Base64" , false , loader ).getMethod ("getEncoder" ).invoke (null );
6667 return (String ) encoder .getClass ().getMethod ("encodeToString" , byte [].class ).invoke (encoder , bs );
6768 } catch (Exception var6 ) {
68- Object encoder = Class .forName ("sun.misc.BASE64Encoder" ).newInstance ();
69+ Object encoder = Class .forName ("sun.misc.BASE64Encoder" , false , loader ).newInstance ();
6970 return (String ) encoder .getClass ().getMethod ("encode" , byte [].class ).invoke (encoder , bs );
7071 }
7172 }
7273
7374 @ SuppressWarnings ("all" )
7475 public static byte [] base64Decode (String bs ) throws Exception {
76+ ClassLoader loader = Thread .currentThread ().getContextClassLoader ();
7577 try {
76- Object decoder = Class .forName ("java.util.Base64" ).getMethod ("getDecoder" ).invoke (null );
78+ Object decoder = Class .forName ("java.util.Base64" , false , loader ).getMethod ("getDecoder" ).invoke (null );
7779 return (byte []) decoder .getClass ().getMethod ("decode" , String .class ).invoke (decoder , bs );
7880 } catch (Exception var6 ) {
79- Object decoder = Class .forName ("sun.misc.BASE64Decoder" ).newInstance ();
81+ Object decoder = Class .forName ("sun.misc.BASE64Decoder" , false , loader ).newInstance ();
8082 return (byte []) decoder .getClass ().getMethod ("decodeBuffer" , String .class ).invoke (decoder , bs );
8183 }
8284 }
0 commit comments