InvocationConstraints constraints = new InvocationConstraints(
ic, null);
MethodDesc methodDesc1 = new MethodDesc(name, constraints);
MethodDesc methodDesc2 = new MethodDesc(constraints);
MethodDesc [] passedDescs = {methodDesc1, methodDesc2};
BasicMethodConstraints bmc = new BasicMethodConstraints(passedDescs);
MethodDesc [] resultDescs = bmc.getMethodDescs();
if (resultDescs.length != passedDescs.length) {
throw new TestException(
"returned MethodDesc array has invalid length");
}
for (int j = 0; j < passedDescs.length; ++j) {
if (resultDescs[j] != passedDescs[j]) {
throw new TestException(
"returned MethodDesc array invalid");
}
}
// 2
bmc = new BasicMethodConstraints(constraints);
resultDescs = bmc.getMethodDescs();
if (resultDescs.length != 1) {
throw new TestException(
"returned MethodDesc array has invalid length");
}
if (!resultDescs[0].getConstraints().equals(constraints)) {
throw new TestException(
"returned MethodDesc array invalid");
}
// 3
bmc = new BasicMethodConstraints(passedDescs);
MethodDesc [] resultDescs1 = bmc.getMethodDescs();
MethodDesc [] resultDescs2 = bmc.getMethodDescs();
if (resultDescs1 == resultDescs2) {
throw new TestException(
"returned MethodDesc array should be the new every time"
+ " it is called");
}
// 4
bmc = new BasicMethodConstraints(constraints);
resultDescs1 = bmc.getMethodDescs();
resultDescs2 = bmc.getMethodDescs();
if (resultDescs1 == resultDescs2) {
throw new TestException(
"returned MethodDesc array should be the new every time"
+ " it is called");
}