Improved treatment of final fields#3495
Conversation
|
Is #3189 now obsolete? Interestingly, |
This is the commits from back then merged onto the modern main.
There are a few source code level things that get lost on byte code. Also generics. Sometimes private fields are not so private in byte code. We operate on source code level and assume that all code is compiler-conformant. |
... revert to heap updates in such cases.
thanks to Richard for hinting at the needed infrastructure
9fb4182 to
9bae13f
Compare
|
The last commits add sound special treatment for constructors. |
# Conflicts: # key.core/src/test/resources/de/uka/ilkd/key/nparser/taclets.old.txt
a final field reference in a created object points to null or to a created object.
key.core/src/test/java/de/uka/ilkd/key/pp/FinalPrinterTest.java
Outdated
Show resolved
Hide resolved
WolframPfeifer
left a comment
There was a problem hiding this comment.
Nice feature, while reviewing it everything worked as expected. I have a few minor questions/remarks that should be resolved, but overall I think it is very well written and also nicely documented in code. Thanks!
key.core/src/main/resources/de/uka/ilkd/key/proof/rules/optionsDeclarations.key
Show resolved
Hide resolved
key.core/src/main/resources/de/uka/ilkd/key/proof/rules/locSetsRules.key
Show resolved
Hide resolved
key.core/src/main/java/de/uka/ilkd/key/proof/init/FinalFieldsPOExtension.java
Outdated
Show resolved
Hide resolved
key.core/src/main/java/de/uka/ilkd/key/proof/init/FinalFieldCodeValidator.java
Outdated
Show resolved
Hide resolved
key.core/src/main/java/de/uka/ilkd/key/speclang/jml/translation/JMLSpecFactory.java
Show resolved
Hide resolved
key.core/src/main/resources/de/uka/ilkd/key/proof/rules/heap.key
Outdated
Show resolved
Hide resolved
key.core/src/main/resources/de/uka/ilkd/key/proof/rules/javaRules.key
Outdated
Show resolved
Hide resolved
key.core/src/test/java/de/uka/ilkd/key/pp/FinalPrinterTest.java
Outdated
Show resolved
Hide resolved
57c514b to
437803f
Compare
437803f to
9bb8e45
Compare
993e805 to
d35ef21
Compare
cade928 to
aa0f53e
Compare
WolframPfeifer
left a comment
There was a problem hiding this comment.
Thanks for resolving all of my points!
Regarding documentation: I compiled a list of questions/possible points that would make sense to describe in our manual (KeYProject/key-docs#44). Let's try not to forget about it ...
Intended Change
Final fields cannot change their value after a single assignment in the constructor. In the current KeY logic, final fields are treated like normal fields stored on the heap. This is highly inefficient since heap assignments cannot have an impact on final fields at all.
The plan is hence to access final fields using a function of their own that does not depend on the heap, unlike other fields
The major challenges include
Writing must somehow be restricted since any modality could write to final fields and thus compromise proofs if thus different inconsistent values for final fields are around on a sequent.
Plan
The following new items showed up:
static finalfields are a challenge since they need double special treatment in parsing and prettyprintingType of pull request
The plan is to have a taclet otion to fall back to old behaviour.
Ensuring quality
To do:
Additional information and contact(s)
It is the modernised version of #3189.
@WolframPfeifer @wadoon
The contributions within this pull request are licensed under GPLv2 (only) for inclusion in KeY.