fix potential NPE in AbstractRootMethod.addAllocation()
This commit is contained in:
parent
97cae29368
commit
f439646cb1
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue