■ ■ ■ ■ ■ ■
jadx-core/src/main/java/jadx/core/dex/instructions/args/ArgType.java
| skipped 11 lines |
12 | 12 | | |
13 | 13 | | import jadx.core.Consts; |
14 | 14 | | import jadx.core.dex.info.ClassInfo; |
15 | | - | import jadx.core.dex.nodes.ClassNode; |
16 | 15 | | import jadx.core.dex.nodes.RootNode; |
17 | 16 | | import jadx.core.dex.visitors.typeinference.TypeCompareEnum; |
| 17 | + | import jadx.core.utils.ListUtils; |
18 | 18 | | import jadx.core.utils.Utils; |
19 | 19 | | import jadx.core.utils.exceptions.JadxRuntimeException; |
20 | 20 | | |
| skipped 853 lines |
874 | 874 | | } |
875 | 875 | | |
876 | 876 | | public static ArgType tryToResolveClassAlias(RootNode root, ArgType type) { |
877 | | - | if (!type.isObject() || type.isGenericType()) { |
| 877 | + | if (type.isGenericType()) { |
878 | 878 | | return type; |
879 | 879 | | } |
880 | | - | |
881 | | - | ClassNode cls = root.resolveClass(type); |
882 | | - | if (cls == null) { |
883 | | - | return type; |
| 880 | + | if (type.isArray()) { |
| 881 | + | ArgType rootType = type.getArrayRootElement(); |
| 882 | + | ArgType aliasType = tryToResolveClassAlias(root, rootType); |
| 883 | + | if (aliasType == rootType) { |
| 884 | + | return type; |
| 885 | + | } |
| 886 | + | return ArgType.array(aliasType, type.getArrayDimension()); |
884 | 887 | | } |
885 | | - | ClassInfo clsInfo = cls.getClassInfo(); |
886 | | - | if (!clsInfo.hasAlias()) { |
887 | | - | return type; |
888 | | - | } |
889 | | - | String aliasFullName = clsInfo.getAliasFullName(); |
890 | | - | if (type.isGeneric()) { |
891 | | - | if (type instanceof GenericObject) { |
892 | | - | return new GenericObject(aliasFullName, type.getGenericTypes()); |
| 888 | + | if (type.isObject()) { |
| 889 | + | ArgType wildcardType = type.getWildcardType(); |
| 890 | + | if (wildcardType != null) { |
| 891 | + | return new WildcardType(tryToResolveClassAlias(root, wildcardType), type.getWildcardBound()); |
| 892 | + | } |
| 893 | + | ClassInfo clsInfo = ClassInfo.fromName(root, type.getObject()); |
| 894 | + | ArgType baseType = clsInfo.hasAlias() ? ArgType.object(clsInfo.getAliasFullName()) : type; |
| 895 | + | if (!type.isGeneric()) { |
| 896 | + | return baseType; |
893 | 897 | | } |
894 | | - | if (type instanceof WildcardType) { |
895 | | - | return new WildcardType(ArgType.object(aliasFullName), type.getWildcardBound()); |
| 898 | + | List<ArgType> genericTypes = type.getGenericTypes(); |
| 899 | + | if (genericTypes != null) { |
| 900 | + | return new GenericObject(baseType.getObject(), tryToResolveClassAlias(root, genericTypes)); |
896 | 901 | | } |
897 | 902 | | } |
898 | | - | return ArgType.object(aliasFullName); |
| 903 | + | return type; |
| 904 | + | } |
| 905 | + | |
| 906 | + | public static List<ArgType> tryToResolveClassAlias(RootNode root, List<ArgType> types) { |
| 907 | + | return ListUtils.map(types, t -> tryToResolveClassAlias(root, t)); |
899 | 908 | | } |
900 | 909 | | |
901 | 910 | | @Override |
| skipped 29 lines |