Comments (1)
"Temporary breaking of class invariance between private method calls is possible, although not encouraged."
This has been fixed.
The other issue with class-invariants being checked during construction of an object can thus only happen after a publicly available method (meaning public, protected or package-private in Java) is being called during construction of an object. As they could also be called during any other moment during the lifecycle of the object, they must be able to assume that the class-invariant holds before being called themselves. With this assumption in mind, it should not be an issue to call the class-invariant after a publicly available method during construction of an object.
Also, the example on c2.com is using another assumption: That the assertValid() method is being overridden in the subclass. The call order will differ between the example and the C4J implementation as follows:
c2.com Example:
Derived();
Base();
{ body of Base() }
Derived.assertValid(); // <-- problem: Invariant called before body of Derived() is being evaluated
Base.assertValid();
{ body of Derived() }
Derived.assertValid();
Base.assertValid();
C4J equivalent:
Derived();
Base();
{ body of Base() }
Base.classInvariant();
{ body of Derived() }
Base.classInvariant();
Derive.classInvariant();
This also shows why doing Contracts in Java without using a framework is quite complicated.
from c4j.
Related Issues (20)
- Fix @AllowPureAccess not working correctly with Objects
- Exceptions being thrown while storing a value for old() in a pre-condition should be thrown in the post-condition
- Work together with EclEmma
- Fix old-Expressions being evaluated in post-condition
- Fix bug when using old and unchanged together in a post-condition
- Fix bug when using old and unchanged in a post-condition as well as in a class-invariant
- Fix pure trying to access package-private fields when subclass is in another package
- Fix XML-Configuration not working for top-level package-names
- Improve performance by removing Thread.currentThread.getStackTrace() calls
- Allow class initializers write access on own static fields in pure validation
- Configure contracts to be run only for a fraction of method calls, ensuring a limited overhead during runtime
- Use SLF4J instead of Log4J
- Review and decide on LSP Implementation HOT 1
- No instrumentation when method is undeclared and already instrumented in super-class
- Bug: unchanged() and old() not usable within extracted methods in Contract class
- Change constructor contract functionality
- Synthetic static method in contract class throws UsageError
- instrumenting too much?
- c4j once configured in Base Eclipse Plugin used in dependant plugins
- Checking whether a precondition is strengthening a super-defined precondition seems to be to strict in case of using external contract classes.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c4j.