use of org.apache.bcel.generic.Type in project jop by jop-devel.
the class SymbolicPointsTo method initial.
public ContextMap<CallString, SymbolicAddressMap> initial(InstructionHandle stmt) {
ContextMap<CallString, SymbolicAddressMap> retval = new ContextMap<CallString, SymbolicAddressMap>(new Context(), new HashMap<CallString, SymbolicAddressMap>());
SymbolicAddressMap init = new SymbolicAddressMap(bsFactory);
// Add symbolic stack names
int stackPtr = 0;
if (!entryMethod.isStatic()) {
init.putStack(stackPtr++, bsFactory.singleton(SymbolicAddress.rootAddress("$this")));
}
String[] args = entryMethod.getArgumentNames();
for (int i = 0; i < args.length; i++) {
Type ty = entryMethod.getArgumentType(i);
if (ty instanceof ReferenceType) {
init.putStack(stackPtr, bsFactory.singleton(SymbolicAddress.rootAddress("$" + args[i])));
}
stackPtr += ty.getSize();
}
retval.put(initialCallString, init);
return retval;
}
use of org.apache.bcel.generic.Type in project contribution by checkstyle.
the class JavaClassDefinition method hasReference.
/**
* Determines whether there is reference to a given Method in this JavaClass
* definition or a definition in a superclass.
* @param aMethodDef the Method to check.
* @param aReferenceDAO reference DAO.
* @return true if there is a reference to the method of aMethodDef in
* this JavaClass or a superclass.
*/
public boolean hasReference(MethodDefinition aMethodDef, ReferenceDAO aReferenceDAO) {
final String methodName = aMethodDef.getName();
final Type[] argTypes = aMethodDef.getArgumentTypes();
// search the inheritance hierarchy
JavaClass currentJavaClass = getJavaClass();
while (currentJavaClass != null) {
final JavaClassDefinition javaClassDef = aReferenceDAO.findJavaClassDef(currentJavaClass);
if (javaClassDef != null) {
final MethodDefinition methodDef = javaClassDef.findNarrowestMethod(getJavaClass().getClassName(), methodName, argTypes);
if ((methodDef != null) && (methodDef.hasReference(getJavaClass()))) {
return true;
}
}
currentJavaClass = currentJavaClass.getSuperClass();
}
return false;
}
use of org.apache.bcel.generic.Type in project fb-contrib by mebigfatguy.
the class SloppyClassReflection method sawOpcode.
/**
* overrides the visitor to find class loading that is non obfuscation proof
*
* @param seen
* the opcode that is being visited
*/
@Override
public void sawOpcode(int seen) {
switch(state) {
case COLLECT:
if ((seen == INVOKESTATIC) || (seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE) || (seen == INVOKESPECIAL)) {
refClasses.add(getClassConstantOperand());
String signature = getSigConstantOperand();
Type[] argTypes = Type.getArgumentTypes(signature);
for (Type t : argTypes) {
addType(t);
}
Type resultType = Type.getReturnType(signature);
addType(resultType);
}
break;
case SEEN_NOTHING:
if ((seen == LDC) || (seen == LDC_W)) {
Constant c = getConstantRefOperand();
if (c instanceof ConstantString) {
clsName = ((ConstantString) c).getBytes(getConstantPool());
state = State.SEEN_LDC;
}
}
break;
case SEEN_LDC:
if ((seen == INVOKESTATIC) && "forName".equals(getNameConstantOperand()) && "java/lang/Class".equals(getClassConstantOperand()) && refClasses.contains(clsName)) {
bugReporter.reportBug(new BugInstance(this, BugType.SCR_SLOPPY_CLASS_REFLECTION.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this));
}
state = State.SEEN_NOTHING;
break;
}
}
use of org.apache.bcel.generic.Type in project fb-contrib by mebigfatguy.
the class SloppyClassReflection method visitMethod.
/**
* overrides the visitor reset the opcode stack
*
* @param obj
* the method object of the currently parsed method
*/
@Override
public void visitMethod(Method obj) {
if (Values.STATIC_INITIALIZER.equals(obj.getName())) {
return;
}
if (state == State.COLLECT) {
Type[] argTypes = obj.getArgumentTypes();
for (Type t : argTypes) {
addType(t);
}
Type resultType = obj.getReturnType();
addType(resultType);
LocalVariableTable lvt = obj.getLocalVariableTable();
if (lvt != null) {
LocalVariable[] lvs = lvt.getLocalVariableTable();
if (lvs != null) {
for (LocalVariable lv : lvs) {
if (lv != null) {
Type t = Type.getType(lv.getSignature());
addType(t);
}
}
}
}
} else {
state = State.SEEN_NOTHING;
}
super.visitMethod(obj);
}
use of org.apache.bcel.generic.Type in project fb-contrib by mebigfatguy.
the class SignatureUtils method getFirstRegisterSlot.
/**
* returns the first open register slot after parameters
*
* @param m
* the method for which you want the parameters
* @return the first available register slot
*/
public static int getFirstRegisterSlot(Method m) {
Type[] parms = m.getArgumentTypes();
int first = m.isStatic() ? 0 : 1;
for (Type t : parms) {
first += getSignatureSize(t.getSignature());
}
return first;
}
Aggregations