Bug #5558
Direct Java interface: extra semicolon in converted Java breaks program logic
50%
History
#1 Updated by Vladimir Tsichevski almost 5 years ago
The following 4gl:
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO. DO WHILE hQuery:GET-NEXT() : MESSAGE "Hello". CATCH EXC AS java.io.IOException: END. END.
Produces the following Java output:
try
{
loopLabel0:
;
while ((hQuery.unwrapQuery().getNext()).booleanValue())
;
{
message("Hello");
}
}
catch (java.io.IOException exc)
{
processCatch(() ->
{
});
}
Note the extra semicolon after the while(...) line, which breaks the program logic.
Also, the catch(..) line indentation is incorrect.
#3 Updated by Constantin Asofiei almost 5 years ago
- Status changed from New to WIP
- Assignee set to Constantin Asofiei
Greg, please review this. I'm not sure how correct it is:
### Eclipse Workspace Patch 1.0
#P p2j
Index: rules/convert/brew.xml
===================================================================
--- rules/convert/brew.xml (revision 2944)
+++ rules/convert/brew.xml (working copy)
@@ -448,6 +448,7 @@
<rule>notCode.add(java.star_comment)</rule>
<rule>notCode.add(java.skip)</rule>
<rule>notCode.add(java.annotation)</rule>
+ <rule>notCode.add(java.label_def)</rule>
<rule>!isRuntimeConfig()
<rule>outputRoot = getConfigParameter("output-root")</rule>
@@ -761,7 +762,8 @@
type != java.initializer and
type != java.star_comment and
type != java.indent_grp and
- (parent.type == java.block or parent.type == java.initializer or
+ (type == java.kw_catch or
+ parent.type == java.block or parent.type == java.initializer or
parent.type == java.bogus or parent.type == java.indent_grp or
(parent.type == java.kw_switch and childIndex > 0 and type != java.then) or
(type == java.kw_break and
#4 Updated by Greg Shah almost 5 years ago
Code Review Patch #5558-3
I think it is correct. No objections.
#5 Updated by Constantin Asofiei almost 5 years ago
Greg Shah wrote:
Code Review Patch #5558-3
I think it is correct. No objections.
Thanks, the patch is in 3821c rev 12705.
#6 Updated by Greg Shah almost 5 years ago
- % Done changed from 0 to 100
- Status changed from WIP to Test
#7 Updated by Vladimir Tsichevski almost 5 years ago
- % Done changed from 100 to 50
- Status changed from Test to WIP
The fix in rev 12705 removes the extra semicolon after a label, but does not remove the extra semicolon after the while(..) line, which is the real trouble.
#8 Updated by Constantin Asofiei almost 5 years ago
Can you work around this issue? This block doesn't convert properly, either:
if hquery <> then do: MESSAGE "Hello". CATCH EXC AS java.io.IOException: END. end.
#9 Updated by Constantin Asofiei almost 5 years ago
Actually, the test above converts OK (I was missing the <> ? right-side operand).
The question about if you can work around this still stands.
#10 Updated by Vladimir Tsichevski almost 5 years ago
Constantin Asofiei wrote:
The question about if you can work around this still stands.
Do you mean the extra semicolon after the while(..) ? I can only fix this manually in the converted Java to be able to debug other problems, but I cannot put the result into production.
#11 Updated by Constantin Asofiei almost 5 years ago
Vladimir Tsichevski wrote:
Do you mean the extra semicolon after the
while(..)? I can only fix this manually in the converted Java to be able to debug other problems, but I cannot put the result into production.
Yes, I mean to find a way to write the code in 4GL to avoid this problem.
#12 Updated by Constantin Asofiei almost 5 years ago
This seems to work:
DO WHILE hQuery:GET-NEXT() :
MESSAGE "Hello".
do:
// execute Java code here
CATCH EXC AS java.io.IOException:
undo, throw new progress.lang.apperror("failed").
END.
end.
END.