Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Achim D. Brucker 2017-02-26 15:05:40 +00:00
commit d32aff7e9a
13 changed files with 101 additions and 32 deletions

View File

@ -65,6 +65,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.shrikeCT.AnnotationsReader.ConstantElementValue; import com.ibm.wala.shrikeCT.AnnotationsReader.ConstantElementValue;
import com.ibm.wala.shrikeCT.AnnotationsReader.ElementValue; import com.ibm.wala.shrikeCT.AnnotationsReader.ElementValue;
import com.ibm.wala.shrikeCT.ClassConstants; import com.ibm.wala.shrikeCT.ClassConstants;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAThrowInstruction; import com.ibm.wala.ssa.SSAThrowInstruction;
import com.ibm.wala.ssa.SymbolTable; import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.types.ClassLoaderReference;
@ -170,7 +171,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
} }
private void addMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock, private void addMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
declaredMethods.put(Util.methodEntityToSelector(methodEntity), new ConcreteJavaMethod(methodEntity, owner, cfg, symtab, declaredMethods.put(Util.methodEntityToSelector(methodEntity), new ConcreteJavaMethod(methodEntity, owner, cfg, symtab,
hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo)); hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo));
} }
@ -251,7 +252,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
private final TypeReference[] exceptionTypes; private final TypeReference[] exceptionTypes;
public JavaEntityMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock, public JavaEntityMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
super(owner, methodEntity.getQualifiers(), cfg, symtab, MethodReference.findOrCreate(owner.getReference(), Util super(owner, methodEntity.getQualifiers(), cfg, symtab, MethodReference.findOrCreate(owner.getReference(), Util
.methodEntityToSelector(methodEntity)), hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo, JavaSourceLoaderImpl.this.getAnnotations(methodEntity)); .methodEntityToSelector(methodEntity)), hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo, JavaSourceLoaderImpl.this.getAnnotations(methodEntity));
this.parameterTypes = computeParameterTypes(methodEntity); this.parameterTypes = computeParameterTypes(methodEntity);
@ -369,7 +370,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
*/ */
public class ConcreteJavaMethod extends JavaEntityMethod { public class ConcreteJavaMethod extends JavaEntityMethod {
public ConcreteJavaMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock, public ConcreteJavaMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
super(methodEntity, owner, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo); super(methodEntity, owner, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo);
} }
@ -522,7 +523,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
} }
public void defineFunction(CAstEntity n, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock, public void defineFunction(CAstEntity n, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
((JavaClass) owner).addMethod(n, owner, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo); ((JavaClass) owner).addMethod(n, owner, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo);
} }

View File

