private IClassHierarchy getHierarchy(FieldReference ref) { return getHierarchy(ref.getDeclaringClass()); }
private IClassHierarchy getHierarchy(FieldReference ref) { return getHierarchy(ref.getDeclaringClass()); }
@Override public final String toString() { return "< " + getDeclaringClass().getClassLoader().getName() + ", " + getDeclaringClass().getName() + ", " + getName() + ", " + fieldType + " >"; }
/** * @return the canonical IField that represents a given field , or null if none found * @throws IllegalArgumentException if f is null */ @Override public IField resolveField(FieldReference f) { if (f == null) { throw new IllegalArgumentException("f is null"); } IClass klass = lookupClass(f.getDeclaringClass()); if (klass == null) { return null; } return resolveField(klass, f); }
/** * @return the canonical IField that represents a given field , or null if none found * @throws IllegalArgumentException if f is null */ @Override public IField resolveField(FieldReference f) { if (f == null) { throw new IllegalArgumentException("f is null"); } IClass klass = lookupClass(f.getDeclaringClass()); if (klass == null) { return null; } return resolveField(klass, f); }
@Override public final String toString() { return "< " + getDeclaringClass().getClassLoader().getName() + ", " + getDeclaringClass().getName() + ", " + getName() + ", " + fieldType + " >"; }
/** * Is s is a getstatic or putstatic, then potentially add the relevant <clinit> to the newMethod set. */ private void processFieldAccess(FieldReference f) { if (DEBUG) { System.err.println(("processFieldAccess: " + f)); } TypeReference t = f.getDeclaringClass(); IClass klass = getClassHierarchy().lookupClass(t); if (klass == null) { } else { processClassInitializer(klass); } }
/** * Is s is a getstatic or putstatic, then potentially add the relevant <clinit> to the newMethod set. */ private void processFieldAccess(FieldReference f) { if (DEBUG) { System.err.println(("processFieldAccess: " + f)); } TypeReference t = f.getDeclaringClass(); IClass klass = getClassHierarchy().lookupClass(t); if (klass == null) { } else { processClassInitializer(klass); } }
@Override public int addGetInstance(FieldReference ref, int object) { TypeReference type = ref.getDeclaringClass(); Atom language = type.getClassLoader().getLanguage(); AbstractRootMethod root = getLanguageRoot(language); return root.addGetInstance(ref, object); }
@Override public int addGetStatic(FieldReference ref) { TypeReference type = ref.getDeclaringClass(); Atom language = type.getClassLoader().getLanguage(); AbstractRootMethod root = getLanguageRoot(language); return root.addGetStatic(ref); }
@Override public int addGetInstance(FieldReference ref, int object) { TypeReference type = ref.getDeclaringClass(); Atom language = type.getClassLoader().getLanguage(); AbstractRootMethod root = getLanguageRoot(language); return root.addGetInstance(ref, object); }
@Override public int addGetStatic(FieldReference ref) { TypeReference type = ref.getDeclaringClass(); Atom language = type.getClassLoader().getLanguage(); AbstractRootMethod root = getLanguageRoot(language); return root.addGetStatic(ref); }
@Override public String getSignature() { return getDeclaringClass().getName() + "." + getName() + ' ' + getFieldType().getName(); }
@Override public String getSignature() { return getDeclaringClass().getName() + "." + getName() + ' ' + getFieldType().getName(); }
TypeReference fieldType = instruction.getDeclaredFieldType(); TypeReference classType = instruction.getDeclaredField() .getDeclaringClass();
@Override public IntSet getTargets(int d1) { System.out.println(ebb.toString()); System.out.println(d1); // first, gen this statement int factNum = domain.getMappedIndex(cha.lookupClass(putInstr.getDeclaredField().getDeclaringClass())); System.out.println(factNum); assert factNum != -1; MutableSparseIntSet result = MutableSparseIntSet.makeEmpty(); result.add(factNum); // if incoming statement is some different statement that defs the same static field, kill it; otherwise, keep it if (d1 != factNum) { result.add(d1); } return result; }
protected void processPutStatic(int rval, FieldReference field, IField f) { PointerKey fKey = getPointerKeyForStaticField(f); PointerKey rvalKey = getPointerKeyForLocal(rval); // if (!supportFullPointerFlowGraph && // contentsAreInvariant(rval)) { if (contentsAreInvariant(symbolTable, du, rval)) { system.recordImplicitPointsToSet(rvalKey); InstanceKey[] ik = getInvariantContents(rval); for (InstanceKey element : ik) { system.newConstraint(fKey, element); } } else { system.newConstraint(fKey, assignOperator, rvalKey); } if (DEBUG) { System.err.println("visitPut class init " + field.getDeclaringClass() + ' ' + field); } // side effect of putstatic: may call class initializer IClass klass = getClassHierarchy().lookupClass(field.getDeclaringClass()); if (klass == null) { Warnings.add(FieldResolutionFailure.create(field)); } else { processClassInitializer(klass); } }
protected void processPutStatic(int rval, FieldReference field, IField f) { PointerKey fKey = getPointerKeyForStaticField(f); PointerKey rvalKey = getPointerKeyForLocal(rval); // if (!supportFullPointerFlowGraph && // contentsAreInvariant(rval)) { if (contentsAreInvariant(symbolTable, du, rval)) { system.recordImplicitPointsToSet(rvalKey); InstanceKey[] ik = getInvariantContents(rval); for (InstanceKey element : ik) { system.newConstraint(fKey, element); } } else { system.newConstraint(fKey, assignOperator, rvalKey); } if (DEBUG) { System.err.println("visitPut class init " + field.getDeclaringClass() + ' ' + field); } // side effect of putstatic: may call class initializer IClass klass = getClassHierarchy().lookupClass(field.getDeclaringClass()); if (klass == null) { Warnings.add(FieldResolutionFailure.create(field)); } else { processClassInitializer(klass); } }
@Override public IntSet getTargets(int d1) { // first, gen this statement int factNum = domain.getMappedIndex(cha.lookupClass(getInstr.getDeclaredField().getDeclaringClass())); assert factNum != -1; MutableSparseIntSet result = MutableSparseIntSet.makeEmpty(); result.add(factNum); // if incoming statement is some different statement that defs the same static field, kill it; otherwise, keep it if (d1 != factNum) { result.add(d1); } return result; }
@Test public void testQualifiedStatic() throws IllegalArgumentException, CancelException, IOException { runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), Collections.singletonList( cg -> { MethodReference mref = descriptorToMethodRef("Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy()); CGNode node = cg.getNodes(mref).iterator().next(); SSAInstruction s = node.getIR().getInstructions()[4]; Assert.assertTrue("Did not find a getstatic instruction.", s instanceof SSAGetInstruction && ((SSAGetInstruction) s).isStatic()); final FieldReference field = ((SSAGetInstruction) s).getDeclaredField(); Assert.assertEquals("Expected a getstatic for 'value'.", field.getName().toString(), "value"); Assert.assertEquals("Expected a getstatic for 'value'.", field.getDeclaringClass().getName().toString(), "LFooQ"); }), true, null); }