/** Checks if the constraints of operands of the said instruction(s) are satisfied. */ public void visitMULTIANEWARRAY(MULTIANEWARRAY o){ indexValid(o, o.getIndex()); Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)){ constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'."); } int dimensions2create = o.getDimensions(); if (dimensions2create < 1){ constraintViolated(o, "Number of dimensions to create must be greater than zero."); } Type t = o.getType(cpg); if (t instanceof ArrayType){ int dimensions = ((ArrayType) t).getDimensions(); if (dimensions < dimensions2create){ constraintViolated(o, "Not allowed to create array with more dimensions ('+dimensions2create+') than the one referenced by the CONSTANT_Class '"+t+"'."); } } else{ constraintViolated(o, "Expecting a CONSTANT_Class referencing an array type. [Constraint not found in The Java Virtual Machine Specification, Second Edition, 4.8.1]"); } }
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */ @Override public void visitMULTIANEWARRAY(final MULTIANEWARRAY o) { indexValid(o, o.getIndex()); final Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)) { constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'."); } final int dimensions2create = o.getDimensions(); if (dimensions2create < 1) { constraintViolated(o, "Number of dimensions to create must be greater than zero."); } final Type t = o.getType(cpg); if (t instanceof ArrayType) { final int dimensions = ((ArrayType) t).getDimensions(); if (dimensions < dimensions2create) { constraintViolated(o, "Not allowed to create array with more dimensions ('"+dimensions2create+ "') than the one referenced by the CONSTANT_Class '"+t+"'."); } } else{ constraintViolated(o, "Expecting a CONSTANT_Class referencing an array type."+ " [Constraint not found in The Java Virtual Machine Specification, Second Edition, 4.8.1]"); } }