/QingTingFanBianYi/src/com/alibaba/fastjson/util/ASMUtils.java

https://gitlab.com/qt-prometheus/qt-prometheus · Java · 129 lines · 114 code · 11 blank · 4 comment · 20 complexity · 855f58b7d1708370991b45f1a3c09f8c MD5 · raw file

  1. package com.alibaba.fastjson.util;
  2. import com.alibaba.fastjson.parser.DefaultJSONParser;
  3. import com.alibaba.fastjson.parser.JSONLexer;
  4. import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
  5. import java.lang.reflect.Field;
  6. import java.lang.reflect.Method;
  7. import java.lang.reflect.Type;
  8. import java.util.Collection;
  9. public class ASMUtils
  10. {
  11. public static String getDesc(Class<?> paramClass)
  12. {
  13. if (paramClass.isPrimitive())
  14. return getPrimitiveLetter(paramClass);
  15. if (paramClass.isArray())
  16. return "[" + getDesc(paramClass.getComponentType());
  17. return "L" + getType(paramClass) + ";";
  18. }
  19. public static String getDesc(Method paramMethod)
  20. {
  21. StringBuffer localStringBuffer = new StringBuffer();
  22. localStringBuffer.append("(");
  23. Class[] arrayOfClass = paramMethod.getParameterTypes();
  24. int i = 0;
  25. while (i < arrayOfClass.length)
  26. {
  27. localStringBuffer.append(getDesc(arrayOfClass[i]));
  28. i += 1;
  29. }
  30. localStringBuffer.append(")");
  31. localStringBuffer.append(getDesc(paramMethod.getReturnType()));
  32. return localStringBuffer.toString();
  33. }
  34. public static Type getFieldType(Class<?> paramClass, String paramString)
  35. {
  36. try
  37. {
  38. paramClass = paramClass.getField(paramString).getGenericType();
  39. return paramClass;
  40. }
  41. catch (Exception paramClass)
  42. {
  43. }
  44. return null;
  45. }
  46. public static Type getMethodType(Class<?> paramClass, String paramString)
  47. {
  48. try
  49. {
  50. paramClass = paramClass.getMethod(paramString, new Class[0]).getGenericReturnType();
  51. return paramClass;
  52. }
  53. catch (Exception paramClass)
  54. {
  55. }
  56. return null;
  57. }
  58. public static String getPrimitiveLetter(Class<?> paramClass)
  59. {
  60. if (Integer.TYPE.equals(paramClass))
  61. return "I";
  62. if (Void.TYPE.equals(paramClass))
  63. return "V";
  64. if (Boolean.TYPE.equals(paramClass))
  65. return "Z";
  66. if (Character.TYPE.equals(paramClass))
  67. return "C";
  68. if (Byte.TYPE.equals(paramClass))
  69. return "B";
  70. if (Short.TYPE.equals(paramClass))
  71. return "S";
  72. if (Float.TYPE.equals(paramClass))
  73. return "F";
  74. if (Long.TYPE.equals(paramClass))
  75. return "J";
  76. if (Double.TYPE.equals(paramClass))
  77. return "D";
  78. throw new IllegalStateException("Type: " + paramClass.getCanonicalName() + " is not a primitive type");
  79. }
  80. public static String getType(Class<?> paramClass)
  81. {
  82. if (paramClass.isArray())
  83. return "[" + getDesc(paramClass.getComponentType());
  84. if (!paramClass.isPrimitive())
  85. return paramClass.getName().replaceAll("\\.", "/");
  86. return getPrimitiveLetter(paramClass);
  87. }
  88. public static boolean isAndroid()
  89. {
  90. return isAndroid(System.getProperty("java.vm.name"));
  91. }
  92. public static boolean isAndroid(String paramString)
  93. {
  94. paramString = paramString.toLowerCase();
  95. return (paramString.contains("dalvik")) || (paramString.contains("lemur"));
  96. }
  97. public static void parseArray(Collection paramCollection, ObjectDeserializer paramObjectDeserializer, DefaultJSONParser paramDefaultJSONParser, Type paramType, Object paramObject)
  98. {
  99. paramObject = paramDefaultJSONParser.getLexer();
  100. if (paramObject.token() == 8)
  101. paramObject.nextToken(16);
  102. paramDefaultJSONParser.accept(14, 14);
  103. int i = 0;
  104. while (true)
  105. {
  106. paramCollection.add(paramObjectDeserializer.deserialze(paramDefaultJSONParser, paramType, Integer.valueOf(i)));
  107. i += 1;
  108. if (paramObject.token() != 16)
  109. break;
  110. paramObject.nextToken(14);
  111. }
  112. paramDefaultJSONParser.accept(15, 16);
  113. }
  114. }
  115. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  116. * Qualified Name: com.alibaba.fastjson.util.ASMUtils
  117. * JD-Core Version: 0.6.2
  118. */