|JVM verifier vs. naive code generator email@example.com (Soeren Sandmann) (2011-03-20)|
|Re: JVM verifier vs. naive code generator firstname.lastname@example.org (glen herrmannsfeldt) (2011-03-21)|
|Re: JVM verifier vs. naive code generator Pidgeot18@verizon.invalid (Joshua Cranmer) (2011-03-21)|
|From:||glen herrmannsfeldt <email@example.com>|
|Date:||Mon, 21 Mar 2011 04:46:34 +0000 (UTC)|
|Organization:||A noiseless patient Spider|
|Posted-Date:||21 Mar 2011 22:08:47 EDT|
Soeren Sandmann <firstname.lastname@example.org> wrote:
> Consider this fragment of Java code:
> int i, j;
> i = 100;
> for (i >= 0 && (j = 10) == 10)
> i = j;
> This is correct; j is not used without being initialized, and the
> Java compiler accepts it without complaints.
(snip about JVM code that might or will fail verification)
> Is there a standard way to get around this problem? Ie., a
> systematic way to ensure that the code generated will not only be
> correct, but also verifiable?
The usual way is to put an initializer on the declaration. I
sometimes add a comment that it is due to a compiler that can't
reliably detect that it is actually correct, but usually not.
I do sometimes wonder why they didn't just initialize local variables
to zero (like they do arrays). It would seem easier than the whole
testing process. My guess is to force people to go back and look at
the code, to be sure that it really does what they expect.
Then again, some may just put the initializer on and not reread
Did you try something like:
if(any boolean) i=1;
It might be better now, but didn't always figure that one out.
Return to the
Search the comp.compilers archives again.