paramTypes = new ArrayList<>(2);
ParameterizedType collectionType = JDKTypes.COLLECTION_TYPE.instantiate(elementType);
diff --git a/src/main/java/randoop/operation/MethodCall.java b/src/main/java/randoop/operation/MethodCall.java
index fbeb7cb608..7b92711eca 100644
--- a/src/main/java/randoop/operation/MethodCall.java
+++ b/src/main/java/randoop/operation/MethodCall.java
@@ -11,7 +11,6 @@
import randoop.ExecutionOutcome;
import randoop.Globals;
import randoop.NormalExecution;
-import randoop.reflection.AccessibilityPredicate;
import randoop.reflection.ReflectionPredicate;
import randoop.sequence.Variable;
import randoop.types.Type;
@@ -46,13 +45,14 @@ public final class MethodCall extends CallableOperation {
private final boolean isStatic;
/**
- * True if the method is accessible. If {@code --only-test-public-members} is set to true, a
- * method is considered accessible iff it's public. Additionally, if {@code --junit-package-name}
- * is null, a method is considered accessible iff it's public. Otherwise, a method is considered
+ * True if the method should be called reflectively. (This is generally because the method is not
+ * accessible from the JUnit code.) If {@code --only-test-public-members} is set to true, a method
+ * is considered accessible iff it's public. Additionally, if {@code --junit-package-name} is
+ * null, a method is considered accessible iff it's public. Otherwise, a method is considered
* accessible if it is either public or accessible relative to the given package name specified by
- * {@code --junit-package-name}
+ * {@code --junit-package-name}.
*/
- private boolean isAccessible;
+ private boolean callReflectively;
/**
* getMethod returns Method object of this MethodCall.
@@ -66,17 +66,28 @@ public Method getMethod() {
/**
* Creates an object corresponding to a call to the given method.
*
+ * In generated tests, the method will be called normally, not reflectively.
+ *
* @param method the reflective method object
- * @param isAccessible boolean indicating if the method is accessible
*/
- public MethodCall(Method method, boolean isAccessible) {
+ public MethodCall(Method method) {
+ this(method, false);
+ }
+
+ /**
+ * Creates an object corresponding to a call to the given method.
+ *
+ * @param method the reflective method object
+ * @param callReflectively if true, the method should be called reflectively
+ */
+ public MethodCall(Method method, boolean callReflectively) {
if (method == null) {
throw new IllegalArgumentException("method should not be null.");
}
this.method = method;
this.isStatic = Modifier.isStatic(method.getModifiers() & Modifier.methodModifiers());
- this.isAccessible = isAccessible;
+ this.callReflectively = callReflectively;
}
/**
@@ -110,7 +121,30 @@ public void appendCode(
// The name of a variable (in the test that Randoop outputs) that holds the Method object.
String methodVar = getVariableNameForMethodObject();
- if (!isAccessible) {
+ if (!callReflectively) {
+ if (isStatic()) {
+ // In the generated Java code, the "receiver" (before the method name) for a static method
+ // call is the class name.
+ sb.append(declaringType.getCanonicalName().replace('$', '.'));
+ } else {
+ // In the generated Java code, the receiver is an expression.
+ String receiverVar = isStatic() ? null : inputVars.get(0).getName();
+ Type receiverFormalType = inputTypes.get(0);
+ if (receiverFormalType.isPrimitive()) {
+ sb.append("((")
+ .append(receiverFormalType.getFqName())
+ .append(")")
+ .append(receiverVar)
+ .append(")");
+ } else {
+ sb.append(receiverVar);
+ }
+ }
+
+ sb.append(".");
+ sb.append(methodName);
+ } else {
+ // TODO: For brevity here, perhaps abstract this `if` statement into a separate method.
if (!Globals.makeAccessibleCode.containsKey(methodVar)) {
StringBuilder makeMethodAccessibleBuilder = new StringBuilder();
makeMethodAccessibleBuilder
@@ -133,32 +167,7 @@ public void appendCode(
.append(System.lineSeparator());
Globals.makeAccessibleCode.put(methodVar, makeMethodAccessibleBuilder.toString());
}
- }
-
- String receiverVar = isStatic() ? null : inputVars.get(0).getName();
- if (isAccessible) {
- if (isStatic()) {
- // In the generated Java code, the "receiver" (before the method name) for a static method
- // call is the class name.
- sb.append(declaringType.getCanonicalName().replace('$', '.'));
- } else {
- // In this branch, isAcessible == false.
- // In the generated Java code, the receiver is an expression.
- Type receiverFormalType = inputTypes.get(0);
- if (receiverFormalType.isPrimitive()) {
- sb.append("((")
- .append(receiverFormalType.getFqName())
- .append(")")
- .append(receiverVar)
- .append(")");
- } else {
- sb.append(receiverVar);
- }
- }
- sb.append(".");
- sb.append(methodName);
- } else {
if (!outputType.isVoid()) {
// Cast because the return type of `invoke()` is Object.
sb.append("(").append(outputType.getFqName()).append(") ");
@@ -168,9 +177,9 @@ public void appendCode(
StringJoiner arguments = new StringJoiner(", ", "(", ")");
// In a reflective call, a receiver is always passed (even if it's null).
- int startIndex = !isAccessible || isStatic() ? 0 : 1;
+ int startIndex = callReflectively || isStatic() ? 0 : 1;
for (int i = startIndex; i < inputVars.size(); i++) {
- if (i == 0 && !isAccessible && isStatic()) {
+ if (i == 0 && callReflectively && isStatic()) {
// There is no harm to passing inputVars.get(0), but pass
// null to emphasize that the first (receiver) argument is ignored.
sb.append("null");
@@ -356,8 +365,8 @@ public static TypedClassOperation parse(String signature) throws OperationParseE
throw new OperationParseException(msg);
}
}
- // accessibility predicate shouldn't matter for generating output type
- return TypedClassOperation.forMethod(m, AccessibilityPredicate.IS_ANY);
+
+ return TypedClassOperation.forMethod(m);
}
/**
diff --git a/src/main/java/randoop/operation/TypedOperation.java b/src/main/java/randoop/operation/TypedOperation.java
index 949526567e..d3c1727771 100644
--- a/src/main/java/randoop/operation/TypedOperation.java
+++ b/src/main/java/randoop/operation/TypedOperation.java
@@ -460,6 +460,16 @@ public static TypedClassOperation forConstructor(Constructor> constructor) {
return new TypedClassOperation(op, declaringType, inputTypes, declaringType);
}
+ /**
+ * Constructs a {@link TypedOperation} for a method object.
+ *
+ * @param method the reflective method object
+ * @return the typed operation for the given method
+ */
+ public static TypedClassOperation forMethod(Method method) {
+ return forMethod(method, AccessibilityPredicate.IS_ANY);
+ }
+
/**
* Constructs a {@link TypedOperation} for a method object.
*
@@ -482,7 +492,7 @@ public static TypedClassOperation forMethod(
}
List paramTypes = new ArrayList<>(methodParamTypes.size() + 1);
- MethodCall op = new MethodCall(method, accessibilityPredicate.isAccessible(method));
+ MethodCall op = new MethodCall(method, !accessibilityPredicate.isAccessible(method));
ClassOrInterfaceType declaringType = ClassOrInterfaceType.forClass(method.getDeclaringClass());
if (!op.isStatic()) {
paramTypes.add(declaringType);
@@ -526,7 +536,7 @@ private static TypedClassOperation getAnonEnumOperation(
continue;
}
List paramTypes = new ArrayList<>(mGenericParamTypes.length + 1);
- MethodCall op = new MethodCall(publicMethod, true);
+ MethodCall op = new MethodCall(publicMethod);
if (!op.isStatic()) {
paramTypes.add(enumType);
}
diff --git a/src/main/java/randoop/reflection/OperationModel.java b/src/main/java/randoop/reflection/OperationModel.java
index a6d16a0c9b..7b506fb370 100644
--- a/src/main/java/randoop/reflection/OperationModel.java
+++ b/src/main/java/randoop/reflection/OperationModel.java
@@ -624,8 +624,8 @@ private void addClassTypes(
succeeded++;
} catch (Throwable e) {
System.out.printf(
- "Cannot get methods for %s specified via --testclass or --classlist"
- + " due to exception:%n%s%n",
+ "Cannot get methods for %s specified via "
+ + "--testclass or --classlist due to exception:%n%s%n",
c.getName(), UtilPlume.stackTraceToString(e));
}
}
diff --git a/src/main/java/randoop/reflection/ReflectionManager.java b/src/main/java/randoop/reflection/ReflectionManager.java
index 5365150156..f7ae4ace5b 100644
--- a/src/main/java/randoop/reflection/ReflectionManager.java
+++ b/src/main/java/randoop/reflection/ReflectionManager.java
@@ -156,7 +156,8 @@ public void apply(ClassVisitor visitor, Class> c) {
m.setAccessible(true);
applyTo(visitor, m);
} catch (Exception e) {
- // Method cannot be reflectively called
+ // Method cannot be reflectively called.
+ // TODO: some kind of error should be thrown here (or at least logging?).
}
} else if (isAccessible(m)) {
if (classIsAccessible || Modifier.isStatic(m.getModifiers())) {
diff --git a/src/main/java/randoop/test/ExpectedExceptionCheck.java b/src/main/java/randoop/test/ExpectedExceptionCheck.java
index 592f9d0bba..ae1cb82650 100644
--- a/src/main/java/randoop/test/ExpectedExceptionCheck.java
+++ b/src/main/java/randoop/test/ExpectedExceptionCheck.java
@@ -17,7 +17,7 @@
public class ExpectedExceptionCheck extends ExceptionCheck {
/** A boolean indicating the accessibility of the method. */
- private boolean isAccessible;
+ private boolean callReflectively;
/**
* Creates check that enforces expectation that an exception is thrown by the statement at the
@@ -32,9 +32,9 @@ public class ExpectedExceptionCheck extends ExceptionCheck {
* @param catchClassName the name of exception to be caught
*/
public ExpectedExceptionCheck(
- Throwable exception, int statementIndex, String catchClassName, boolean isAccessible) {
+ Throwable exception, int statementIndex, String catchClassName, boolean callReflectively) {
super(exception, statementIndex, catchClassName);
- this.isAccessible = isAccessible;
+ this.callReflectively = callReflectively;
}
/**
@@ -45,7 +45,9 @@ public ExpectedExceptionCheck(
@Override
protected void appendTryBehavior(StringBuilder b) {
String assertionMessage;
- {
+ if (callReflectively) {
+ assertionMessage = "Expected exception of type java.lang.reflect.InvocationTargetException";
+ } else {
String message;
if (exception.getClass().isAnonymousClass()) {
message = "Expected anonymous exception";
@@ -58,14 +60,7 @@ protected void appendTryBehavior(StringBuilder b) {
}
message = "Expected exception of type " + getExceptionName() + exceptionMessage;
}
- if (isAccessible) {
- assertionMessage = "org.junit.Assert.fail(\"" + StringsPlume.escapeJava(message) + "\")";
- } else {
- assertionMessage =
- "org.junit.Assert.fail(\""
- + "Expected exception of type java.lang.reflect.InvocationTargetException"
- + "\")";
- }
+ assertionMessage = "org.junit.Assert.fail(\"" + StringsPlume.escapeJava(message) + "\")";
}
b.append(Globals.lineSep)
.append(" org.junit.Assert.fail(\"")
@@ -95,7 +90,7 @@ protected void appendTryBehavior(StringBuilder b) {
*/
@Override
protected void appendCatchBehavior(StringBuilder b, String catchClassName) {
- if (!isAccessible) {
+ if (callReflectively) {
b.append("catch (")
.append("java.lang.reflect.InvocationTargetException")
.append(" e) {")
diff --git a/src/test/java/randoop/condition/OperationSpecificationTest.java b/src/test/java/randoop/condition/OperationSpecificationTest.java
index 4fc05610b9..8ee550bdd3 100644
--- a/src/test/java/randoop/condition/OperationSpecificationTest.java
+++ b/src/test/java/randoop/condition/OperationSpecificationTest.java
@@ -25,7 +25,6 @@
import randoop.condition.specification.ThrowsCondition;
import randoop.operation.TypedClassOperation;
import randoop.operation.TypedOperation;
-import randoop.reflection.AccessibilityPredicate;
import randoop.sequence.ExecutableSequence;
import randoop.sequence.Sequence;
import randoop.sequence.Variable;
@@ -193,8 +192,7 @@ private ExecutableSequence createCategorySequence(int value) throws NoSuchMethod
Constructor> reflectionConstructor = c.getConstructor(int.class);
TypedClassOperation constructorOp = TypedOperation.forConstructor(reflectionConstructor);
Method method = c.getDeclaredMethod("category", int.class);
- TypedClassOperation methodOp =
- TypedOperation.forMethod(method, AccessibilityPredicate.IS_PUBLIC);
+ TypedClassOperation methodOp = TypedOperation.forMethod(method);
methodOp.setExecutableSpecification(getMethodSpecification(method));
Sequence sequence = new Sequence();
@@ -212,8 +210,7 @@ private ExecutableSequence createCategorySequence(int value) throws NoSuchMethod
private ExecutableSequence createBadnessSequence() throws NoSuchMethodException {
Class> c = ClassWithConditions.class;
Method method = c.getDeclaredMethod("badness", ClassWithConditions.Range.class, int.class);
- TypedClassOperation methodOp =
- TypedOperation.forMethod(method, AccessibilityPredicate.IS_PUBLIC);
+ TypedClassOperation methodOp = TypedOperation.forMethod(method);
methodOp.setExecutableSpecification(getBadnessConditions(method));
Sequence sequence = new Sequence();
diff --git a/src/test/java/randoop/condition/SpecificationTranslatorTest.java b/src/test/java/randoop/condition/SpecificationTranslatorTest.java
index 76214f9213..2fcad61902 100644
--- a/src/test/java/randoop/condition/SpecificationTranslatorTest.java
+++ b/src/test/java/randoop/condition/SpecificationTranslatorTest.java
@@ -26,7 +26,6 @@
import randoop.condition.specification.OperationSpecification;
import randoop.operation.TypedClassOperation;
import randoop.operation.TypedOperation;
-import randoop.reflection.AccessibilityPredicate;
import randoop.sequence.ExecutableSequence;
import randoop.sequence.Sequence;
import randoop.sequence.Variable;
@@ -62,9 +61,7 @@ public void testPrintWriterAppend() {
assertEquals("x2.equals(x0)", Util.replaceWords("result.equals(receiver)", replacements));
String conditionText = "result.equals(receiver)";
- Sequence sequence =
- createPrintWriterSequence(
- TypedOperation.forMethod(method, AccessibilityPredicate.IS_PUBLIC));
+ Sequence sequence = createPrintWriterSequence(TypedOperation.forMethod(method));
List postConditions = new ArrayList<>();
Method conditionMethod =
@@ -163,8 +160,7 @@ public void testSignatureFromFile() {
SpecificationCollection collection = SpecificationCollection.create(specList);
ExecutableSpecification execSpec = collection.getExecutableSpecification(method);
- TypedClassOperation appendOp =
- TypedOperation.forMethod(method, AccessibilityPredicate.IS_PUBLIC);
+ TypedClassOperation appendOp = TypedOperation.forMethod(method);
appendOp.setExecutableSpecification(execSpec);
Sequence sequence = createPrintWriterSequence(appendOp);
ExecutableSequence eseq = new ExecutableSequence(sequence);
diff --git a/src/test/java/randoop/operation/EnumReflectionTest.java b/src/test/java/randoop/operation/EnumReflectionTest.java
index d54fb11392..9685133510 100644
--- a/src/test/java/randoop/operation/EnumReflectionTest.java
+++ b/src/test/java/randoop/operation/EnumReflectionTest.java
@@ -68,7 +68,7 @@ public void simpleEnumTest() {
for (Method m : exclude) {
assertFalse(
"method " + m.toGenericString() + " should not occur in simple enum",
- actual.contains(createMethodCall(m, declaringType, true)));
+ actual.contains(createMethodCall(m, declaringType)));
}
}
@@ -134,11 +134,11 @@ public void innerEnumWithMethodsTest() {
include.add(createEnumOperation(e));
}
for (Method m : c.getDeclaredMethods()) {
- if (Modifier.isPublic(m.getModifiers())) { // extract only public methods
+ if (Modifier.isPublic(m.getModifiers())) {
if (!m.getName().equals("values") && !m.getName().equals("valueOf")) {
- include.add(createMethodCall(m, enumType, true));
+ include.add(createMethodCall(m, enumType));
} else {
- exclude.add(createMethodCall(m, enumType, true));
+ exclude.add(createMethodCall(m, enumType));
}
}
}
@@ -180,16 +180,16 @@ public void enumAsPredicateTest() {
if (opSet == null) {
opSet = new HashSet<>();
}
- opSet.add(createMethodCall(m, enumType, true));
+ opSet.add(createMethodCall(m, enumType));
overrideMap.put(m.getName(), opSet);
}
}
for (Method m : c.getDeclaredMethods()) {
- if (Modifier.isPublic(m.getModifiers())) { // extract only public methods
+ if (Modifier.isPublic(m.getModifiers())) {
if (!m.getName().equals("values") && !m.getName().equals("valueOf")) {
- include.add(createMethodCall(m, enumType, true));
+ include.add(createMethodCall(m, enumType));
} else {
- exclude.add(createMethodCall(m, enumType, true));
+ exclude.add(createMethodCall(m, enumType));
}
}
}
@@ -198,7 +198,7 @@ public void enumAsPredicateTest() {
Set opSet = overrideMap.get(publicMethod.getName());
if (opSet != null) {
TypedClassOperation actualEnumOp =
- createMethodCall(publicMethod, enumType, true)
+ createMethodCall(publicMethod, enumType)
.substitute(interfaceType.getTypeSubstitution());
include.add(actualEnumOp);
}
@@ -264,7 +264,7 @@ public void valueEnum() {
}
for (Method publicMethod : coin.getMethods()) {
- TypedOperation mc = createMethodCall(publicMethod, declaringType, true);
+ TypedOperation mc = createMethodCall(publicMethod, declaringType);
if (publicMethod.getName().equals("value")) {
assertTrue(
"enum method " + publicMethod.toGenericString() + " should occur", actual.contains(mc));
@@ -303,7 +303,7 @@ public void abstractMethodEnum() {
}
for (Method publicMethod : op.getMethods()) {
- TypedOperation mc = createMethodCall(publicMethod, declaringType, true);
+ TypedOperation mc = createMethodCall(publicMethod, declaringType);
if (overrides.contains(publicMethod.getName())) {
assertTrue("enum method " + mc + " should occur", actual.contains(mc));
count++;
@@ -338,9 +338,8 @@ private TypedClassOperation createConstructorCall(Constructor> con)
return new TypedClassOperation(op, declaringType, new TypeTuple(paramTypes), declaringType);
}
- private TypedClassOperation createMethodCall(
- Method m, ClassOrInterfaceType declaringType, boolean isAccessible) {
- MethodCall op = new MethodCall(m, isAccessible);
+ private TypedClassOperation createMethodCall(Method m, ClassOrInterfaceType declaringType) {
+ MethodCall op = new MethodCall(m);
List paramTypes = new ArrayList<>();
paramTypes.add(declaringType);
for (java.lang.reflect.Type t : m.getGenericParameterTypes()) {
diff --git a/src/test/java/randoop/operation/OperationParserTests.java b/src/test/java/randoop/operation/OperationParserTests.java
index 7e64d8ff27..d2882b1aea 100644
--- a/src/test/java/randoop/operation/OperationParserTests.java
+++ b/src/test/java/randoop/operation/OperationParserTests.java
@@ -117,7 +117,7 @@ public void testRMethod() {
}
TypeTuple inputTypes = new TypeTuple(paramTypes);
Type outputType = Type.forType(publicMethod.getGenericReturnType());
- checkParse(new MethodCall(publicMethod, true), declaringType, inputTypes, outputType);
+ checkParse(new MethodCall(publicMethod), declaringType, inputTypes, outputType);
}
}
diff --git a/src/test/java/randoop/operation/TypedOperationTest.java b/src/test/java/randoop/operation/TypedOperationTest.java
index c348bf9798..cb1ed68c3f 100644
--- a/src/test/java/randoop/operation/TypedOperationTest.java
+++ b/src/test/java/randoop/operation/TypedOperationTest.java
@@ -6,7 +6,6 @@
import java.lang.reflect.Method;
import org.junit.Test;
-import randoop.reflection.AccessibilityPredicate;
import randoop.types.TypeVariable;
public class TypedOperationTest {
@@ -20,7 +19,7 @@ public void testOperationParameterTypes() {
fail("failed to load method ParameterInput.m()");
throw new Error("unreachable");
}
- TypedClassOperation operation = TypedOperation.forMethod(m, AccessibilityPredicate.IS_PUBLIC);
+ TypedClassOperation operation = TypedOperation.forMethod(m);
assertFalse(
"operation has type parameters: " + operation, operation.getTypeParameters().isEmpty());
TypedClassOperation capOp = operation.applyCaptureConversion();
diff --git a/src/test/java/randoop/reflection/AccessibilityTest.java b/src/test/java/randoop/reflection/AccessibilityTest.java
index 74a2faaeb9..ecea216e1b 100644
--- a/src/test/java/randoop/reflection/AccessibilityTest.java
+++ b/src/test/java/randoop/reflection/AccessibilityTest.java
@@ -131,7 +131,7 @@ public void testStandardPackagePrivateAccessibility() throws ClassNotFoundExcept
for (Method m : expectedMethods) {
assertTrue(
"method " + m.getName() + " should occur",
- actual.contains(createMethodCall(m, declaringType, accessibility.isAccessible(m))));
+ actual.contains(createMethodCall(m, declaringType, !accessibility.isAccessible(m))));
}
} catch (RandoopTypeException e) {
fail("Type error: " + e.getMessage());
@@ -229,7 +229,7 @@ public void testPublicOnlyPackagePrivateAccessibility() throws ClassNotFoundExce
for (Method m : expectedMethods) {
assertFalse(
"method " + m.getName() + " should occur",
- actual.contains(createMethodCall(m, declaringType, true)));
+ actual.contains(createMethodCall(m, declaringType)));
}
} catch (RandoopTypeException e) {
fail("Type error: " + e.getMessage());
@@ -326,7 +326,7 @@ public void testStandardAccessibility() {
for (Method m : expectedMethods) {
assertTrue(
"method " + m.getName() + " should occur",
- actual.contains(createMethodCall(m, declaringType, accessibility.isAccessible(m))));
+ actual.contains(createMethodCall(m, declaringType, !accessibility.isAccessible(m))));
}
} catch (RandoopTypeException e) {
fail("Type error: " + e.getMessage());
@@ -436,8 +436,8 @@ public void testPublicOnlyAccessibility() {
assertTrue(
"method " + m.getName() + " should occur",
actual.contains(
- createMethodCall(
- m, declaringType, true))); // every method is public in expectedMethods
+ // every method is public in expectedMethods
+ createMethodCall(m, declaringType)));
}
for (Constructor> co : expectedConstructors) {
@@ -560,10 +560,15 @@ private TypedOperation createConstructorCall(Constructor> con) throws RandoopT
return new TypedClassOperation(op, declaringType, new TypeTuple(paramTypes), declaringType);
}
+ private TypedOperation createMethodCall(Method m, ClassOrInterfaceType declaringType)
+ throws RandoopTypeException {
+ return createMethodCall(m, declaringType, false);
+ }
+
private TypedOperation createMethodCall(
- Method m, ClassOrInterfaceType declaringType, boolean isAccessible)
+ Method m, ClassOrInterfaceType declaringType, boolean reflectiveCall)
throws RandoopTypeException {
- MethodCall op = new MethodCall(m, isAccessible);
+ MethodCall op = new MethodCall(m, reflectiveCall);
List paramTypes = new ArrayList<>();
if (!Modifier.isStatic(m.getModifiers() & Modifier.methodModifiers())) {
paramTypes.add(declaringType);
diff --git a/src/test/java/randoop/reflection/SignatureParserTest.java b/src/test/java/randoop/reflection/SignatureParserTest.java
index baadb78ea0..c4e54e7d2d 100644
--- a/src/test/java/randoop/reflection/SignatureParserTest.java
+++ b/src/test/java/randoop/reflection/SignatureParserTest.java
@@ -70,7 +70,7 @@ private void checkParse(String inputString) throws SignatureParseException {
TypedClassOperation operation =
(accessibleObject instanceof Constructor)
? TypedOperation.forConstructor((Constructor) accessibleObject)
- : TypedOperation.forMethod((Method) accessibleObject, AccessibilityPredicate.IS_PUBLIC);
+ : TypedOperation.forMethod((Method) accessibleObject);
String expectedString = inputString.replace(" ", "").replace(".", "");
String signatureString = operation.getRawSignature().toString();
diff --git a/src/test/java/randoop/sequence/DevExampleCode.java b/src/test/java/randoop/sequence/DevExampleCode.java
index 9014aa9bc9..c6bffc03c4 100644
--- a/src/test/java/randoop/sequence/DevExampleCode.java
+++ b/src/test/java/randoop/sequence/DevExampleCode.java
@@ -38,14 +38,10 @@ public void devDocExampleTest() {
TypedOperation newOb =
TypedOperation.createPrimitiveInitialization(JavaTypes.STRING_TYPE, "hi!");
TypedOperation addFirst =
- TypedOperation.forMethod(
- LinkedList.class.getMethod("addFirst", Object.class),
- AccessibilityPredicate.IS_PUBLIC)
+ TypedOperation.forMethod(LinkedList.class.getMethod("addFirst", Object.class))
.substitute(substLL);
TypedOperation size =
- TypedOperation.forMethod(
- LinkedList.class.getMethod("size"), AccessibilityPredicate.IS_PUBLIC)
- .substitute(substLL);
+ TypedOperation.forMethod(LinkedList.class.getMethod("size")).substitute(substLL);
// Call to operation with wildcard in TreeSet
InstantiatedType treeSetType = JDKTypes.TREE_SET_TYPE.instantiate(JavaTypes.STRING_TYPE);
diff --git a/src/test/java/randoop/types/CaptureConversionTest.java b/src/test/java/randoop/types/CaptureConversionTest.java
index 961c8c2291..9b846dbdbd 100644
--- a/src/test/java/randoop/types/CaptureConversionTest.java
+++ b/src/test/java/randoop/types/CaptureConversionTest.java
@@ -9,7 +9,6 @@
import org.junit.BeforeClass;
import org.junit.Test;
import randoop.operation.TypedOperation;
-import randoop.reflection.AccessibilityPredicate;
import randoop.types.test.CaptureTestClass;
import randoop.types.test.Container;
import randoop.types.test.Gibberish;
@@ -31,23 +30,13 @@ public static void setup() {
listOperations = new ArrayList<>();
containerOperations = new ArrayList<>();
try {
- listOperations.add(
- TypedOperation.forMethod(c.getMethod("a", List.class), AccessibilityPredicate.IS_PUBLIC));
- listOperations.add(
- TypedOperation.forMethod(c.getMethod("b", List.class), AccessibilityPredicate.IS_PUBLIC));
- listOperations.add(
- TypedOperation.forMethod(c.getMethod("c", List.class), AccessibilityPredicate.IS_PUBLIC));
- listOperations.add(
- TypedOperation.forMethod(c.getMethod("d", List.class), AccessibilityPredicate.IS_PUBLIC));
- containerOperations.add(
- TypedOperation.forMethod(
- c.getMethod("a", Container.class), AccessibilityPredicate.IS_PUBLIC));
- containerOperations.add(
- TypedOperation.forMethod(
- c.getMethod("b", Container.class), AccessibilityPredicate.IS_PUBLIC));
- containerOperations.add(
- TypedOperation.forMethod(
- c.getMethod("c", Container.class), AccessibilityPredicate.IS_PUBLIC));
+ listOperations.add(TypedOperation.forMethod(c.getMethod("a", List.class)));
+ listOperations.add(TypedOperation.forMethod(c.getMethod("b", List.class)));
+ listOperations.add(TypedOperation.forMethod(c.getMethod("c", List.class)));
+ listOperations.add(TypedOperation.forMethod(c.getMethod("d", List.class)));
+ containerOperations.add(TypedOperation.forMethod(c.getMethod("a", Container.class)));
+ containerOperations.add(TypedOperation.forMethod(c.getMethod("b", Container.class)));
+ containerOperations.add(TypedOperation.forMethod(c.getMethod("c", Container.class)));
} catch (NoSuchMethodException e) {
fail("didn't find method: " + e.getMessage());
}
diff --git a/src/test/java/randoop/types/TypeVariableTest.java b/src/test/java/randoop/types/TypeVariableTest.java
index d7ee7a0e06..ce0e147bf7 100644
--- a/src/test/java/randoop/types/TypeVariableTest.java
+++ b/src/test/java/randoop/types/TypeVariableTest.java
@@ -11,7 +11,6 @@
import org.junit.Test;
import randoop.operation.TypedClassOperation;
import randoop.operation.TypedOperation;
-import randoop.reflection.AccessibilityPredicate;
import randoop.types.test.VariablesInput;
public class TypeVariableTest {
@@ -29,8 +28,7 @@ public int compare(Method o1, Method o2) {
Collections.addAll(methods, c.getDeclaredMethods());
for (Method m : methods) {
if (!m.getName().equals("$jacocoInit")) {
- TypedClassOperation operation =
- TypedOperation.forMethod(m, AccessibilityPredicate.IS_PUBLIC).applyCaptureConversion();
+ TypedClassOperation operation = TypedOperation.forMethod(m).applyCaptureConversion();
ReferenceType parameterType = (ReferenceType) operation.getInputTypes().get(1);
TypeVariable variable;