MCPcopy Create free account
hub / github.com/LFYSec/MScan / toClass

Method toClass

src/main/java/pascal/taie/analysis/pta/plugin/util/CSObjs.java:75–88  ·  view source on GitHub ↗

Converts a CSObj of class to corresponding JClass. If the object is not a class constant, then return null.

(CSObj csObj)

Source from the content-addressed store, hash-verified

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.

Callers 9

findConstructorMethod · 0.95
findMethodMethod · 0.95
classGetConstructorMethod · 0.95
classGetMethodMethod · 0.95
classGetMethodsMethod · 0.95
getAnnotationMethod · 0.95
classGetConstructorMethod · 0.95
classGetMethodMethod · 0.95
classNewInstanceMethod · 0.95

Calls 7

getMethod · 0.95
getTypeValueMethod · 0.80
getJClassMethod · 0.80
getClassHierarchyMethod · 0.80
getObjectMethod · 0.65
getJREClassMethod · 0.65
getAllocationMethod · 0.45

Tested by

no test coverage detected