Converts a CSObj of class to corresponding JClass. If the object is not a class constant, then return null.
(CSObj csObj)
| 73 | * not a class constant, then return null. |
| 74 | */ |
| 75 | @Nullable |
| 76 | public static JClass toClass(CSObj csObj) { |
| 77 | Object alloc = csObj.getObject().getAllocation(); |
| 78 | if (alloc instanceof ClassLiteral cls) { |
| 79 | Type type = cls.getTypeValue(); |
| 80 | if (type instanceof ClassType clsType) { |
| 81 | return clsType.getJClass(); |
| 82 | } else if (type instanceof ArrayType) { |
| 83 | return World.get().getClassHierarchy() |
| 84 | .getJREClass(ClassNames.OBJECT); |
| 85 | } |
| 86 | } |
| 87 | return null; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Converts a CSObj of java.lang.reflect.Constructor to corresponding JMethod. |
no test coverage detected