@@ -61,22 +61,24 @@ public boolean equals(Object obj) {
61
61
62
62
@ SuppressWarnings ("all" )
63
63
public static String base64Encode (byte [] bs ) throws Exception {
64
+ ClassLoader loader = Thread .currentThread ().getContextClassLoader ();
64
65
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 );
66
67
return (String ) encoder .getClass ().getMethod ("encodeToString" , byte [].class ).invoke (encoder , bs );
67
68
} catch (Exception var6 ) {
68
- Object encoder = Class .forName ("sun.misc.BASE64Encoder" ).newInstance ();
69
+ Object encoder = Class .forName ("sun.misc.BASE64Encoder" , false , loader ).newInstance ();
69
70
return (String ) encoder .getClass ().getMethod ("encode" , byte [].class ).invoke (encoder , bs );
70
71
}
71
72
}
72
73
73
74
@ SuppressWarnings ("all" )
74
75
public static byte [] base64Decode (String bs ) throws Exception {
76
+ ClassLoader loader = Thread .currentThread ().getContextClassLoader ();
75
77
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 );
77
79
return (byte []) decoder .getClass ().getMethod ("decode" , String .class ).invoke (decoder , bs );
78
80
} catch (Exception var6 ) {
79
- Object decoder = Class .forName ("sun.misc.BASE64Decoder" ).newInstance ();
81
+ Object decoder = Class .forName ("sun.misc.BASE64Decoder" , false , loader ).newInstance ();
80
82
return (byte []) decoder .getClass ().getMethod ("decodeBuffer" , String .class ).invoke (decoder , bs );
81
83
}
82
84
}
0 commit comments