Adding preprocessing for functions of the Java Character library#640
Conversation
There was a problem hiding this comment.
No single-character indent, please (just don't indent public/private).
There was a problem hiding this comment.
Passing a list by value?
There was a problem hiding this comment.
No blank line at end-of-file, please.
There was a problem hiding this comment.
Some comments around those magic numbers would really be appreciated.
There was a problem hiding this comment.
Rather random as it applies across this PR: use (const) references wherever possible, both in parameters and within the functions.
src/goto-programs/Makefile
Outdated
There was a problem hiding this comment.
put each cpp file on a separate line to facilitate merging
There was a problem hiding this comment.
Is there a reason why this has not been implemented yet?
There was a problem hiding this comment.
assignment (several occurrences)
There was a problem hiding this comment.
please comment on why this function is not implemented (several instances)
e0cd4ee to
b5cd96b
Compare
tautschnig
left a comment
There was a problem hiding this comment.
Mostly minor changes - many about the use of references.
src/cbmc/cbmc_parse_options.cpp
Outdated
There was a problem hiding this comment.
@kroening @peterschrammel @romainbrenguier I am wondering whether the invoked code should go in java_bytecode. (Yes, I have asked a similar question before.) If that folder isn't a good fit (for it introduces a dependency on goto-programs from java_bytecode), then maybe it's time for some folder like java_in-processing?
There was a problem hiding this comment.
Yes, you're right it should probably go to java_bytecode, the dependencies in goto-programs are not strong here. I will investigate that.
There was a problem hiding this comment.
I made some changes to the code which allows it to be called during java bytecode conversion.
So it can be moved there. See the commits 5801fbf , 848983b and 4c1986a
There was a problem hiding this comment.
const typet &type=result.type(); If you delay the target->make_assignment() call until after code is constructed, you could even make all of the above const exprt &
There was a problem hiding this comment.
Pass mp_integer by (const) reference
There was a problem hiding this comment.
Use disjunction from util/std_expr.h to avoid a deeply nested expression.
There was a problem hiding this comment.
Use references - see above
There was a problem hiding this comment.
No need for this return; statement
There was a problem hiding this comment.
Is there any way to catch or check additional function names (think about evolution of the Java SDK)? I'm thinking along the lines of "if the function call has prefix java::java.lang.Character." then it must be in the conversion_table or in some (to be created) conversion_not_supported table. Would that seem reasonable to do?
There was a problem hiding this comment.
It would be nice to detect functions that we do not support, but I don't think it should stop CBMC if we encounter one, considering its result non-deterministic maybe enough for what we want to check. We could raise a warning in that case, but it's actually already done by CBMC: we get messages like **** WARNING: no body for function java::java.lang.Character.toUpperCase:(C)C for the functions we haven't translated.
The reasonable thing in my opinion would be to update the code with the new versions of the JDK. From what I have seen, there will not be much difference with the JDK9 (the only difference I see is a new codePointOf(String) function which is the inverse of getName).
There was a problem hiding this comment.
There is some mixed indent of parameters - either seems ok, but consistency would be great.
|
With regard to the unsupported functions: won't the warning about missing function bodies continue to show up for all functions that are natively handled by the string solver? |
636c274 to
848983b
Compare
|
@tautschnig the functions that we support are converted to some fake functions calls (which are understood by the solver), and these don't show up in the warnings. |
There was a problem hiding this comment.
Just a note: with C++11 you don't need the space in > > anymore.
tautschnig
left a comment
There was a problem hiding this comment.
For all that I can tell from just reading code: this looks really good. Thanks a lot for all the changes and refactoring!
|
This needs a rebase! |
This preprocessing is meant to replace simple methods of the Character Java library by expressions on characters during bytecode conversion. About 60% of the library is supported, but for some of this methods are limited to ASCII characters. This is meant to be run in conjunction with the string refinement so it is called if the string-refine option is activated.
848983b to
924e01b
Compare
|
@kroening this has been rebased. |
This preprocessing is meant to replace simple methods of the Character
Java in goto-programs by expressions on characters.
About 60% of the library is supported, but for some of this
methods are limited to ASCII characters.
This is meant to be run in conjunction with the string refinement so
it is called if the string-refine option is activated.
Note that the string-refine option is added in PR #429, but this PR can be merged independently.