@@ -12,22 +12,7 @@ public class ShellCommonUtil {
1212
1313 @ SuppressWarnings ("all" )
1414 public static Object getFieldValue (Object obj , String name ) throws Exception {
15- Field field = null ;
16- Class <?> clazz = obj .getClass ();
17- while (clazz != Object .class ) {
18- try {
19- field = clazz .getDeclaredField (name );
20- break ;
21- } catch (NoSuchFieldException var5 ) {
22- clazz = clazz .getSuperclass ();
23- }
24- }
25- if (field == null ) {
26- throw new NoSuchFieldException (name );
27- } else {
28- field .setAccessible (true );
29- return field .get (obj );
30- }
15+ return "" ;
3116 }
3217
3318 public static class GetFieldValueInterceptor {
@@ -37,66 +22,43 @@ public static void exit(@Advice.Argument(value = 0) Object obj,
3722 @ Advice .Argument (value = 1 ) String name ,
3823 @ Advice .Return (readOnly = false ) Object returnValue
3924 ) throws Exception {
40- Field field = null ;
4125 Class <?> clazz = obj .getClass ();
4226 while (clazz != Object .class ) {
4327 try {
44- field = clazz .getDeclaredField (name );
45- break ;
28+ Field field = clazz .getDeclaredField (name );
29+ field .setAccessible (true );
30+ returnValue = field .get (obj );
31+ return ;
4632 } catch (NoSuchFieldException var5 ) {
4733 clazz = clazz .getSuperclass ();
4834 }
4935 }
50- if (field == null ) {
51- throw new NoSuchFieldException (name );
52- } else {
53- field .setAccessible (true );
54- returnValue = field .get (obj );
55- return ;
36+ if (returnValue == null ) {
37+ throw new NoSuchFieldException ();
5638 }
5739 }
5840 }
5941
6042
6143 @ SuppressWarnings ("all" )
62- public static String base64DecodeToString (String bs ) {
63- byte [] value = null ;
64- Class <?> base64 ;
65- try {
66- base64 = Class .forName ("java.util.Base64" );
67- Object decoder = base64 .getMethod ("getDecoder" , (Class <?>[]) null ).invoke (base64 , (Object []) null );
68- value = (byte []) decoder .getClass ().getMethod ("decode" , String .class ).invoke (decoder , bs );
69- } catch (Exception var6 ) {
70- try {
71- base64 = Class .forName ("sun.misc.BASE64Decoder" );
72- Object decoder = base64 .newInstance ();
73- value = (byte []) decoder .getClass ().getMethod ("decodeBuffer" , String .class ).invoke (decoder , bs );
74- } catch (Exception ignored ) {
75- }
76- }
77- return value == null ? null : new String (value );
44+ public static String base64DecodeToString (String bs ) throws Exception {
45+ return "" ;
7846 }
7947
8048 public static class Base64DecodeToStringInterceptor {
8149
8250 @ Advice .OnMethodExit
8351 @ SuppressWarnings ("all" )
84- public static void exit (@ Advice .Argument (value = 0 , readOnly = false ) String bs , @ Advice .Return (readOnly = false ) String returnValue ) {
85- byte [] value = null ;
86- Class <?> base64 ;
87- try {
88- base64 = Class .forName ("java.util.Base64" );
89- Object decoder = base64 .getMethod ("getDecoder" , (Class <?>[]) null ).invoke (base64 , (Object []) null );
90- value = (byte []) decoder .getClass ().getMethod ("decode" , String .class ).invoke (decoder , bs );
91- } catch (Exception var6 ) {
52+ public static void exit (@ Advice .Argument (value = 0 , readOnly = false ) String bs , @ Advice .Return (readOnly = false ) String returnValue ) throws Exception {
53+ if (bs != null ) {
9254 try {
93- base64 = Class .forName ("sun.misc.BASE64Decoder" );
94- Object decoder = base64 .newInstance ();
95- value = (byte []) decoder .getClass ().getMethod ("decodeBuffer" , String .class ).invoke (decoder , bs );
96- } catch (Exception ignored ) {
55+ Object decoder = Class .forName ("java.util.Base64" ).getMethod ("getDecoder" ).invoke (null );
56+ returnValue = new String ((byte []) decoder .getClass ().getMethod ("decode" , String .class ).invoke (decoder , bs ));
57+ } catch (Exception var6 ) {
58+ Object decoder = Class .forName ("sun.misc.BASE64Decoder" ).newInstance ();
59+ returnValue = new String ((byte []) decoder .getClass ().getMethod ("decodeBuffer" , String .class ).invoke (decoder , bs ));
9760 }
9861 }
99- returnValue = value == null ? null : new String (value );
10062 }
10163 }
10264}
0 commit comments