1) a bit more source mappimg information
2) fixes to how Contexts are combined
This commit is contained in:
parent
31cf42674a
commit
b2503628a4
|
@ -9,8 +9,13 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
|
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.autoboxing=error
|
org.eclipse.jdt.core.compiler.problem.autoboxing=error
|
||||||
|
|
|
@ -289,8 +289,11 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
|
|
||||||
private final T fSourcePosition;
|
private final T fSourcePosition;
|
||||||
|
|
||||||
|
private final T fNamePos;
|
||||||
|
|
||||||
public ClassEntity(ITypeBinding jdtType, String name, Collection<CAstQualifier> quals, Collection<CAstEntity> entities,
|
public ClassEntity(ITypeBinding jdtType, String name, Collection<CAstQualifier> quals, Collection<CAstEntity> entities,
|
||||||
T pos) {
|
T pos, T namePos) {
|
||||||
|
fNamePos = namePos;
|
||||||
fName = name;
|
fName = name;
|
||||||
fQuals = quals;
|
fQuals = quals;
|
||||||
fEntities = entities;
|
fEntities = entities;
|
||||||
|
@ -396,6 +399,11 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
return fTypeDict.new JdtJavaType(fJdtType);
|
return fTypeDict.new JdtJavaType(fJdtType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getNamePosition() {
|
||||||
|
return fNamePos;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isInterface(AbstractTypeDeclaration decl) {
|
private static boolean isInterface(AbstractTypeDeclaration decl) {
|
||||||
|
@ -405,7 +413,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
|
|
||||||
private CAstEntity visitTypeDecl(AbstractTypeDeclaration n, WalkContext context) {
|
private CAstEntity visitTypeDecl(AbstractTypeDeclaration n, WalkContext context) {
|
||||||
return createClassDeclaration(n, n.bodyDeclarations(), null, n.resolveBinding(), n.getName().getIdentifier(), n.getModifiers(),
|
return createClassDeclaration(n, n.bodyDeclarations(), null, n.resolveBinding(), n.getName().getIdentifier(), n.getModifiers(),
|
||||||
isInterface(n), n instanceof AnnotationTypeDeclaration, context);
|
isInterface(n), n instanceof AnnotationTypeDeclaration, context, makePosition(n.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -416,10 +424,11 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
* @param typeBinding
|
* @param typeBinding
|
||||||
* @param name Used in creating default constructor, and passed into new ClassEntity()
|
* @param name Used in creating default constructor, and passed into new ClassEntity()
|
||||||
* @param context
|
* @param context
|
||||||
|
* @param namePos
|
||||||
*/
|
*/
|
||||||
private CAstEntity createClassDeclaration(ASTNode n, List<BodyDeclaration> bodyDecls,
|
private CAstEntity createClassDeclaration(ASTNode n, List<BodyDeclaration> bodyDecls,
|
||||||
List<EnumConstantDeclaration> enumConstants, ITypeBinding typeBinding, String name, int modifiers,
|
List<EnumConstantDeclaration> enumConstants, ITypeBinding typeBinding, String name, int modifiers,
|
||||||
boolean isInterface, boolean isAnnotation, WalkContext context) {
|
boolean isInterface, boolean isAnnotation, WalkContext context, T namePos) {
|
||||||
final List<CAstEntity> memberEntities = new ArrayList<>();
|
final List<CAstEntity> memberEntities = new ArrayList<>();
|
||||||
|
|
||||||
// find and collect all initializers (type Initializer) and field initializers (type VariableDeclarationFragment).
|
// find and collect all initializers (type Initializer) and field initializers (type VariableDeclarationFragment).
|
||||||
|
@ -465,7 +474,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
IVariableBinding fieldBinding = fieldFrag.resolveBinding();
|
IVariableBinding fieldBinding = fieldFrag.resolveBinding();
|
||||||
memberEntities.add(new FieldEntity(fieldFrag.getName().getIdentifier(), fieldBinding.getType(), quals,
|
memberEntities.add(new FieldEntity(fieldFrag.getName().getIdentifier(), fieldBinding.getType(), quals,
|
||||||
makePosition(fieldFrag.getStartPosition(), fieldFrag.getStartPosition() + fieldFrag.getLength()),
|
makePosition(fieldFrag.getStartPosition(), fieldFrag.getStartPosition() + fieldFrag.getLength()),
|
||||||
handleAnnotations(fieldBinding)));
|
handleAnnotations(fieldBinding), makePosition(fieldFrag.getName())));
|
||||||
}
|
}
|
||||||
} else if (decl instanceof Initializer) {
|
} else if (decl instanceof Initializer) {
|
||||||
// Initializers are inserted into constructors when making constructors.
|
// Initializers are inserted into constructors when making constructors.
|
||||||
|
@ -526,12 +535,12 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
|
|
||||||
Collection<CAstQualifier> quals = JDT2CAstUtils.mapModifiersToQualifiers(modifiers, isInterface, isAnnotation);
|
Collection<CAstQualifier> quals = JDT2CAstUtils.mapModifiersToQualifiers(modifiers, isInterface, isAnnotation);
|
||||||
|
|
||||||
return new ClassEntity(typeBinding, name, quals, memberEntities, makePosition(n));
|
return new ClassEntity(typeBinding, name, quals, memberEntities, makePosition(n), namePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CAstEntity visit(AnonymousClassDeclaration n, WalkContext context) {
|
private CAstEntity visit(AnonymousClassDeclaration n, WalkContext context) {
|
||||||
return createClassDeclaration(n, n.bodyDeclarations(), null, n.resolveBinding(),
|
return createClassDeclaration(n, n.bodyDeclarations(), null, n.resolveBinding(),
|
||||||
JDT2CAstUtils.anonTypeName(n.resolveBinding()), 0 /* no modifiers */, false, false, context);
|
JDT2CAstUtils.anonTypeName(n.resolveBinding()), 0 /* no modifiers */, false, false, context, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CAstNode visit(TypeDeclarationStatement n, WalkContext context) {
|
private CAstNode visit(TypeDeclarationStatement n, WalkContext context) {
|
||||||
|
@ -1106,6 +1115,15 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
SingleVariableDeclaration p = (SingleVariableDeclaration) fDecl.parameters().get(arg);
|
SingleVariableDeclaration p = (SingleVariableDeclaration) fDecl.parameters().get(arg);
|
||||||
return makePosition(p);
|
return makePosition(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getNamePosition() {
|
||||||
|
if (fDecl == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return makePosition(fDecl);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////
|
// ////////////////////////////////////
|
||||||
|
@ -1158,13 +1176,16 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
|
|
||||||
private final T position;
|
private final T position;
|
||||||
|
|
||||||
|
private final T namePos;
|
||||||
|
|
||||||
private final Set<CAstAnnotation> annotations;
|
private final Set<CAstAnnotation> annotations;
|
||||||
|
|
||||||
private FieldEntity(String name, ITypeBinding type, Collection<CAstQualifier> quals, T position, Set<CAstAnnotation> annotations) {
|
private FieldEntity(String name, ITypeBinding type, Collection<CAstQualifier> quals, T position, Set<CAstAnnotation> annotations, T namePos) {
|
||||||
super();
|
super();
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.quals = quals;
|
this.quals = quals;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.namePos = namePos;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.annotations = annotations;
|
this.annotations = annotations;
|
||||||
}
|
}
|
||||||
|
@ -1261,6 +1282,13 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Position getPosition(int arg) {
|
public Position getPosition(int arg) {
|
||||||
|
return namePos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getNamePosition() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3045,6 +3073,11 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
public Position getPosition(int arg) {
|
public Position getPosition(int arg) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getNamePosition() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /////////////////////////////
|
// /////////////////////////////
|
||||||
|
@ -3340,7 +3373,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
*/
|
*/
|
||||||
private CAstEntity visit(EnumConstantDeclaration decl, WalkContext context) {
|
private CAstEntity visit(EnumConstantDeclaration decl, WalkContext context) {
|
||||||
return new FieldEntity(decl.getName().getIdentifier(), decl.resolveVariable().getType(), enumQuals, makePosition(decl
|
return new FieldEntity(decl.getName().getIdentifier(), decl.resolveVariable().getType(), enumQuals, makePosition(decl
|
||||||
.getStartPosition(), decl.getStartPosition() + decl.getLength()), null);
|
.getStartPosition(), decl.getStartPosition() + decl.getLength()), null, makePosition(decl.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3489,10 +3522,9 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private CAstEntity visit(EnumDeclaration n, WalkContext context) {
|
private CAstEntity visit(EnumDeclaration n, WalkContext context) {
|
||||||
|
|
||||||
// JDT contains correct type info / class / subclass info for the enum
|
// JDT contains correct type info / class / subclass info for the enum
|
||||||
return createClassDeclaration(n, n.bodyDeclarations(), n.enumConstants(), n.resolveBinding(), n.getName().getIdentifier(), n
|
return createClassDeclaration(n, n.bodyDeclarations(), n.enumConstants(), n.resolveBinding(), n.getName().getIdentifier(), n
|
||||||
.resolveBinding().getModifiers(), false, false, context);
|
.resolveBinding().getModifiers(), false, false, context, makePosition(n.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -410,6 +410,8 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
|
||||||
|
|
||||||
private final Position entityPosition;
|
private final Position entityPosition;
|
||||||
|
|
||||||
|
private final Position namePosition;
|
||||||
|
|
||||||
private final Position[] paramPositions;
|
private final Position[] paramPositions;
|
||||||
|
|
||||||
private ScriptOrFnEntity(AstNode n, Map<CAstNode, Collection<CAstEntity>> subs, CAstNode ast, CAstControlFlowMap map, CAstSourcePositionMap pos, String name) {
|
private ScriptOrFnEntity(AstNode n, Map<CAstNode, Collection<CAstEntity>> subs, CAstNode ast, CAstControlFlowMap map, CAstSourcePositionMap pos, String name) {
|
||||||
|
@ -418,6 +420,7 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
|
||||||
|
|
||||||
if (n instanceof FunctionNode) {
|
if (n instanceof FunctionNode) {
|
||||||
FunctionNode f = (FunctionNode) n;
|
FunctionNode f = (FunctionNode) n;
|
||||||
|
namePosition = makePosition(f.getFunctionName());
|
||||||
f.flattenSymbolTable(false);
|
f.flattenSymbolTable(false);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
arguments = new String[f.getParamCount() + 2];
|
arguments = new String[f.getParamCount() + 2];
|
||||||
|
@ -436,6 +439,7 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
|
||||||
} else {
|
} else {
|
||||||
paramPositions = new Position[0];
|
paramPositions = new Position[0];
|
||||||
arguments = new String[0];
|
arguments = new String[0];
|
||||||
|
namePosition = null;
|
||||||
}
|
}
|
||||||
kind = (n instanceof FunctionNode) ? CAstEntity.FUNCTION_ENTITY : CAstEntity.SCRIPT_ENTITY;
|
kind = (n instanceof FunctionNode) ? CAstEntity.FUNCTION_ENTITY : CAstEntity.SCRIPT_ENTITY;
|
||||||
this.subs = subs;
|
this.subs = subs;
|
||||||
|
@ -538,6 +542,11 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
|
||||||
public Position getPosition(int arg) {
|
public Position getPosition(int arg) {
|
||||||
return paramPositions[arg];
|
return paramPositions[arg];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getNamePosition() {
|
||||||
|
return namePosition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CAstEntity walkEntity(final AstNode n, List<CAstNode> body, String name, WalkContext child) {
|
private CAstEntity walkEntity(final AstNode n, List<CAstNode> body, String name, WalkContext child) {
|
||||||
|
@ -569,6 +578,7 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Position makePosition(AstNode n) {
|
private Position makePosition(AstNode n) {
|
||||||
|
if (n != null) {
|
||||||
URL url = ((SourceModule)sourceModule).getURL();
|
URL url = ((SourceModule)sourceModule).getURL();
|
||||||
int line = n.getLineno();
|
int line = n.getLineno();
|
||||||
Position pos = new RangePosition(url, line, n.getAbsolutePosition(), n.getAbsolutePosition()+n.getLength());
|
Position pos = new RangePosition(url, line, n.getAbsolutePosition(), n.getAbsolutePosition()+n.getLength());
|
||||||
|
@ -581,6 +591,9 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
|
||||||
}
|
}
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CAstNode noteSourcePosition(WalkContext context, CAstNode n, AstNode p) {
|
protected CAstNode noteSourcePosition(WalkContext context, CAstNode n, AstNode p) {
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -191,4 +191,9 @@ class ExtractedFunction implements CAstEntity {
|
||||||
public Position getPosition(int arg) {
|
public Position getPosition(int arg) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getNamePosition() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -130,6 +130,12 @@ public class TestConstantCollector {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getNamePosition() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,12 @@ public class TestNativeTranslator {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getNamePosition() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -504,6 +504,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
||||||
private static class AstDebuggingInformation implements DebuggingInformation {
|
private static class AstDebuggingInformation implements DebuggingInformation {
|
||||||
private Position codeBodyPosition;
|
private Position codeBodyPosition;
|
||||||
|
|
||||||
|
private Position codeBodyNamePosition;
|
||||||
|
|
||||||
private String[][] valueNumberNames;
|
private String[][] valueNumberNames;
|
||||||
|
|
||||||
private Position[] instructionPositions;
|
private Position[] instructionPositions;
|
||||||
|
@ -512,7 +514,9 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
||||||
|
|
||||||
private Position[] parameterPositions;
|
private Position[] parameterPositions;
|
||||||
|
|
||||||
AstDebuggingInformation(Position codeBodyPosition, Position[] instructionPositions, Position[][] operandPositions, Position[] parameterPositions, String[] names) {
|
AstDebuggingInformation(Position codeBodyNamePosition, Position codeBodyPosition, Position[] instructionPositions, Position[][] operandPositions, Position[] parameterPositions, String[] names) {
|
||||||
|
this.codeBodyNamePosition = codeBodyNamePosition;
|
||||||
|
|
||||||
this.codeBodyPosition = codeBodyPosition;
|
this.codeBodyPosition = codeBodyPosition;
|
||||||
|
|
||||||
this.instructionPositions = instructionPositions;
|
this.instructionPositions = instructionPositions;
|
||||||
|
@ -536,6 +540,11 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
||||||
return codeBodyPosition;
|
return codeBodyPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getCodeNamePosition() {
|
||||||
|
return codeBodyNamePosition;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Position getInstructionPosition(int instructionOffset) {
|
public Position getInstructionPosition(int instructionOffset) {
|
||||||
return instructionPositions[instructionOffset];
|
return instructionPositions[instructionOffset];
|
||||||
|
@ -3386,7 +3395,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
||||||
|
|
||||||
Position[] parameterPositions = getParameterPositions(n);
|
Position[] parameterPositions = getParameterPositions(n);
|
||||||
|
|
||||||
DebuggingInformation DBG = new AstDebuggingInformation(n.getPosition(), line, operand, parameterPositions, nms);
|
DebuggingInformation DBG = new AstDebuggingInformation(n.getNamePosition(), n.getPosition(), line, operand, parameterPositions, nms);
|
||||||
|
|
||||||
// actually make code body
|
// actually make code body
|
||||||
defineFunction(n, parentContext, cfg, symtab, katch, catchTypes, monitor, LI, DBG);
|
defineFunction(n, parentContext, cfg, symtab, katch, catchTypes, monitor, LI, DBG);
|
||||||
|
|
|
@ -46,6 +46,8 @@ public abstract class AstMethod implements IMethod {
|
||||||
|
|
||||||
Position getCodeBodyPosition();
|
Position getCodeBodyPosition();
|
||||||
|
|
||||||
|
Position getCodeNamePosition();
|
||||||
|
|
||||||
Position getInstructionPosition(int instructionOffset);
|
Position getInstructionPosition(int instructionOffset);
|
||||||
|
|
||||||
String[][] getSourceNamesForValues();
|
String[][] getSourceNamesForValues();
|
||||||
|
|
|
@ -161,6 +161,11 @@ public interface CAstEntity {
|
||||||
*/
|
*/
|
||||||
CAstSourcePositionMap.Position getPosition();
|
CAstSourcePositionMap.Position getPosition();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The source position of the token denoting this entity's name.
|
||||||
|
*/
|
||||||
|
CAstSourcePositionMap.Position getNamePosition();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The source position of argument 'arg' this entity, if any;
|
* The source position of argument 'arg' this entity, if any;
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -116,4 +116,9 @@ public class DelegatingEntity implements CAstEntity {
|
||||||
return base.getPosition(arg);
|
return base.getPosition(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getNamePosition() {
|
||||||
|
return base.getNamePosition();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class AstConstantCollector {
|
||||||
Object val = s.getSingle("value").getValue();
|
Object val = s.getSingle("value").getValue();
|
||||||
if (! bad.contains(var)) {
|
if (! bad.contains(var)) {
|
||||||
if (values.containsKey(var)) {
|
if (values.containsKey(var)) {
|
||||||
if (!values.get(var).equals(val)) {
|
if (val == null? values.get(var) != null: !values.get(var).equals(val)) {
|
||||||
values.remove(var);
|
values.remove(var);
|
||||||
bad.add(var);
|
bad.add(var);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -19,7 +19,6 @@ import sun.java2d.FontSupport;
|
||||||
* TODO To change the template for this generated type comment go to
|
* TODO To change the template for this generated type comment go to
|
||||||
* Window - Preferences - Java - Code Style - Code Templates
|
* Window - Preferences - Java - Code Style - Code Templates
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -18,7 +18,6 @@ import sun.java2d.FontSupport;
|
||||||
* When analyzed with J2EEClassHierarchy exclusions, the superinterface
|
* When analyzed with J2EEClassHierarchy exclusions, the superinterface
|
||||||
* FontSupport should not be found because we exclude sun.java2d.*
|
* FontSupport should not be found because we exclude sun.java2d.*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("restriction")
|
|
||||||
public interface YuckyInterface extends FontSupport {
|
public interface YuckyInterface extends FontSupport {
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.util.jar.JarFile;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.ibm.wala.analysis.reflection.java7.MethodHandles;
|
import com.ibm.wala.analysis.reflection.java7.MethodHandles;
|
||||||
|
import com.ibm.wala.classLoader.Language;
|
||||||
import com.ibm.wala.core.tests.shrike.DynamicCallGraphTestBase;
|
import com.ibm.wala.core.tests.shrike.DynamicCallGraphTestBase;
|
||||||
import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl;
|
import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl;
|
||||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||||
|
@ -54,14 +55,17 @@ public class Java7CallGraphTest extends DynamicCallGraphTestBase {
|
||||||
ClassHierarchy cha = ClassHierarchyFactory.make(scope);
|
ClassHierarchy cha = ClassHierarchyFactory.make(scope);
|
||||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "Lpack/ocamljavaMain");
|
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "Lpack/ocamljavaMain");
|
||||||
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
||||||
|
options.setUseConstantSpecificKeys(true);
|
||||||
IAnalysisCacheView cache = new AnalysisCacheImpl();
|
IAnalysisCacheView cache = new AnalysisCacheImpl();
|
||||||
|
|
||||||
SSAPropagationCallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
|
SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope);
|
||||||
|
|
||||||
MethodHandles.analyzeMethodHandles(options, builder);
|
MethodHandles.analyzeMethodHandles(options, builder);
|
||||||
|
|
||||||
CallGraph cg = builder.makeCallGraph(options, null);
|
CallGraph cg = builder.makeCallGraph(options, null);
|
||||||
|
|
||||||
|
System.err.println(cg);
|
||||||
|
|
||||||
instrument(F.getAbsolutePath());
|
instrument(F.getAbsolutePath());
|
||||||
run("pack.ocamljavaMain", null, args);
|
run("pack.ocamljavaMain", null, args);
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class KawaCallGraphTest extends DynamicCallGraphTestBase {
|
||||||
Set<CGNode> color = getNodes(CG, "Lchess", "startingColor", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
Set<CGNode> color = getNodes(CG, "Lchess", "startingColor", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
||||||
assert ! color.isEmpty();
|
assert ! color.isEmpty();
|
||||||
|
|
||||||
|
System.out.println(CG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -78,7 +79,7 @@ public class KawaCallGraphTest extends DynamicCallGraphTestBase {
|
||||||
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
||||||
IAnalysisCacheView cache = new AnalysisCacheImpl();
|
IAnalysisCacheView cache = new AnalysisCacheImpl();
|
||||||
|
|
||||||
options.setReflectionOptions(ReflectionOptions.NONE);
|
options.setReflectionOptions(ReflectionOptions.STRING_ONLY);
|
||||||
options.setTraceStringConstants(true);
|
options.setTraceStringConstants(true);
|
||||||
options.setUseConstantSpecificKeys(true);
|
options.setUseConstantSpecificKeys(true);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||||
import com.ibm.wala.ipa.callgraph.Context;
|
import com.ibm.wala.ipa.callgraph.Context;
|
||||||
|
import com.ibm.wala.ipa.callgraph.ContextKey;
|
||||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||||
import com.ibm.wala.ipa.callgraph.impl.Everywhere;
|
import com.ibm.wala.ipa.callgraph.impl.Everywhere;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.ConstantKey;
|
import com.ibm.wala.ipa.callgraph.propagation.ConstantKey;
|
||||||
|
@ -278,9 +279,8 @@ public class ReflectionTest extends WalaTestCase {
|
||||||
|
|
||||||
for (CGNode node : mainChildren) {
|
for (CGNode node : mainChildren) {
|
||||||
Context context = node.getContext();
|
Context context = node.getContext();
|
||||||
if (context instanceof ReceiverInstanceContext && node.getMethod().getReference().equals(newInstanceMr)) {
|
if (context.isA(ReceiverInstanceContext.class) && node.getMethod().getReference().equals(newInstanceMr)) {
|
||||||
ReceiverInstanceContext r = (ReceiverInstanceContext) context;
|
ConstantKey<IMethod> c = (ConstantKey<IMethod>) context.get(ContextKey.RECEIVER);
|
||||||
ConstantKey<IMethod> c = (ConstantKey<IMethod>) r.getReceiver();
|
|
||||||
IMethod ctor = c.getValue();
|
IMethod ctor = c.getValue();
|
||||||
if (ctor.getSignature().equals(fpInitSig)) {
|
if (ctor.getSignature().equals(fpInitSig)) {
|
||||||
filePermConstrNewInstanceNode = node;
|
filePermConstrNewInstanceNode = node;
|
||||||
|
@ -377,6 +377,7 @@ public class ReflectionTest extends WalaTestCase {
|
||||||
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer");
|
TypeReference tr = TypeReference.findOrCreate(ClassLoaderReference.Primordial, "Ljava/lang/Integer");
|
||||||
MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;");
|
MethodReference mr = MethodReference.findOrCreate(tr, "toString", "()Ljava/lang/String;");
|
||||||
Set<CGNode> nodes = cg.getNodes(mr);
|
Set<CGNode> nodes = cg.getNodes(mr);
|
||||||
|
System.err.println(cg);
|
||||||
Assert.assertFalse(nodes.isEmpty());
|
Assert.assertFalse(nodes.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ public abstract class DynamicCallGraphTestBase extends WalaTestCase {
|
||||||
if (! filter.test(callerRef)) {
|
if (! filter.test(callerRef)) {
|
||||||
continue loop;
|
continue loop;
|
||||||
}
|
}
|
||||||
Assert.assertEquals(callerMethod, 1, nodes.size());
|
Assert.assertEquals(callerRef.toString(), 1, nodes.size());
|
||||||
caller = nodes.iterator().next();
|
caller = nodes.iterator().next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.ibm.wala.analysis.typeInference.TypeAbstraction;
|
||||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||||
import com.ibm.wala.cfg.InducedCFG;
|
import com.ibm.wala.cfg.InducedCFG;
|
||||||
import com.ibm.wala.classLoader.CallSiteReference;
|
import com.ibm.wala.classLoader.CallSiteReference;
|
||||||
|
@ -21,6 +22,8 @@ import com.ibm.wala.classLoader.IClass;
|
||||||
import com.ibm.wala.classLoader.IMethod;
|
import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.classLoader.NewSiteReference;
|
import com.ibm.wala.classLoader.NewSiteReference;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
|
import com.ibm.wala.ipa.callgraph.Context;
|
||||||
|
import com.ibm.wala.ipa.callgraph.ContextKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||||
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
||||||
import com.ibm.wala.ssa.DefUse;
|
import com.ibm.wala.ssa.DefUse;
|
||||||
|
@ -63,7 +66,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
|
||||||
/** BEGIN Custom change: caching */
|
/** BEGIN Custom change: caching */
|
||||||
|
|
||||||
|
|
||||||
final JavaTypeContext context = (JavaTypeContext) node.getContext();
|
final Context context = node.getContext();
|
||||||
final IMethod method = node.getMethod();
|
final IMethod method = node.getMethod();
|
||||||
final String hashKey = method.toString() + "@" + context.toString();
|
final String hashKey = method.toString() + "@" + context.toString();
|
||||||
|
|
||||||
|
@ -97,7 +100,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
throw new IllegalArgumentException("node is null");
|
throw new IllegalArgumentException("node is null");
|
||||||
}
|
}
|
||||||
if (!(node.getContext() instanceof JavaTypeContext)) {
|
if (!(node.getContext().isA(JavaTypeContext.class))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ClassFactoryContextSelector.isClassFactory(node.getMethod().getReference());
|
return ClassFactoryContextSelector.isClassFactory(node.getMethod().getReference());
|
||||||
|
@ -112,8 +115,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
|
||||||
throw new IllegalArgumentException("node is null");
|
throw new IllegalArgumentException("node is null");
|
||||||
}
|
}
|
||||||
assert understands(node);
|
assert understands(node);
|
||||||
JavaTypeContext context = (JavaTypeContext) node.getContext();
|
TypeReference tr = ((TypeAbstraction)node.getContext().get(ContextKey.RECEIVER)).getTypeReference();
|
||||||
TypeReference tr = context.getType().getTypeReference();
|
|
||||||
if (tr != null) {
|
if (tr != null) {
|
||||||
return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr));
|
return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr));
|
||||||
}
|
}
|
||||||
|
@ -129,12 +131,12 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
|
||||||
return EmptyIterator.instance();
|
return EmptyIterator.instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SSAInstruction[] makeStatements(JavaTypeContext context) {
|
private static SSAInstruction[] makeStatements(Context context) {
|
||||||
SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory();
|
SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory();
|
||||||
ArrayList<SSAInstruction> statements = new ArrayList<>();
|
ArrayList<SSAInstruction> statements = new ArrayList<>();
|
||||||
// vn1 is the string parameter
|
// vn1 is the string parameter
|
||||||
int retValue = 2;
|
int retValue = 2;
|
||||||
TypeReference tr = context.getType().getTypeReference();
|
TypeReference tr = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getTypeReference();
|
||||||
if (tr != null) {
|
if (tr != null) {
|
||||||
SSALoadMetadataInstruction l = insts.LoadMetadataInstruction(statements.size(), retValue, TypeReference.JavaLangClass, tr);
|
SSALoadMetadataInstruction l = insts.LoadMetadataInstruction(statements.size(), retValue, TypeReference.JavaLangClass, tr);
|
||||||
statements.add(l);
|
statements.add(l);
|
||||||
|
@ -149,7 +151,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IR makeIR(IMethod method, JavaTypeContext context) {
|
private static IR makeIR(IMethod method, Context context) {
|
||||||
SSAInstruction instrs[] = makeStatements(context);
|
SSAInstruction instrs[] = makeStatements(context);
|
||||||
return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), null);
|
return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,12 @@ package com.ibm.wala.analysis.reflection;
|
||||||
import com.ibm.wala.analysis.typeInference.PointType;
|
import com.ibm.wala.analysis.typeInference.PointType;
|
||||||
import com.ibm.wala.classLoader.CallSiteReference;
|
import com.ibm.wala.classLoader.CallSiteReference;
|
||||||
import com.ibm.wala.classLoader.IClass;
|
import com.ibm.wala.classLoader.IClass;
|
||||||
|
import com.ibm.wala.classLoader.IClassLoader;
|
||||||
import com.ibm.wala.classLoader.IMethod;
|
import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
import com.ibm.wala.ipa.callgraph.Context;
|
import com.ibm.wala.ipa.callgraph.Context;
|
||||||
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
||||||
|
import com.ibm.wala.ipa.callgraph.propagation.ConstantKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||||
import com.ibm.wala.ssa.IR;
|
import com.ibm.wala.ssa.IR;
|
||||||
|
@ -103,19 +105,35 @@ class ClassFactoryContextSelector implements ContextSelector {
|
||||||
return new JavaTypeContext(new PointType(klass));
|
return new JavaTypeContext(new PointType(klass));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int nameVn = callee.isStatic()? 0: 1;
|
||||||
|
if (receiver != null && receiver.length > nameVn) {
|
||||||
|
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()) {
|
||||||
|
TypeReference t = TypeReference.findOrCreate(cl.getReference(), className);
|
||||||
|
IClass klass = caller.getClassHierarchy().lookupClass(t);
|
||||||
|
if (klass != null) {
|
||||||
|
return new JavaTypeContext(new PointType(klass));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final IntSet thisParameter = IntSetUtil.make(new int[]{0});
|
private static final IntSet thisParameter = IntSetUtil.make(new int[]{0});
|
||||||
|
|
||||||
private static final IntSet firstParameter = IntSetUtil.make(new int[]{1});
|
private static final IntSet firstParameter = IntSetUtil.make(new int[]{0, 1});
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) {
|
public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) {
|
||||||
if (isClassFactory(site.getDeclaredTarget())) {
|
if (isClassFactory(site.getDeclaredTarget())) {
|
||||||
SSAAbstractInvokeInstruction[] invokeInstructions = caller.getIR().getCalls(site);
|
SSAAbstractInvokeInstruction[] invokeInstructions = caller.getIR().getCalls(site);
|
||||||
if (invokeInstructions.length != 1) {
|
if (invokeInstructions.length >= 1) {
|
||||||
if (invokeInstructions[0].isStatic()) {
|
if (invokeInstructions[0].isStatic()) {
|
||||||
return thisParameter;
|
return thisParameter;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,6 +13,7 @@ package com.ibm.wala.analysis.reflection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.ibm.wala.analysis.typeInference.TypeAbstraction;
|
||||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||||
import com.ibm.wala.cfg.InducedCFG;
|
import com.ibm.wala.cfg.InducedCFG;
|
||||||
import com.ibm.wala.classLoader.CallSiteReference;
|
import com.ibm.wala.classLoader.CallSiteReference;
|
||||||
|
@ -20,6 +21,8 @@ import com.ibm.wala.classLoader.IClass;
|
||||||
import com.ibm.wala.classLoader.IMethod;
|
import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.classLoader.NewSiteReference;
|
import com.ibm.wala.classLoader.NewSiteReference;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
|
import com.ibm.wala.ipa.callgraph.Context;
|
||||||
|
import com.ibm.wala.ipa.callgraph.ContextKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||||
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
||||||
|
@ -81,7 +84,7 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp
|
||||||
}
|
}
|
||||||
/** BEGIN Custom change: caching */
|
/** BEGIN Custom change: caching */
|
||||||
|
|
||||||
final JavaTypeContext context = (JavaTypeContext) node.getContext();
|
final Context context = node.getContext();
|
||||||
final IMethod method = node.getMethod();
|
final IMethod method = node.getMethod();
|
||||||
final String hashKey = method.toString() + "@" + context.toString();
|
final String hashKey = method.toString() + "@" + context.toString();
|
||||||
|
|
||||||
|
@ -112,7 +115,7 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
throw new IllegalArgumentException("node is null");
|
throw new IllegalArgumentException("node is null");
|
||||||
}
|
}
|
||||||
if (!(node.getContext() instanceof JavaTypeContext)) {
|
if (!(node.getContext().isA(JavaTypeContext.class))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return node.getMethod().getReference().equals(CLASS_NEW_INSTANCE_REF);
|
return node.getMethod().getReference().equals(CLASS_NEW_INSTANCE_REF);
|
||||||
|
@ -124,8 +127,8 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp
|
||||||
throw new IllegalArgumentException("node is null");
|
throw new IllegalArgumentException("node is null");
|
||||||
}
|
}
|
||||||
assert understands(node);
|
assert understands(node);
|
||||||
JavaTypeContext context = (JavaTypeContext) node.getContext();
|
Context context = node.getContext();
|
||||||
TypeReference tr = context.getType().getTypeReference();
|
TypeReference tr = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getTypeReference();
|
||||||
if (tr != null) {
|
if (tr != null) {
|
||||||
return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr));
|
return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr));
|
||||||
}
|
}
|
||||||
|
@ -138,9 +141,9 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp
|
||||||
return EmptyIterator.instance();
|
return EmptyIterator.instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IR makeIR(IMethod method, JavaTypeContext context) {
|
private IR makeIR(IMethod method, Context context) {
|
||||||
SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory();
|
SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory();
|
||||||
TypeReference tr = context.getType().getTypeReference();
|
TypeReference tr = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getTypeReference();
|
||||||
if (tr != null) {
|
if (tr != null) {
|
||||||
SpecializedMethod m = new SpecializedMethod(method, method.getDeclaringClass(), method.isStatic(), false);
|
SpecializedMethod m = new SpecializedMethod(method, method.getDeclaringClass(), method.isStatic(), false);
|
||||||
IClass klass = cha.lookupClass(tr);
|
IClass klass = cha.lookupClass(tr);
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.ibm.wala.analysis.typeInference.TypeAbstraction;
|
||||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||||
import com.ibm.wala.cfg.InducedCFG;
|
import com.ibm.wala.cfg.InducedCFG;
|
||||||
import com.ibm.wala.classLoader.CallSiteReference;
|
import com.ibm.wala.classLoader.CallSiteReference;
|
||||||
|
@ -21,6 +22,8 @@ import com.ibm.wala.classLoader.IClass;
|
||||||
import com.ibm.wala.classLoader.IMethod;
|
import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.classLoader.NewSiteReference;
|
import com.ibm.wala.classLoader.NewSiteReference;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
|
import com.ibm.wala.ipa.callgraph.Context;
|
||||||
|
import com.ibm.wala.ipa.callgraph.ContextKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||||
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
||||||
import com.ibm.wala.ssa.DefUse;
|
import com.ibm.wala.ssa.DefUse;
|
||||||
|
@ -59,7 +62,7 @@ public class GetClassContextInterpeter implements SSAContextInterpreter {
|
||||||
}
|
}
|
||||||
/** BEGIN Custom change: caching */
|
/** BEGIN Custom change: caching */
|
||||||
|
|
||||||
final JavaTypeContext context = (JavaTypeContext) node.getContext();
|
final Context context = node.getContext();
|
||||||
final IMethod method = node.getMethod();
|
final IMethod method = node.getMethod();
|
||||||
final String hashKey = method.toString() + "@" + context.toString();
|
final String hashKey = method.toString() + "@" + context.toString();
|
||||||
|
|
||||||
|
@ -90,7 +93,7 @@ public class GetClassContextInterpeter implements SSAContextInterpreter {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
throw new IllegalArgumentException("node is null");
|
throw new IllegalArgumentException("node is null");
|
||||||
}
|
}
|
||||||
if (!(node.getContext() instanceof JavaTypeContext)) {
|
if (!(node.getContext().isA(JavaTypeContext.class))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return node.getMethod().getReference().equals(GetClassContextSelector.GET_CLASS);
|
return node.getMethod().getReference().equals(GetClassContextSelector.GET_CLASS);
|
||||||
|
@ -106,12 +109,12 @@ public class GetClassContextInterpeter implements SSAContextInterpreter {
|
||||||
return EmptyIterator.instance();
|
return EmptyIterator.instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SSAInstruction[] makeStatements(JavaTypeContext context) {
|
private static SSAInstruction[] makeStatements(Context context) {
|
||||||
ArrayList<SSAInstruction> statements = new ArrayList<>();
|
ArrayList<SSAInstruction> statements = new ArrayList<>();
|
||||||
int nextLocal = 2;
|
int nextLocal = 2;
|
||||||
int retValue = nextLocal++;
|
int retValue = nextLocal++;
|
||||||
TypeReference tr = context.getType().getTypeReference();
|
TypeReference tr = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getTypeReference();
|
||||||
SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory();
|
SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory();
|
||||||
if (tr != null) {
|
if (tr != null) {
|
||||||
SSALoadMetadataInstruction l = insts.LoadMetadataInstruction(statements.size(), retValue, TypeReference.JavaLangClass, tr);
|
SSALoadMetadataInstruction l = insts.LoadMetadataInstruction(statements.size(), retValue, TypeReference.JavaLangClass, tr);
|
||||||
statements.add(l);
|
statements.add(l);
|
||||||
|
@ -126,7 +129,7 @@ public class GetClassContextInterpeter implements SSAContextInterpreter {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IR makeIR(IMethod method, JavaTypeContext context) {
|
private static IR makeIR(IMethod method, Context context) {
|
||||||
SSAInstruction instrs[] = makeStatements(context);
|
SSAInstruction instrs[] = makeStatements(context);
|
||||||
return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), null);
|
return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,10 +83,17 @@ public class GetMethodContext implements Context {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NameItem implements ContextItem {
|
||||||
|
String name() { return getName(); }
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContextItem get(ContextKey name) {
|
public ContextItem get(ContextKey name) {
|
||||||
|
|
||||||
if (name == ContextKey.RECEIVER) {
|
if (name == ContextKey.RECEIVER) {
|
||||||
return type;
|
return type;
|
||||||
|
} else if (name == ContextKey.NAME) {
|
||||||
|
return new NameItem();
|
||||||
} else if (name == ContextKey.PARAMETERS[0]) {
|
} else if (name == ContextKey.PARAMETERS[0]) {
|
||||||
if (type instanceof PointType) {
|
if (type instanceof PointType) {
|
||||||
IClass cls = ((PointType) type).getIClass();
|
IClass cls = ((PointType) type).getIClass();
|
||||||
|
|
|
@ -15,6 +15,8 @@ import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.ibm.wala.analysis.reflection.GetMethodContext.NameItem;
|
||||||
|
import com.ibm.wala.analysis.typeInference.TypeAbstraction;
|
||||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||||
import com.ibm.wala.cfg.InducedCFG;
|
import com.ibm.wala.cfg.InducedCFG;
|
||||||
import com.ibm.wala.classLoader.CallSiteReference;
|
import com.ibm.wala.classLoader.CallSiteReference;
|
||||||
|
@ -22,6 +24,8 @@ import com.ibm.wala.classLoader.IClass;
|
||||||
import com.ibm.wala.classLoader.IMethod;
|
import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.classLoader.NewSiteReference;
|
import com.ibm.wala.classLoader.NewSiteReference;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
|
import com.ibm.wala.ipa.callgraph.Context;
|
||||||
|
import com.ibm.wala.ipa.callgraph.ContextKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||||
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
||||||
import com.ibm.wala.ssa.ConstantValue;
|
import com.ibm.wala.ssa.ConstantValue;
|
||||||
|
@ -79,15 +83,15 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
|
||||||
System.err.println("generating IR for " + node);
|
System.err.println("generating IR for " + node);
|
||||||
}
|
}
|
||||||
IMethod method = node.getMethod();
|
IMethod method = node.getMethod();
|
||||||
GetMethodContext context = (GetMethodContext) node.getContext();
|
Context context = node.getContext();
|
||||||
Map<Integer,ConstantValue> constants = HashMapFactory.make();
|
Map<Integer,ConstantValue> constants = HashMapFactory.make();
|
||||||
if (method.getReference().equals(GET_METHOD)) {
|
if (method.getReference().equals(GET_METHOD)) {
|
||||||
Atom name = Atom.findOrCreateAsciiAtom(context.getName());
|
Atom name = Atom.findOrCreateAsciiAtom(((NameItem)(context.get(ContextKey.NAME))).name());
|
||||||
SSAInstruction instrs[] = makeGetMethodStatements(context,constants,name);
|
SSAInstruction instrs[] = makeGetMethodStatements(context,constants,name);
|
||||||
return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), constants);
|
return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), constants);
|
||||||
}
|
}
|
||||||
if (method.getReference().equals(GET_DECLARED_METHOD)) {
|
if (method.getReference().equals(GET_DECLARED_METHOD)) {
|
||||||
Atom name = Atom.findOrCreateAsciiAtom(context.getName());
|
Atom name = Atom.findOrCreateAsciiAtom(((NameItem)(context.get(ContextKey.NAME))).name());
|
||||||
SSAInstruction instrs[] = makeGetDeclaredMethodStatements(context,constants,name);
|
SSAInstruction instrs[] = makeGetDeclaredMethodStatements(context,constants,name);
|
||||||
return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), constants);
|
return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), constants);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +121,7 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
throw new IllegalArgumentException("node is null");
|
throw new IllegalArgumentException("node is null");
|
||||||
}
|
}
|
||||||
if (!(node.getContext() instanceof GetMethodContext)) {
|
if (!(node.getContext().isA(GetMethodContext.class))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MethodReference mRef = node.getMethod().getReference();
|
MethodReference mRef = node.getMethod().getReference();
|
||||||
|
@ -190,13 +194,13 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
|
||||||
(
|
(
|
||||||
MethodReference ref,
|
MethodReference ref,
|
||||||
Collection<IMethod> returnValues,
|
Collection<IMethod> returnValues,
|
||||||
GetMethodContext context,
|
Context context,
|
||||||
Map<Integer, ConstantValue> constants
|
Map<Integer, ConstantValue> constants
|
||||||
) {
|
) {
|
||||||
ArrayList<SSAInstruction> statements = new ArrayList<>();
|
ArrayList<SSAInstruction> statements = new ArrayList<>();
|
||||||
int nextLocal = ref.getNumberOfParameters() + 2;
|
int nextLocal = ref.getNumberOfParameters() + 2;
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory();
|
SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory();
|
||||||
if (cls != null) {
|
if (cls != null) {
|
||||||
for (IMethod m : returnValues) {
|
for (IMethod m : returnValues) {
|
||||||
int c = nextLocal++;
|
int c = nextLocal++;
|
||||||
|
@ -219,11 +223,11 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
|
||||||
|
|
||||||
private static SSAInstruction[] makeGetMethodStatements
|
private static SSAInstruction[] makeGetMethodStatements
|
||||||
(
|
(
|
||||||
GetMethodContext context,
|
Context context,
|
||||||
Map<Integer,ConstantValue> constants,
|
Map<Integer,ConstantValue> constants,
|
||||||
Atom name
|
Atom name
|
||||||
) {
|
) {
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return getParticularMethodStatements(GET_METHOD, null, context, constants);
|
return getParticularMethodStatements(GET_METHOD, null, context, constants);
|
||||||
} else {
|
} else {
|
||||||
|
@ -234,8 +238,8 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
|
||||||
/**
|
/**
|
||||||
* Create statements for {@link Class#getDeclaredMethod(String, Class...)}.
|
* Create statements for {@link Class#getDeclaredMethod(String, Class...)}.
|
||||||
*/
|
*/
|
||||||
private static SSAInstruction[] makeGetDeclaredMethodStatements(GetMethodContext context, Map<Integer, ConstantValue> constants,Atom name) {
|
private static SSAInstruction[] makeGetDeclaredMethodStatements(Context context, Map<Integer, ConstantValue> constants,Atom name) {
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return getParticularMethodStatements(GET_DECLARED_METHOD, null, context, constants);
|
return getParticularMethodStatements(GET_DECLARED_METHOD, null, context, constants);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.ibm.wala.analysis.typeInference.TypeAbstraction;
|
||||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||||
import com.ibm.wala.cfg.InducedCFG;
|
import com.ibm.wala.cfg.InducedCFG;
|
||||||
import com.ibm.wala.classLoader.CallSiteReference;
|
import com.ibm.wala.classLoader.CallSiteReference;
|
||||||
|
@ -22,6 +23,8 @@ import com.ibm.wala.classLoader.IClass;
|
||||||
import com.ibm.wala.classLoader.IMethod;
|
import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.classLoader.NewSiteReference;
|
import com.ibm.wala.classLoader.NewSiteReference;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
|
import com.ibm.wala.ipa.callgraph.Context;
|
||||||
|
import com.ibm.wala.ipa.callgraph.ContextKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||||
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
||||||
import com.ibm.wala.ssa.ConstantValue;
|
import com.ibm.wala.ssa.ConstantValue;
|
||||||
|
@ -106,7 +109,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
}
|
}
|
||||||
/** BEGIN Custom change: caching */
|
/** BEGIN Custom change: caching */
|
||||||
|
|
||||||
final JavaTypeContext context = (JavaTypeContext) node.getContext();
|
final Context context = node.getContext();
|
||||||
final IMethod method = node.getMethod();
|
final IMethod method = node.getMethod();
|
||||||
final String hashKey = method.toString() + "@" + context.toString();
|
final String hashKey = method.toString() + "@" + context.toString();
|
||||||
|
|
||||||
|
@ -128,7 +131,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
return getIR(node);
|
return getIR(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IR makeIR(IMethod method, JavaTypeContext context) {
|
private static IR makeIR(IMethod method, Context context) {
|
||||||
Map<Integer, ConstantValue> constants = HashMapFactory.make();
|
Map<Integer, ConstantValue> constants = HashMapFactory.make();
|
||||||
if (method.getReference().equals(GET_CONSTRUCTOR)) {
|
if (method.getReference().equals(GET_CONSTRUCTOR)) {
|
||||||
SSAInstruction instrs[] = makeGetCtorStatements(context, constants);
|
SSAInstruction instrs[] = makeGetCtorStatements(context, constants);
|
||||||
|
@ -192,7 +195,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
throw new IllegalArgumentException("node is null");
|
throw new IllegalArgumentException("node is null");
|
||||||
}
|
}
|
||||||
if (!(node.getContext() instanceof JavaTypeContext)) {
|
if (!(node.getContext().isA(JavaTypeContext.class))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MethodReference mRef = node.getMethod().getReference();
|
MethodReference mRef = node.getMethod().getReference();
|
||||||
|
@ -207,8 +210,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
throw new IllegalArgumentException("node is null");
|
throw new IllegalArgumentException("node is null");
|
||||||
}
|
}
|
||||||
assert understands(node);
|
assert understands(node);
|
||||||
JavaTypeContext context = (JavaTypeContext) node.getContext();
|
Context context = node.getContext();
|
||||||
TypeReference tr = context.getType().getTypeReference();
|
TypeReference tr = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getTypeReference();
|
||||||
if (tr != null) {
|
if (tr != null) {
|
||||||
return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr));
|
return new NonNullSingletonIterator<>(NewSiteReference.make(0, tr));
|
||||||
}
|
}
|
||||||
|
@ -280,13 +283,13 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
*
|
*
|
||||||
* @param returnValues the possible return values for this method.
|
* @param returnValues the possible return values for this method.
|
||||||
*/
|
*/
|
||||||
private static SSAInstruction[] getMethodArrayStatements(MethodReference ref, Collection<IMethod> returnValues, JavaTypeContext context,
|
private static SSAInstruction[] getMethodArrayStatements(MethodReference ref, Collection<IMethod> returnValues, Context context,
|
||||||
Map<Integer, ConstantValue> constants) {
|
Map<Integer, ConstantValue> constants) {
|
||||||
ArrayList<SSAInstruction> statements = new ArrayList<>();
|
ArrayList<SSAInstruction> statements = new ArrayList<>();
|
||||||
int nextLocal = ref.getNumberOfParameters() + 2;
|
int nextLocal = ref.getNumberOfParameters() + 2;
|
||||||
int retValue = nextLocal++;
|
int retValue = nextLocal++;
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory();
|
SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory();
|
||||||
if (cls != null) {
|
if (cls != null) {
|
||||||
TypeReference arrType = ref.getReturnType();
|
TypeReference arrType = ref.getReturnType();
|
||||||
NewSiteReference site = new NewSiteReference(retValue, arrType);
|
NewSiteReference site = new NewSiteReference(retValue, arrType);
|
||||||
|
@ -328,11 +331,11 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
* @param returnValues the possible return values for this method.
|
* @param returnValues the possible return values for this method.
|
||||||
*/
|
*/
|
||||||
private static SSAInstruction[] getParticularMethodStatements(MethodReference ref, Collection<IMethod> returnValues,
|
private static SSAInstruction[] getParticularMethodStatements(MethodReference ref, Collection<IMethod> returnValues,
|
||||||
JavaTypeContext context, Map<Integer, ConstantValue> constants) {
|
Context context, Map<Integer, ConstantValue> constants) {
|
||||||
ArrayList<SSAInstruction> statements = new ArrayList<>();
|
ArrayList<SSAInstruction> statements = new ArrayList<>();
|
||||||
int nextLocal = ref.getNumberOfParameters() + 2;
|
int nextLocal = ref.getNumberOfParameters() + 2;
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory();
|
SSAInstructionFactory insts = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType().getClassLoader().getInstructionFactory();
|
||||||
if (cls != null) {
|
if (cls != null) {
|
||||||
for (IMethod m : returnValues) {
|
for (IMethod m : returnValues) {
|
||||||
int c = nextLocal++;
|
int c = nextLocal++;
|
||||||
|
@ -356,8 +359,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
/**
|
/**
|
||||||
* create statements for getConstructor()
|
* create statements for getConstructor()
|
||||||
*/
|
*/
|
||||||
private static SSAInstruction[] makeGetCtorStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
|
private static SSAInstruction[] makeGetCtorStatements(Context context, Map<Integer, ConstantValue> constants) {
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return getParticularMethodStatements(GET_CONSTRUCTOR, null, context, constants);
|
return getParticularMethodStatements(GET_CONSTRUCTOR, null, context, constants);
|
||||||
} else {
|
} else {
|
||||||
|
@ -366,8 +369,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
private static SSAInstruction[] makeGetCtorsStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
|
private static SSAInstruction[] makeGetCtorsStatements(Context context, Map<Integer, ConstantValue> constants) {
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return getMethodArrayStatements(GET_DECLARED_CONSTRUCTORS, null, context, constants);
|
return getMethodArrayStatements(GET_DECLARED_CONSTRUCTORS, null, context, constants);
|
||||||
} else {
|
} else {
|
||||||
|
@ -375,8 +378,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SSAInstruction[] makeGetMethodStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
|
private static SSAInstruction[] makeGetMethodStatements(Context context, Map<Integer, ConstantValue> constants) {
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return getParticularMethodStatements(GET_METHOD, null, context, constants);
|
return getParticularMethodStatements(GET_METHOD, null, context, constants);
|
||||||
} else {
|
} else {
|
||||||
|
@ -384,8 +387,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SSAInstruction[] makeGetMethodsStatments(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
|
private static SSAInstruction[] makeGetMethodsStatments(Context context, Map<Integer, ConstantValue> constants) {
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return getMethodArrayStatements(GET_METHODS, null, context, constants);
|
return getMethodArrayStatements(GET_METHODS, null, context, constants);
|
||||||
} else {
|
} else {
|
||||||
|
@ -396,8 +399,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
/**
|
/**
|
||||||
* create statements for getConstructor()
|
* create statements for getConstructor()
|
||||||
*/
|
*/
|
||||||
private static SSAInstruction[] makeGetDeclCtorStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
|
private static SSAInstruction[] makeGetDeclCtorStatements(Context context, Map<Integer, ConstantValue> constants) {
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return getParticularMethodStatements(GET_DECLARED_CONSTRUCTOR, null, context, constants);
|
return getParticularMethodStatements(GET_DECLARED_CONSTRUCTOR, null, context, constants);
|
||||||
} else {
|
} else {
|
||||||
|
@ -405,8 +408,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SSAInstruction[] makeGetDeclCtorsStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
|
private static SSAInstruction[] makeGetDeclCtorsStatements(Context context, Map<Integer, ConstantValue> constants) {
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return getMethodArrayStatements(GET_DECLARED_CONSTRUCTORS, null, context, constants);
|
return getMethodArrayStatements(GET_DECLARED_CONSTRUCTORS, null, context, constants);
|
||||||
} else {
|
} else {
|
||||||
|
@ -417,8 +420,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
/**
|
/**
|
||||||
* create statements for getDeclaredMethod()
|
* create statements for getDeclaredMethod()
|
||||||
*/
|
*/
|
||||||
private static SSAInstruction[] makeGetDeclaredMethodStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
|
private static SSAInstruction[] makeGetDeclaredMethodStatements(Context context, Map<Integer, ConstantValue> constants) {
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return getParticularMethodStatements(GET_DECLARED_METHOD, null, context, constants);
|
return getParticularMethodStatements(GET_DECLARED_METHOD, null, context, constants);
|
||||||
} else {
|
} else {
|
||||||
|
@ -429,8 +432,8 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
||||||
/**
|
/**
|
||||||
* create statements for getDeclaredMethod()
|
* create statements for getDeclaredMethod()
|
||||||
*/
|
*/
|
||||||
private static SSAInstruction[] makeGetDeclaredMethodsStatements(JavaTypeContext context, Map<Integer, ConstantValue> constants) {
|
private static SSAInstruction[] makeGetDeclaredMethodsStatements(Context context, Map<Integer, ConstantValue> constants) {
|
||||||
IClass cls = context.getType().getType();
|
IClass cls = ((TypeAbstraction)context.get(ContextKey.RECEIVER)).getType();
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return getMethodArrayStatements(GET_DECLARED_METHODS, null, context, constants);
|
return getMethodArrayStatements(GET_DECLARED_METHODS, null, context, constants);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -20,6 +20,8 @@ import com.ibm.wala.classLoader.IClass;
|
||||||
import com.ibm.wala.classLoader.IMethod;
|
import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.classLoader.NewSiteReference;
|
import com.ibm.wala.classLoader.NewSiteReference;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
|
import com.ibm.wala.ipa.callgraph.Context;
|
||||||
|
import com.ibm.wala.ipa.callgraph.ContextKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.ConstantKey;
|
import com.ibm.wala.ipa.callgraph.propagation.ConstantKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.ReceiverInstanceContext;
|
import com.ibm.wala.ipa.callgraph.propagation.ReceiverInstanceContext;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||||
|
@ -69,8 +71,8 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
System.err.println("generating IR for " + node);
|
System.err.println("generating IR for " + node);
|
||||||
}
|
}
|
||||||
ReceiverInstanceContext recv = (ReceiverInstanceContext) node.getContext();
|
Context recv = node.getContext();
|
||||||
ConstantKey c = (ConstantKey) recv.getReceiver();
|
ConstantKey c = (ConstantKey) recv.get(ContextKey.RECEIVER);
|
||||||
IMethod m = (IMethod) c.getValue();
|
IMethod m = (IMethod) c.getValue();
|
||||||
/** BEGIN Custom change: caching */
|
/** BEGIN Custom change: caching */
|
||||||
final IMethod method = node.getMethod();
|
final IMethod method = node.getMethod();
|
||||||
|
@ -109,11 +111,11 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
throw new IllegalArgumentException("node is null");
|
throw new IllegalArgumentException("node is null");
|
||||||
}
|
}
|
||||||
if (!(node.getContext() instanceof ReceiverInstanceContext)) {
|
if (!(node.getContext().isA(ReceiverInstanceContext.class))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ReceiverInstanceContext r = (ReceiverInstanceContext) node.getContext();
|
Context r = node.getContext();
|
||||||
if (!(r.getReceiver() instanceof ConstantKey)) {
|
if (!(r.get(ContextKey.RECEIVER) instanceof ConstantKey)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return node.getMethod().getReference().equals(METHOD_INVOKE) || node.getMethod().getReference().equals(CTOR_NEW_INSTANCE);
|
return node.getMethod().getReference().equals(METHOD_INVOKE) || node.getMethod().getReference().equals(CTOR_NEW_INSTANCE);
|
||||||
|
@ -146,7 +148,7 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret
|
||||||
* @param method is something like Method.invoke or Construction.newInstance
|
* @param method is something like Method.invoke or Construction.newInstance
|
||||||
* @param target is the method being called reflectively
|
* @param target is the method being called reflectively
|
||||||
*/
|
*/
|
||||||
private IR makeIR(IMethod method, IMethod target, ReceiverInstanceContext context) {
|
private IR makeIR(IMethod method, IMethod target, Context recv) {
|
||||||
SSAInstructionFactory insts = method.getDeclaringClass().getClassLoader().getInstructionFactory();
|
SSAInstructionFactory insts = method.getDeclaringClass().getClassLoader().getInstructionFactory();
|
||||||
|
|
||||||
SpecializedMethod m = new SpecializedMethod(method, method.getDeclaringClass(), method.isStatic(), false);
|
SpecializedMethod m = new SpecializedMethod(method, method.getDeclaringClass(), method.isStatic(), false);
|
||||||
|
@ -225,7 +227,7 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret
|
||||||
SSAInstruction[] instrs = new SSAInstruction[m.allInstructions.size()];
|
SSAInstruction[] instrs = new SSAInstruction[m.allInstructions.size()];
|
||||||
m.allInstructions.<SSAInstruction> toArray(instrs);
|
m.allInstructions.<SSAInstruction> toArray(instrs);
|
||||||
|
|
||||||
return new SyntheticIR(method, context, new InducedCFG(instrs, method, context), instrs, SSAOptions.defaultOptions(), constants);
|
return new SyntheticIR(method, recv, new InducedCFG(instrs, method, recv), instrs, SSAOptions.defaultOptions(), constants);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -55,6 +55,7 @@ import com.ibm.wala.util.collections.HashMapFactory;
|
||||||
import com.ibm.wala.util.collections.MapIterator;
|
import com.ibm.wala.util.collections.MapIterator;
|
||||||
import com.ibm.wala.util.intset.IntSet;
|
import com.ibm.wala.util.intset.IntSet;
|
||||||
import com.ibm.wala.util.intset.IntSetUtil;
|
import com.ibm.wala.util.intset.IntSetUtil;
|
||||||
|
import com.ibm.wala.util.intset.MutableIntSet;
|
||||||
|
|
||||||
public class MethodHandles {
|
public class MethodHandles {
|
||||||
|
|
||||||
|
@ -270,7 +271,9 @@ public class MethodHandles {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) {
|
public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) {
|
||||||
return isFindStatic(site.getDeclaredTarget())? params: self;
|
MutableIntSet x = IntSetUtil.makeMutableCopy(base.getRelevantParameters(caller, site));
|
||||||
|
x.addAll(isFindStatic(site.getDeclaredTarget())? params: self);
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +395,7 @@ public class MethodHandles {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean understands(CGNode node) {
|
public boolean understands(CGNode node) {
|
||||||
return isFindStatic(node) && node.getContext() instanceof FindContext;
|
return isFindStatic(node) && node.getContext().isA(FindContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -401,7 +404,7 @@ public class MethodHandles {
|
||||||
MethodSummary code = new MethodSummary(node.getMethod().getReference());
|
MethodSummary code = new MethodSummary(node.getMethod().getReference());
|
||||||
SummarizedMethod m = new SummarizedMethod(node.getMethod().getReference(), code, node.getMethod().getDeclaringClass());
|
SummarizedMethod m = new SummarizedMethod(node.getMethod().getReference(), code, node.getMethod().getDeclaringClass());
|
||||||
SSAInstructionFactory insts = node.getMethod().getDeclaringClass().getClassLoader().getLanguage().instructionFactory();
|
SSAInstructionFactory insts = node.getMethod().getDeclaringClass().getClassLoader().getLanguage().instructionFactory();
|
||||||
assert node.getContext() instanceof FindContext;
|
assert node.getContext().isA(FindContext.class);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
IClass cls = node.getClassHierarchy().lookupClass(((HandlesItem<TypeReference>)node.getContext().get(CLASS_KEY)).item);
|
IClass cls = node.getClassHierarchy().lookupClass(((HandlesItem<TypeReference>)node.getContext().get(CLASS_KEY)).item);
|
||||||
|
@ -427,7 +430,7 @@ public class MethodHandles {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean understands(CGNode node) {
|
public boolean understands(CGNode node) {
|
||||||
return (isInvoke(node) || isType(node)) && node.getContext() instanceof MethodContext;
|
return (isInvoke(node) || isType(node)) && node.getContext().isA(MethodContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -436,7 +439,7 @@ public class MethodHandles {
|
||||||
MethodSummary code = new MethodSummary(node.getMethod().getReference());
|
MethodSummary code = new MethodSummary(node.getMethod().getReference());
|
||||||
SummarizedMethod m = new SummarizedMethod(node.getMethod().getReference(), code, node.getMethod().getDeclaringClass());
|
SummarizedMethod m = new SummarizedMethod(node.getMethod().getReference(), code, node.getMethod().getDeclaringClass());
|
||||||
SSAInstructionFactory insts = node.getMethod().getDeclaringClass().getClassLoader().getLanguage().instructionFactory();
|
SSAInstructionFactory insts = node.getMethod().getDeclaringClass().getClassLoader().getLanguage().instructionFactory();
|
||||||
assert node.getContext() instanceof MethodContext;
|
assert node.getContext().isA(MethodContext.class);
|
||||||
MethodReference ref = ((MethodContext)node.getContext()).method;
|
MethodReference ref = ((MethodContext)node.getContext()).method;
|
||||||
boolean isStatic = node.getClassHierarchy().resolveMethod(ref).isStatic();
|
boolean isStatic = node.getClassHierarchy().resolveMethod(ref).isStatic();
|
||||||
boolean isVoid = ref.getReturnType().equals(TypeReference.Void);
|
boolean isVoid = ref.getReturnType().equals(TypeReference.Void);
|
||||||
|
|
|
@ -74,6 +74,7 @@ public class AnalysisOptions {
|
||||||
ONE_FLOW_TO_CASTS_APPLICATION_GET_METHOD("one_flow_to_casts_application_get_method", 1, false, false, true),
|
ONE_FLOW_TO_CASTS_APPLICATION_GET_METHOD("one_flow_to_casts_application_get_method", 1, false, false, true),
|
||||||
MULTI_FLOW_TO_CASTS_APPLICATION_GET_METHOD("multi_flow_to_casts_application_get_method", 100, false, false, true),
|
MULTI_FLOW_TO_CASTS_APPLICATION_GET_METHOD("multi_flow_to_casts_application_get_method", 100, false, false, true),
|
||||||
NO_STRING_CONSTANTS("no_string_constants", Integer.MAX_VALUE, false, true, false),
|
NO_STRING_CONSTANTS("no_string_constants", Integer.MAX_VALUE, false, true, false),
|
||||||
|
STRING_ONLY("string_constants", 0, true, false, true),
|
||||||
NONE("none", 0, true, true, true);
|
NONE("none", 0, true, true, true);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
|
@ -18,9 +18,16 @@ package com.ibm.wala.ipa.callgraph;
|
||||||
* As another example, for CPA, there would be name for each parameter slot ("zero","one","two"), and the Context provides a mapping
|
* As another example, for CPA, there would be name for each parameter slot ("zero","one","two"), and the Context provides a mapping
|
||||||
* from this name to a set of types. eg. "one" -> {java.lang.String, java.lang.Date}
|
* from this name to a set of types. eg. "one" -> {java.lang.String, java.lang.Date}
|
||||||
*/
|
*/
|
||||||
public interface Context {
|
public interface Context extends ContextItem {
|
||||||
/**
|
/**
|
||||||
* @return the objects corresponding to a given name
|
* @return the objects corresponding to a given name
|
||||||
*/
|
*/
|
||||||
ContextItem get(ContextKey name);
|
ContextItem get(ContextKey name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return whether this context has a specific type
|
||||||
|
*/
|
||||||
|
default boolean isA(Class<? extends Context> type) {
|
||||||
|
return type.isInstance(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,18 @@ public interface ContextKey {
|
||||||
public final static ContextKey CALLER = new ContextKey() {
|
public final static ContextKey CALLER = new ContextKey() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A property of contexts that might be generally useful: the "target" method.
|
||||||
|
*/
|
||||||
|
public final static ContextKey TARGET = new ContextKey() {
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A property of contexts that might be generally useful: the "name".
|
||||||
|
*/
|
||||||
|
public final static ContextKey NAME = new ContextKey() {
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A property of contexts that might be generally useful: the "call site" method ... used for call-string context schemes.
|
* A property of contexts that might be generally useful: the "call site" method ... used for call-string context schemes.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -70,6 +70,9 @@ public class DelegatingContext implements Context {
|
||||||
return "DelegatingContext [A=" + A + ", B=" + B + "]";
|
return "DelegatingContext [A=" + A + ", B=" + B + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isA(Class<? extends Context> type) {
|
||||||
|
return A.isA(type) || B.isA(type);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,14 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.ibm.wala.analysis.reflection.JavaTypeContext;
|
import com.ibm.wala.analysis.reflection.JavaTypeContext;
|
||||||
|
import com.ibm.wala.analysis.typeInference.TypeAbstraction;
|
||||||
import com.ibm.wala.classLoader.CallSiteReference;
|
import com.ibm.wala.classLoader.CallSiteReference;
|
||||||
import com.ibm.wala.classLoader.IMethod;
|
import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||||
import com.ibm.wala.ipa.callgraph.Context;
|
import com.ibm.wala.ipa.callgraph.Context;
|
||||||
|
import com.ibm.wala.ipa.callgraph.ContextKey;
|
||||||
|
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.ReceiverInstanceContext;
|
import com.ibm.wala.ipa.callgraph.propagation.ReceiverInstanceContext;
|
||||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||||
import com.ibm.wala.shrikeBT.IInvokeInstruction;
|
import com.ibm.wala.shrikeBT.IInvokeInstruction;
|
||||||
|
@ -369,10 +372,10 @@ public abstract class BasicCallGraph<T> extends AbstractNumberedGraph<CGNode> im
|
||||||
for(CGNode n : this) {
|
for(CGNode n : this) {
|
||||||
String nm = n.getMethod().getDeclaringClass().getName().toString() + "/" + n.getMethod().getName() + "/" + n.getContext().getClass().toString();
|
String nm = n.getMethod().getDeclaringClass().getName().toString() + "/" + n.getMethod().getName() + "/" + n.getContext().getClass().toString();
|
||||||
|
|
||||||
if (n.getContext() instanceof ReceiverInstanceContext) {
|
if (n.getContext().isA(ReceiverInstanceContext.class)) {
|
||||||
nm = nm + "/" + ((ReceiverInstanceContext)n.getContext()).getReceiver().getConcreteType().getName();
|
nm = nm + "/" + ((InstanceKey)n.getContext().get(ContextKey.RECEIVER)).getConcreteType().getName();
|
||||||
} else if (n.getContext() instanceof JavaTypeContext) {
|
} else if (n.getContext() instanceof JavaTypeContext) {
|
||||||
nm = nm + "/" + ((JavaTypeContext)n.getContext()).getType().getTypeReference().getName();
|
nm = nm + "/" + ((TypeAbstraction)n.getContext().get(ContextKey.RECEIVER)).getTypeReference().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
import com.ibm.wala.ipa.callgraph.Context;
|
import com.ibm.wala.ipa.callgraph.Context;
|
||||||
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
||||||
|
import com.ibm.wala.ipa.callgraph.DelegatingContext;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||||
import com.ibm.wala.util.intset.IntSet;
|
import com.ibm.wala.util.intset.IntSet;
|
||||||
|
|
||||||
|
@ -56,9 +57,14 @@ public class DelegatingContextSelector implements ContextSelector {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
System.err.println(("Case A " + A.getClass() + " " + C));
|
System.err.println(("Case A " + A.getClass() + " " + C));
|
||||||
}
|
}
|
||||||
|
Context CB = B.getCalleeTarget(caller, site, callee, receiver);
|
||||||
|
if (CB != null) {
|
||||||
|
return new DelegatingContext(C, CB);
|
||||||
|
} else {
|
||||||
return C;
|
return C;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Context C = B.getCalleeTarget(caller, site, callee, receiver);
|
Context C = B.getCalleeTarget(caller, site, callee, receiver);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
System.err.println(("Case B " + B.getClass() + " " + C));
|
System.err.println(("Case B " + B.getClass() + " " + C));
|
||||||
|
|
|
@ -75,7 +75,8 @@ public class AllocationSiteInNodeFactory implements InstanceKeyFactory {
|
||||||
CGNode nodeToUse = node;
|
CGNode nodeToUse = node;
|
||||||
|
|
||||||
// disallow recursion in contexts.
|
// disallow recursion in contexts.
|
||||||
if (node.getContext() instanceof ReceiverInstanceContext || node.getContext() instanceof CallerContext) {
|
if (node.getContext().isA(ReceiverInstanceContext.class) ||
|
||||||
|
node.getContext().isA(CallerContext.class)) {
|
||||||
IMethod m = node.getMethod();
|
IMethod m = node.getMethod();
|
||||||
CGNode n = ContainerContextSelector.findNodeRecursiveMatchingContext(m, node.getContext());
|
CGNode n = ContainerContextSelector.findNodeRecursiveMatchingContext(m, node.getContext());
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
|
|
|
@ -720,7 +720,7 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder<In
|
||||||
}
|
}
|
||||||
Context targetContext = contextSelector.getCalleeTarget(caller, site, targetMethod, iKey);
|
Context targetContext = contextSelector.getCalleeTarget(caller, site, targetMethod, iKey);
|
||||||
|
|
||||||
if (targetContext instanceof IllegalArgumentExceptionContext) {
|
if (targetContext.isA(IllegalArgumentExceptionContext.class)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class SmushedAllocationSiteInstanceKeys implements InstanceKeyFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
// disallow recursion in contexts.
|
// disallow recursion in contexts.
|
||||||
if (node.getContext() instanceof ReceiverInstanceContext) {
|
if (node.getContext().isA(ReceiverInstanceContext.class)) {
|
||||||
IMethod m = node.getMethod();
|
IMethod m = node.getMethod();
|
||||||
CGNode n = ContainerContextSelector.findNodeRecursiveMatchingContext(m, node.getContext());
|
CGNode n = ContainerContextSelector.findNodeRecursiveMatchingContext(m, node.getContext());
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
|
|
|
@ -51,6 +51,8 @@ public class TargetMethodContextSelector implements ContextSelector {
|
||||||
public ContextItem get(ContextKey name) {
|
public ContextItem get(ContextKey name) {
|
||||||
if (name.equals(ContextKey.PARAMETERS[0])) {
|
if (name.equals(ContextKey.PARAMETERS[0])) {
|
||||||
return new FilteredPointerKey.TargetMethodFilter(M);
|
return new FilteredPointerKey.TargetMethodFilter(M);
|
||||||
|
} else if (name.equals(ContextKey.TARGET)) {
|
||||||
|
return M;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +70,9 @@ public class TargetMethodContextSelector implements ContextSelector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
return (o instanceof MethodDispatchContext) && ((MethodDispatchContext) o).getTargetMethod().equals(M);
|
return (o instanceof Context) &&
|
||||||
|
((Context)o).isA(MethodDispatchContext.class) &&
|
||||||
|
((Context)o).get(ContextKey.TARGET).equals(M);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,9 @@ public class CallStringContext implements Context {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
return (o instanceof CallStringContext) && ((CallStringContext) o).cs.equals(cs);
|
return (o instanceof Context) &&
|
||||||
|
((Context)o).isA(CallStringContext.class) &&
|
||||||
|
((Context)o).get(CallStringContextSelector.CALL_STRING).equals(cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,6 +30,13 @@ public abstract class CallStringContextSelector implements ContextSelector {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static final ContextKey BASE = new ContextKey() {
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "BASE_KEY";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public static class CallStringContextPair implements Context {
|
public static class CallStringContextPair implements Context {
|
||||||
private final CallString cs;
|
private final CallString cs;
|
||||||
|
|
||||||
|
@ -42,8 +49,10 @@ public abstract class CallStringContextSelector implements ContextSelector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
return (o instanceof CallStringContextPair) && ((CallStringContextPair) o).cs.equals(cs)
|
return o instanceof Context &&
|
||||||
&& ((CallStringContextPair) o).base.equals(base);
|
((Context)o).isA(CallStringContextPair.class) &&
|
||||||
|
((Context)o).get(CALL_STRING).equals(cs) &&
|
||||||
|
((Context)o).get(BASE).equals(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,6 +69,8 @@ public abstract class CallStringContextSelector implements ContextSelector {
|
||||||
public ContextItem get(ContextKey name) {
|
public ContextItem get(ContextKey name) {
|
||||||
if (CALL_STRING.equals(name)) {
|
if (CALL_STRING.equals(name)) {
|
||||||
return cs;
|
return cs;
|
||||||
|
} else if (BASE.equals(name)) {
|
||||||
|
return base;
|
||||||
} else {
|
} else {
|
||||||
return base.get(name);
|
return base.get(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import com.ibm.wala.classLoader.IClass;
|
||||||
import com.ibm.wala.classLoader.IMethod;
|
import com.ibm.wala.classLoader.IMethod;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
import com.ibm.wala.ipa.callgraph.Context;
|
import com.ibm.wala.ipa.callgraph.Context;
|
||||||
|
import com.ibm.wala.ipa.callgraph.ContextKey;
|
||||||
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.AllocationSiteInNode;
|
import com.ibm.wala.ipa.callgraph.propagation.AllocationSiteInNode;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.ContainerUtil;
|
import com.ibm.wala.ipa.callgraph.propagation.ContainerUtil;
|
||||||
|
@ -232,21 +233,20 @@ public class ContainerContextSelector implements ContextSelector {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
System.err.println("findNodeRecursiveMatchingContext " + m + " in context " + c);
|
System.err.println("findNodeRecursiveMatchingContext " + m + " in context " + c);
|
||||||
}
|
}
|
||||||
if (c instanceof ReceiverInstanceContext) {
|
if (c.isA(ReceiverInstanceContext.class)) {
|
||||||
ReceiverInstanceContext ric = (ReceiverInstanceContext) c;
|
InstanceKey receiver = (InstanceKey) c.get(ContextKey.RECEIVER);
|
||||||
if (!(ric.getReceiver() instanceof AllocationSiteInNode)) {
|
if (!(receiver instanceof AllocationSiteInNode)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
AllocationSiteInNode i = (AllocationSiteInNode) ric.getReceiver();
|
AllocationSiteInNode i = (AllocationSiteInNode) receiver;
|
||||||
CGNode n = i.getNode();
|
CGNode n = i.getNode();
|
||||||
if (n.getMethod().equals(m)) {
|
if (n.getMethod().equals(m)) {
|
||||||
return n;
|
return n;
|
||||||
} else {
|
} else {
|
||||||
return findNodeRecursiveMatchingContext(m, n.getContext());
|
return findNodeRecursiveMatchingContext(m, n.getContext());
|
||||||
}
|
}
|
||||||
} else if (c instanceof CallerContext) {
|
} else if (c.isA(CallerContext.class)) {
|
||||||
CallerContext cc = (CallerContext) c;
|
CGNode n = (CGNode) c.get(ContextKey.CALLER);
|
||||||
CGNode n = cc.getCaller();
|
|
||||||
if (n.getMethod().equals(m)) {
|
if (n.getMethod().equals(m)) {
|
||||||
return n;
|
return n;
|
||||||
} else {
|
} else {
|
||||||
|
@ -320,7 +320,7 @@ public class ContainerContextSelector implements ContextSelector {
|
||||||
if (receiver instanceof AllocationSiteInNode) {
|
if (receiver instanceof AllocationSiteInNode) {
|
||||||
AllocationSiteInNode I = (AllocationSiteInNode) receiver;
|
AllocationSiteInNode I = (AllocationSiteInNode) receiver;
|
||||||
CGNode N = I.getNode();
|
CGNode N = I.getNode();
|
||||||
if (N.getContext() instanceof ReceiverInstanceContext) {
|
if (N.getContext().isA(ReceiverInstanceContext.class)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,13 @@ public class DefaultPointerKeyFactory implements PointerKeyFactory {
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
throw new IllegalArgumentException("field is null");
|
throw new IllegalArgumentException("field is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IField resolveAgain = I.getConcreteType().getField(field.getName(), field.getFieldTypeReference().getName());
|
||||||
|
if (resolveAgain != null) {
|
||||||
|
field = resolveAgain;
|
||||||
|
}
|
||||||
|
|
||||||
return new InstanceFieldKey(I, field);
|
return new InstanceFieldKey(I, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class SummarizedMethodWithNames extends SummarizedMethod {
|
||||||
@Override
|
@Override
|
||||||
public String[] getLocalNames(int index, int vn) {
|
public String[] getLocalNames(int index, int vn) {
|
||||||
if (DEBUG) { System.err.printf("IR.getLocalNames({}, {})", index, vn); }
|
if (DEBUG) { System.err.printf("IR.getLocalNames({}, {})", index, vn); }
|
||||||
if (this.localNames.containsKey(vn)) {
|
if (localNames != null && localNames.containsKey(vn)) {
|
||||||
return new String[] { this.localNames.get(vn).toString() };
|
return new String[] { this.localNames.get(vn).toString() };
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -757,11 +757,14 @@ public class XMLMethodSummaryReader implements BytecodeConstants {
|
||||||
if (refNumber == null) {
|
if (refNumber == null) {
|
||||||
Assertions.UNREACHABLE("Cannot lookup value: " + R);
|
Assertions.UNREACHABLE("Cannot lookup value: " + R);
|
||||||
}
|
}
|
||||||
// N.B: we currently ignore the index
|
|
||||||
String I = atts.getValue(A_INDEX);
|
String I = atts.getValue(A_INDEX);
|
||||||
if (I == null) {
|
if (I == null) {
|
||||||
Assertions.UNREACHABLE("Must specify index for aaload " + governingMethod);
|
Assertions.UNREACHABLE("Must specify index for aaload " + governingMethod);
|
||||||
}
|
}
|
||||||
|
Integer idxNumber = symbolTable.get(I);
|
||||||
|
if (idxNumber == null) {
|
||||||
|
Assertions.UNREACHABLE("Cannot lookup value: " + I);
|
||||||
|
}
|
||||||
String strType = atts.getValue(A_TYPE);
|
String strType = atts.getValue(A_TYPE);
|
||||||
TypeReference type;
|
TypeReference type;
|
||||||
if (strType == null) {
|
if (strType == null) {
|
||||||
|
@ -779,8 +782,7 @@ public class XMLMethodSummaryReader implements BytecodeConstants {
|
||||||
}
|
}
|
||||||
int defNum = nextLocal;
|
int defNum = nextLocal;
|
||||||
symbolTable.put(defVar, Integer.valueOf(nextLocal++));
|
symbolTable.put(defVar, Integer.valueOf(nextLocal++));
|
||||||
SSAArrayLoadInstruction S = insts.ArrayLoadInstruction(governingMethod.getNumberOfStatements(), defNum, refNumber.intValue(), 0,
|
SSAArrayLoadInstruction S = insts.ArrayLoadInstruction(governingMethod.getNumberOfStatements(), defNum, refNumber, idxNumber, type);
|
||||||
type);
|
|
||||||
governingMethod.addStatement(S);
|
governingMethod.addStatement(S);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,13 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
|
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
|
||||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
|
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class APKCallGraphDriver {
|
||||||
return "timeout";
|
return "timeout";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CG = DalvikCallGraphTestBase.makeAPKCallGraph(libs(), null, apk1.getAbsolutePath(), pm, ReflectionOptions.NONE);
|
CG = DalvikCallGraphTestBase.makeAPKCallGraph(null, Util.androidJavaLib(), apk1.getAbsolutePath(), pm, ReflectionOptions.NONE);
|
||||||
System.err.println("Analyzed " + apk1 + " in " + (System.currentTimeMillis() - time));
|
System.err.println("Analyzed " + apk1 + " in " + (System.currentTimeMillis() - time));
|
||||||
|
|
||||||
System.err.println(new SDG<>(CG.fst, CG.snd, DataDependenceOptions.NO_BASE_NO_HEAP_NO_EXCEPTIONS, ControlDependenceOptions.NONE));
|
System.err.println(new SDG<>(CG.fst, CG.snd, DataDependenceOptions.NO_BASE_NO_HEAP_NO_EXCEPTIONS, ControlDependenceOptions.NONE));
|
||||||
|
|
|
@ -108,6 +108,7 @@ public abstract class Invoke extends Instruction {
|
||||||
String clazzName, String methodName, String descriptor,
|
String clazzName, String methodName, String descriptor,
|
||||||
int[] args, Opcode opcode, DexIMethod method) {
|
int[] args, Opcode opcode, DexIMethod method) {
|
||||||
super(instLoc, clazzName, methodName, descriptor, args, opcode, method);
|
super(instLoc, clazzName, methodName, descriptor, args, opcode, method);
|
||||||
|
assert descriptor.contains("(");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -788,7 +788,6 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
|
||||||
|
|
||||||
Language lang = dexCFG.getMethod().getDeclaringClass().getClassLoader().getLanguage();
|
Language lang = dexCFG.getMethod().getDeclaringClass().getClassLoader().getLanguage();
|
||||||
// TODO: check that the signature needed by findOrCreate can use the descriptor
|
// TODO: check that the signature needed by findOrCreate can use the descriptor
|
||||||
|
|
||||||
MethodReference m = MethodReference.findOrCreate(lang, loader, instruction.clazzName, instruction.methodName, instruction.descriptor);
|
MethodReference m = MethodReference.findOrCreate(lang, loader, instruction.clazzName, instruction.methodName, instruction.descriptor);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
|
@ -9,8 +9,13 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.APILeak=warning
|
org.eclipse.jdt.core.compiler.problem.APILeak=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
|
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
|
Loading…
Reference in New Issue