Answer the question
In order to leave comments, you need to log in
What is the problem with C4J framework?
Hello.
So, it was necessary to sketch an example using the C4J framework.
Wrote a class
package ua.avereschaka.Utils;
import de.vksi.c4j.ContractReference;
import ua.avereschaka.Contracts.PhysicsUtilsContract;
@ContractReference(PhysicsUtilsContract.class)
public class PhysicsUtils {
public double getMinSpeed(double busSpeed, double distToBus, double distToRoad){
return (busSpeed * distToRoad) / distToBus;
}
}
package ua.avereschaka.Contracts;
import de.vksi.c4j.Contract;
import de.vksi.c4j.Target;
import ua.avereschaka.Utils.PhysicsUtils;
import static de.vksi.c4j.Condition.*;
@Contract
public class PhysicsUtilsContract extends PhysicsUtils {
@Target
private PhysicsUtils target;
@Override
public double getMinSpeed(double busSpeed, double distToBus, double distToRoad) {
if (preCondition()) {
assert busSpeed >= 0;
assert distToBus >= 0;
assert distToRoad >= 0;
}
if (postCondition()) {
assert result() != null;
assert result(Double.class) >= 0;
}
return ignored();
}
}
Answer the question
In order to leave comments, you need to log in
UPD: SOLVED
Specified javaagent to C4J jar nickname in startup parameters, and enabled assertions:
-javaagent:c4j-6.0.0.jar -ea
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question