@ -37,6 +37,7 @@ import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.ModuleEntry; import com.ibm.wala.classLoader.ModuleEntry;
import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SymbolTable; import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.FieldReference; import com.ibm.wala.types.FieldReference;
import com.ibm.wala.types.TypeName; import com.ibm.wala.types.TypeName;
@ -244,8 +245,8 @@ public class JavaCAst2IRTranslator extends AstTranslator {
} }
@Override @Override
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab, protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
DebuggingInformation debugInfo) { DebuggingInformation debugInfo) {
// N.B.: base class may actually ask to create a synthetic type to wrap // N.B.: base class may actually ask to create a synthetic type to wrap
// code bodies, so we may see other things than TYPE_ENTITY here. // code bodies, so we may see other things than TYPE_ENTITY here.

View File

@ -46,6 +46,7 @@ import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ssa.DefUse; import com.ibm.wala.ssa.DefUse;
import com.ibm.wala.ssa.IR; import com.ibm.wala.ssa.IR;
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction; import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAOptions; import com.ibm.wala.ssa.SSAOptions;
import com.ibm.wala.ssa.SymbolTable; import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.TypeReference; import com.ibm.wala.types.TypeReference;
@ -309,8 +310,8 @@ public class ArgumentSpecialization {
} }
@Override @Override
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab, protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI, boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
DebuggingInformation debugInfo) { DebuggingInformation debugInfo) {
if (N == codeBodyEntity) { if (N == codeBodyEntity) {
specializedCode = myloader.makeCodeBodyCode(cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, LI, debugInfo, method.getDeclaringClass()); specializedCode = myloader.makeCodeBodyCode(cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, LI, debugInfo, method.getDeclaringClass());

View File

@ -57,6 +57,7 @@ import com.ibm.wala.ipa.callgraph.impl.ClassHierarchyMethodTargetSelector;
import com.ibm.wala.ipa.cha.ClassHierarchyException; import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.ipa.cha.ClassHierarchyFactory; import com.ibm.wala.ipa.cha.ClassHierarchyFactory;
import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SymbolTable; import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.MethodReference; import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeName; import com.ibm.wala.types.TypeName;
@ -192,8 +193,8 @@ public class JSCallGraphUtil extends com.ibm.wala.cast.ipa.callgraph.CAstCallGra
final Set<String> names = new HashSet<String>(); final Set<String> names = new HashSet<String>();
JSAstTranslator toIR = new JSAstTranslator(cl) { JSAstTranslator toIR = new JSAstTranslator(cl) {
@Override @Override
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab, protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI, boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
DebuggingInformation debugInfo) { DebuggingInformation debugInfo) {
String fnName = "L" + composeEntityName(definingContext, N); String fnName = "L" + composeEntityName(definingContext, N);
names.add(fnName); names.add(fnName);

View File

@ -803,7 +803,7 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
private CAstEntity entity; private CAstEntity entity;
JavaScriptMethodObject(IClass cls, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock, JavaScriptMethodObject(IClass cls, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
super(cls, functionQualifiers, cfg, symtab, AstMethodReference.fnReference(cls.getReference()), hasCatchBlock, caughtTypes, super(cls, functionQualifiers, cfg, symtab, AstMethodReference.fnReference(cls.getReference()), hasCatchBlock, caughtTypes,
hasMonitorOp, lexicalInfo, debugInfo, null); hasMonitorOp, lexicalInfo, debugInfo, null);
@ -917,14 +917,14 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
} }
public IMethod defineCodeBodyCode(String clsName, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock, public IMethod defineCodeBodyCode(String clsName, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
JavaScriptCodeBody C = (JavaScriptCodeBody) lookupClass(clsName, cha); JavaScriptCodeBody C = (JavaScriptCodeBody) lookupClass(clsName, cha);
assert C != null : clsName; assert C != null : clsName;
return C.setCodeBody(makeCodeBodyCode(cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo, C)); return C.setCodeBody(makeCodeBodyCode(cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo, C));
} }
public JavaScriptMethodObject makeCodeBodyCode(AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock, public JavaScriptMethodObject makeCodeBodyCode(AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo, Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo,
IClass C) { IClass C) {
return new JavaScriptMethodObject(C, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, return new JavaScriptMethodObject(C, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo,
debugInfo); debugInfo);

View File

@ -168,8 +168,8 @@ public class JSAstTranslator extends AstTranslator {
} }
@Override @Override
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab, protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI, boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
DebuggingInformation debugInfo) { DebuggingInformation debugInfo) {
if (DEBUG) if (DEBUG)
System.err.println(("\n\nAdding code for " + N)); System.err.println(("\n\nAdding code for " + N));

View File

@ -11,6 +11,7 @@
package com.ibm.wala.cast.ir.ssa; package com.ibm.wala.cast.ir.ssa;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import com.ibm.wala.cast.loader.AstMethod; import com.ibm.wala.cast.loader.AstMethod;
import com.ibm.wala.cast.loader.AstMethod.LexicalInformation; import com.ibm.wala.cast.loader.AstMethod.LexicalInformation;
@ -87,8 +88,8 @@ public class AstIRFactory<T extends IMethod> implements IRFactory<T> {
} }
} }
private void setupCatchTypes(SSACFG cfg, Map<IBasicBlock, TypeReference[]> map) { private void setupCatchTypes(SSACFG cfg, Map<IBasicBlock<SSAInstruction>, TypeReference[]> map) {
for(Map.Entry<IBasicBlock,TypeReference[]> e : map.entrySet()) { for(Entry<IBasicBlock<SSAInstruction>, TypeReference[]> e : map.entrySet()) {
if (e.getKey().getNumber() != -1) { if (e.getKey().getNumber() != -1) {
ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) cfg.getNode(e.getKey().getNumber()); ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) cfg.getNode(e.getKey().getNumber());
for (int j = 0; j < e.getValue().length; j++) { for (int j = 0; j < e.getValue().length; j++) {

View File

@ -139,8 +139,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
* fully define a function. invoked after all the code of the function has * fully define a function. invoked after all the code of the function has
* been processed * been processed
*/ */
protected abstract void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab, protected abstract void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock, TypeReference[]> catchTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
DebuggingInformation debugInfo); DebuggingInformation debugInfo);
/** /**
@ -2332,7 +2332,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
void setCatchType(CAstNode catchNode, TypeReference catchType); void setCatchType(CAstNode catchNode, TypeReference catchType);
Map<IBasicBlock,TypeReference[]> getCatchTypes(); Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes();
void addEntityName(CAstEntity e, String name); void addEntityName(CAstEntity e, String name);
@ -2425,7 +2425,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
} }
@Override @Override
public Map<IBasicBlock, TypeReference[]> getCatchTypes() { public Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes() {
return parent.getCatchTypes(); return parent.getCatchTypes();
} }
@ -2530,7 +2530,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
private final IncipientCFG cfg; private final IncipientCFG cfg;
private final Map<IBasicBlock,TypeReference[]> catchTypes = HashMapFactory.make(); private final Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes = HashMapFactory.make();
Set<Pair<Pair<String, String>, Integer>> exposedReads; Set<Pair<Pair<String, String>, Integer>> exposedReads;
Set<Pair<Pair<String, String>, Integer>> exposedWrites; Set<Pair<Pair<String, String>, Integer>> exposedWrites;
@ -2638,7 +2638,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
} }
@Override @Override
public Map<IBasicBlock,TypeReference[]> getCatchTypes() { public Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes() {
return catchTypes; return catchTypes;
} }
@ -3297,7 +3297,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
// create code entry stuff for this entity // create code entry stuff for this entity
SymbolTable symtab = ((AbstractScope) functionContext.currentScope()).getUnderlyingSymtab(); SymbolTable symtab = ((AbstractScope) functionContext.currentScope()).getUnderlyingSymtab();
Map<IBasicBlock,TypeReference[]> catchTypes = functionContext.getCatchTypes(); Map<IBasicBlock<SSAInstruction>,TypeReference[]> catchTypes = functionContext.getCatchTypes();
AstCFG cfg = new AstCFG(n, functionContext.cfg(), symtab, insts); AstCFG cfg = new AstCFG(n, functionContext.cfg(), symtab, insts);
Position[] line = functionContext.cfg().getLinePositionMap(); Position[] line = functionContext.cfg().getLinePositionMap();
boolean katch = functionContext.cfg().hasCatchBlock(); boolean katch = functionContext.cfg().hasCatchBlock();
@ -4740,7 +4740,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
} }
@Override @Override
public Map<IBasicBlock, TypeReference[]> getCatchTypes() { public Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes() {
return null; return null;
} }

View File

@ -24,6 +24,7 @@ import com.ibm.wala.cfg.IBasicBlock;
import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.shrikeCT.InvalidClassFileException; import com.ibm.wala.shrikeCT.InvalidClassFileException;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SymbolTable; import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.Descriptor; import com.ibm.wala.types.Descriptor;
import com.ibm.wala.types.MethodReference; import com.ibm.wala.types.MethodReference;
@ -108,13 +109,13 @@ public abstract class AstMethod implements IMethod {
private final MethodReference ref; private final MethodReference ref;
private final boolean hasCatchBlock; private final boolean hasCatchBlock;
private final boolean hasMonitorOp; private final boolean hasMonitorOp;
private final Map<IBasicBlock, TypeReference[]> catchTypes; private final Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes;
private final AstLexicalInformation lexicalInfo; private final AstLexicalInformation lexicalInfo;
private final DebuggingInformation debugInfo; private final DebuggingInformation debugInfo;
private final Collection<Annotation> annotations; private final Collection<Annotation> annotations;
protected AstMethod(IClass cls, Collection qualifiers, AbstractCFG cfg, SymbolTable symtab, MethodReference ref, protected AstMethod(IClass cls, Collection qualifiers, AbstractCFG cfg, SymbolTable symtab, MethodReference ref,
boolean hasCatchBlock, Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
DebuggingInformation debugInfo, Collection<Annotation> annotations) { DebuggingInformation debugInfo, Collection<Annotation> annotations) {
this.cls = cls; this.cls = cls;
this.cfg = cfg; this.cfg = cfg;
@ -158,7 +159,7 @@ public abstract class AstMethod implements IMethod {
return symtab; return symtab;
} }
public Map<IBasicBlock, TypeReference[]> catchTypes() { public Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes() {
return catchTypes; return catchTypes;
} }

View File

@ -167,7 +167,7 @@
<param name="destdir" value="${temp.folder}/dalvik/@dot"/> <param name="destdir" value="${temp.folder}/dalvik/@dot"/>
<param name="jsv" value="1.6"/> <param name="jsv" value="1.6"/>
<param name="jtv" value="1.6"/> <param name="jtv" value="1.6"/>
<param name="excludes" value="**/bak/,**/SortingExample.java,defaultMethods/*.java"/> <param name="excludes" value="**/bak/,**/SortingExample.java,defaultMethods/*.java,special/A.java"/>
</antcall> </antcall>
</target> </target>

View File

@ -0,0 +1,30 @@
package special;
class A {
String name;
A() {
setX("silly");
}
public void setX(String name) {
this.name = name;
}
@Override
public
String toString() {
return name;
}
interface Ctor<T> {
T make();
}
public static void main(String[] args) {
Ctor<A> o = A::new;
Object a = o.make();
a.toString();
}
}

View File

@ -41,6 +41,26 @@ import com.ibm.wala.util.strings.Atom;
*/ */
public class LambdaTest extends WalaTestCase { public class LambdaTest extends WalaTestCase {
@Test public void testStreamExample_137() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
ClassHierarchy cha = ClassHierarchyFactory.make(scope);
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
"Lspecial/A");
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
CallGraph cg = CallGraphTestUtil.buildZeroCFA(options, new AnalysisCacheImpl(), cha, scope, false);
TypeReference A = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lspecial/A");
MethodReference ct = MethodReference.findOrCreate(A, Atom.findOrCreateUnicodeAtom("<init>"), Descriptor.findOrCreateUTF8("()V"));
Set<CGNode> ctnodes = cg.getNodes(ct);
Assert.assertEquals(1, ctnodes.size());
MethodReference ts = MethodReference.findOrCreate(A, Atom.findOrCreateUnicodeAtom("toString"), Descriptor.findOrCreateUTF8("()Ljava/lang/String;"));
Set<CGNode> tsnodes = cg.getNodes(ts);
Assert.assertEquals(1, tsnodes.size());
}
@Test public void testSortingExample() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { @Test public void testSortingExample() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS); AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS);

View File

@ -20,6 +20,7 @@ import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IField; import com.ibm.wala.classLoader.IField;
import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.classLoader.SyntheticClass; import com.ibm.wala.classLoader.SyntheticClass;
import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ipa.cha.IClassHierarchy;
@ -257,27 +258,39 @@ public class LambdaSummaryClass extends SyntheticClass {
MethodReference callee = MethodReference.findOrCreate(ClassLoaderReference.Application, getLambdaCalleeClass(), getLambdaCalleeName(), getLambdaCalleeSignature()); MethodReference callee = MethodReference.findOrCreate(ClassLoaderReference.Application, getLambdaCalleeClass(), getLambdaCalleeName(), getLambdaCalleeSignature());
Dispatch code; Dispatch code;
boolean isNew = false;
int new_v = -1;
int kind = getLambdaCalleeKind(); int kind = getLambdaCalleeKind();
switch (kind) { switch (kind) {
case 5: code = Dispatch.VIRTUAL; break; case 5: code = Dispatch.VIRTUAL; break;
case 6: code = Dispatch.STATIC; break; case 6: code = Dispatch.STATIC; break;
case 7: code = Dispatch.SPECIAL; break; case 7: code = Dispatch.SPECIAL; break;
case 8: code = Dispatch.SPECIAL; isNew = true; break;
case 9: code = Dispatch.INTERFACE; break; case 9: code = Dispatch.INTERFACE; break;
default: default:
throw new Error("unexpected dynamic invoke type " + kind); throw new Error("unexpected dynamic invoke type " + kind);
} }
int numParams = getClassHierarchy().resolveMethod(callee).getNumberOfParameters(); int numParams = getClassHierarchy().resolveMethod(callee).getNumberOfParameters();
int params[] = new int[ numParams ]; int params[] = new int[ numParams ];
for(int i = 0; i < invoke.getNumberOfParameters(); i++) { for(int i = isNew? 1: 0; i < invoke.getNumberOfParameters(); i++) {
params[i] = args + i + 1; params[i] = args + i + 1;
} }
for(int n = 2, i = invoke.getNumberOfParameters(); i < numParams; i++) { for(int n = 2, i = invoke.getNumberOfParameters(); i < numParams; i++) {
params[i] = n++; params[i] = n++;
} }
if (isNew) {
v++;
summary.addStatement(insts.NewInstruction(inst++, new_v=v++, NewSiteReference.make(inst, callee.getDeclaringClass())));
params[0] = new_v;
}
if (callee.getReturnType().equals(TypeReference.Void)) { if (callee.getReturnType().equals(TypeReference.Void)) {
summary.addStatement(insts.InvokeInstruction(inst++, params, v++, CallSiteReference.make(inst, callee, code), null)); summary.addStatement(insts.InvokeInstruction(inst++, params, v++, CallSiteReference.make(inst, callee, code), null));
if (isNew) {
summary.addStatement(insts.ReturnInstruction(inst++, new_v, false));
}
} else { } else {
int ret = v++; int ret = v++;
summary.addStatement(insts.InvokeInstruction(inst++, ret, params, v++, CallSiteReference.make(inst, callee, code), null)); summary.addStatement(insts.InvokeInstruction(inst++, ret, params, v++, CallSiteReference.make(inst, callee, code), null));