private static boolean isConstructorConstant(InstanceKey instance) { if (instance instanceof ConstantKey) { ConstantKey c = (ConstantKey) instance; if (c.getConcreteType().getReference().equals(TypeReference.JavaLangReflectConstructor)) { return true; } } return false; }
private static boolean isConstructorConstant(InstanceKey instance) { if (instance instanceof ConstantKey) { ConstantKey c = (ConstantKey) instance; if (c.getConcreteType().getReference().equals(TypeReference.JavaLangReflectConstructor)) { return true; } } return false; }
@Override public IClass getConcreteType() { return constant.getConcreteType().getClassHierarchy().lookupClass(TypeReference.CharArray); }
@Override public IClass getConcreteType() { return constant.getConcreteType().getClassHierarchy().lookupClass(TypeReference.CharArray); }
@Override public ContextItem get(ContextKey name) { if (name == ContextKey.RECEIVER) { return type; } else if (name == ContextKey.NAME) { return new NameItem(); } else if (name == ContextKey.PARAMETERS[0]) { if (type instanceof PointType) { IClass cls = ((PointType) type).getIClass(); return new FilteredPointerKey.SingleClassFilter(cls); } else { return null; } } else if (name == ContextKey.PARAMETERS[1]) { return new FilteredPointerKey.SingleClassFilter(this.name.getConcreteType()); } else { return null; } }
@Override public ContextItem get(ContextKey name) { if (name == ContextKey.RECEIVER) { return type; } else if (name == ContextKey.NAME) { return new NameItem(); } else if (name == ContextKey.PARAMETERS[0]) { if (type instanceof PointType) { IClass cls = ((PointType) type).getIClass(); return new FilteredPointerKey.SingleClassFilter(cls); } else { return null; } } else if (name == ContextKey.PARAMETERS[1]) { return new FilteredPointerKey.SingleClassFilter(this.name.getConcreteType()); } else { return null; } }
@Override public Context getCalleeTarget(CGNode caller, CallSiteReference site, IMethod callee, InstanceKey[] actualParameters) { Context baseContext = base.getCalleeTarget(caller, site, callee, actualParameters); if ((isInvoke(callee) || isType(callee)) && callee.getReference().getDeclaringClass().getName().equals(TypeReference.JavaLangInvokeMethodHandle.getName())) { if (actualParameters != null && actualParameters.length > 0) { InstanceKey selfKey = actualParameters[0]; if (selfKey instanceof ConstantKey && ((ConstantKey)selfKey).getConcreteType().getReference().equals(TypeReference.JavaLangInvokeMethodHandle)) { MethodReference ref = ((IMethod) ((ConstantKey)selfKey).getValue()).getReference(); return new MethodContext(baseContext, ref); } } } if (isFindStatic(callee) && callee.getDeclaringClass().getReference().equals(TypeReference.JavaLangInvokeMethodHandlesLookup)) { if (actualParameters != null && actualParameters.length > 2) { InstanceKey classKey = actualParameters[1]; InstanceKey nameKey = actualParameters[2]; if (classKey instanceof ConstantKey && ((ConstantKey)classKey).getConcreteType().getReference().equals(TypeReference.JavaLangClass) && nameKey instanceof ConstantKey && ((ConstantKey)nameKey).getConcreteType().getReference().equals(TypeReference.JavaLangString)) { return new FindContext(baseContext, ((IClass)((ConstantKey)classKey).getValue()).getReference(), (String)((ConstantKey)nameKey).getValue()); } } } return baseContext; }
@Override public Context getCalleeTarget(CGNode caller, CallSiteReference site, IMethod callee, InstanceKey[] actualParameters) { Context baseContext = base.getCalleeTarget(caller, site, callee, actualParameters); if ((isInvoke(callee) || isType(callee)) && callee.getReference().getDeclaringClass().getName().equals(TypeReference.JavaLangInvokeMethodHandle.getName())) { if (actualParameters != null && actualParameters.length > 0) { InstanceKey selfKey = actualParameters[0]; if (selfKey instanceof ConstantKey && ((ConstantKey)selfKey).getConcreteType().getReference().equals(TypeReference.JavaLangInvokeMethodHandle)) { MethodReference ref = ((IMethod) ((ConstantKey)selfKey).getValue()).getReference(); return new MethodContext(baseContext, ref); } } } if (isFindStatic(callee) && callee.getDeclaringClass().getReference().equals(TypeReference.JavaLangInvokeMethodHandlesLookup)) { if (actualParameters != null && actualParameters.length > 2) { InstanceKey classKey = actualParameters[1]; InstanceKey nameKey = actualParameters[2]; if (classKey instanceof ConstantKey && ((ConstantKey)classKey).getConcreteType().getReference().equals(TypeReference.JavaLangClass) && nameKey instanceof ConstantKey && ((ConstantKey)nameKey).getConcreteType().getReference().equals(TypeReference.JavaLangString)) { return new FindContext(baseContext, ((IClass)((ConstantKey)classKey).getValue()).getReference(), (String)((ConstantKey)nameKey).getValue()); } } } return baseContext; }
@Override @SuppressWarnings("unchecked") public OrdinalSet<InstanceKey> getPointsToSet(PointerKey key) { if (pointsToMap.isImplicit(key)) { return computeImplicitPointsToSet(key); } // special logic to handle contents of char[] from string constants. if (key instanceof InstanceFieldKey) { InstanceFieldKey ifk = (InstanceFieldKey) key; if (ifk.getInstanceKey() instanceof ConstantKey) { ConstantKey<?> i = (ConstantKey<?>) ifk.getInstanceKey(); if (i.getValue() instanceof String && i.getConcreteType().getClassLoader().getLanguage().equals(Language.JAVA)) { StringConstantCharArray contents = StringConstantCharArray.make((ConstantKey<String>) i); instanceKeys.add(contents); Collection<InstanceKey> singleton = HashSetFactory.make(); singleton.add(contents); return OrdinalSet.toOrdinalSet(singleton, instanceKeys); } } } PointsToSetVariable v = pointsToMap.getPointsToSet(key); if (v == null) { return OrdinalSet.empty(); } else { IntSet S = v.getValue(); return new OrdinalSet<>(S, instanceKeys); } }
@Override @SuppressWarnings("unchecked") public OrdinalSet<InstanceKey> getPointsToSet(PointerKey key) { if (pointsToMap.isImplicit(key)) { return computeImplicitPointsToSet(key); } // special logic to handle contents of char[] from string constants. if (key instanceof InstanceFieldKey) { InstanceFieldKey ifk = (InstanceFieldKey) key; if (ifk.getInstanceKey() instanceof ConstantKey) { ConstantKey<?> i = (ConstantKey<?>) ifk.getInstanceKey(); if (i.getValue() instanceof String && i.getConcreteType().getClassLoader().getLanguage().equals(Language.JAVA)) { StringConstantCharArray contents = StringConstantCharArray.make((ConstantKey<String>) i); instanceKeys.add(contents); Collection<InstanceKey> singleton = HashSetFactory.make(); singleton.add(contents); return OrdinalSet.toOrdinalSet(singleton, instanceKeys); } } } PointsToSetVariable v = pointsToMap.getPointsToSet(key); if (v == null) { return OrdinalSet.empty(); } else { IntSet S = v.getValue(); return new OrdinalSet<>(S, instanceKeys); } }
if (receiver[nameVn] instanceof ConstantKey) { ConstantKey ik = (ConstantKey) receiver[nameVn]; if (ik.getConcreteType().getReference().equals(TypeReference.JavaLangString)) { String className = StringStuff.deployment2CanonicalTypeString(ik.getValue().toString()); for(IClassLoader cl : caller.getClassHierarchy().getLoaders()) {
if (receiver[nameVn] instanceof ConstantKey) { ConstantKey ik = (ConstantKey) receiver[nameVn]; if (ik.getConcreteType().getReference().equals(TypeReference.JavaLangString)) { String className = StringStuff.deployment2CanonicalTypeString(ik.getValue().toString()); for(IClassLoader cl : caller.getClassHierarchy().getLoaders()) {