fix potential NPE in AbstractRootMethod.addAllocation()

This commit is contained in:
Manu Sridharan 2013-04-15 08:58:42 +02:00
parent 97cae29368
commit f439646cb1
2 changed files with 11 additions and 2 deletions

View File

@ -243,7 +243,16 @@ public class ArrayClass implements IClass, Constants {
}
public int getDimensionality() {
int mask = getReference().getDerivedMask();
return getArrayTypeDimensionality(getReference());
}
/**
*
* @param reference a type reference for an array type
* @return the dimensionality of the array
*/
public static int getArrayTypeDimensionality(TypeReference reference) {
int mask = reference.getDerivedMask();
if ((mask&PrimitiveMask) == PrimitiveMask) {
mask >>= ElementBits;
}

View File

@ -207,7 +207,7 @@ public abstract class AbstractRootMethod extends SyntheticMethod {
if (T.isReferenceType()) {
NewSiteReference ref = NewSiteReference.make(statements.size(), T);
if (T.isArrayType()) {
int[] sizes = new int[((ArrayClass)cha.lookupClass(T)).getDimensionality()];
int[] sizes = new int[ArrayClass.getArrayTypeDimensionality(T)];
Arrays.fill(sizes, getValueNumberForIntConstant(1));
result = insts.NewInstruction(instance, ref, sizes);
} else {