-
Notifications
You must be signed in to change notification settings - Fork 274
[TG-8623] Fix primitive wrapper types in JSON value retriever #4973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TG-8623] Fix primitive wrapper types in JSON value retriever #4973
Conversation
1081b33
to
1c52357
Compare
Following the format of the json-io library, the JSON input to the value retriever does not distinguish between primitive types and their corresponding wrapper types. A class Foo with a field fooField of type Integer might appear as { "@type":"org.cprover.Foo", "fooField":100 } To support this "primitive representation", we need a special case in the struct assignment part.
In this case, the values are represented as JSON objects with @type keys. This already worked before the fix in the previous commit.
In this case, the values are represented as simple JSON numbers, booleans or strings. This did not work before the recent fix for primitive wrapper types.
This test falls into the same category as the tests from the previous commit (static field with reference to primitive wrapper(s)) but is closer to the example that was initially found for the bug (TG-8623).
1c52357
to
91e652e
Compare
@tautschnig I had to reformat all of the test commits on this PR because clang-format complained. It seems that this is a consequence of #4926. What is the reason behind enforcing clang-format on Java source files for regression tests? |
Codecov Report
@@ Coverage Diff @@
## develop #4973 +/- ##
===========================================
+ Coverage 69.24% 69.31% +0.07%
===========================================
Files 1309 1308 -1
Lines 108453 108324 -129
===========================================
- Hits 75096 75084 -12
+ Misses 33357 33240 -117
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR failed Diffblue compatibility checks (cbmc commit: 91e652e).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/121647072
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.
I'm pretty sure that the clang-format configuration for Java actually should be amended in some way, which might in many cases help avoid the need for reformatting (assuming our Java tests are actually formatted in some consistent fashion...). I was in a way hoping for this to happen so that we could figure out what the correct formatting rules should be. Maybe we can do this here and now?
Previously, clang-format would abort when encountering changes to Java files, leaving the C++ files untouched even when they weren't correctly formatted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tidy
It doesn't look like they are. No format has ever been enforced for them... Do you think specifying a format for test files is generally useful? It certainly is for source code but tests are much more isolated and slightly different formats usually don't make them less readable.
That sounds like a bug? Did we report this somewhere? Are only Java files affected, or do we have other file types that could secretly silence clang-format when they are changed? |
If we want to there's an argument to git-clang-format giving wildcard excludes (i.e. *,java would do) |
@smowton Let's look into that. I don't think the clang-format issue should block this PR so I'll rebase it and merge it if it (and its TG bump) passes. |
Following the format of the json-io library, the JSON input to the value retriever does not distinguish between primitive types and their corresponding wrapper types. A class
Foo
with a fieldfooField
of type Integer might appear asTo support this "primitive representation", we need a special case in the struct assignment part.
The new function
is_primitive_wrapper_type_name
is moved here from TG. Any changes to it should be done in future refactoring PRs.