Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
Hi all
Here is a test case for a bug in Janino 2.3.18.
public class Branch { public static void main(String[] args) { try { { System.out.println("set1"); } { boolean tmp4 = false; if (tmp4) { { System.out.println("if true"); if (true) return; } } } { System.out.println("return"); } } catch (Exception e) { System.out.println("exception"); } finally { System.out.println("finally"); } } }
$ javac Branch.java
$ java Branch
set1
return
finally
$ janinoc Branch.java
$ java Branch
set1
finally
The janino compiled code seems to jump from the if () statement
to the end of the method instead of to the start of the block
containing the return statement.
cheers
Mo DeJong
Hello Arno
I am running into a problem with Janino having to do with code that
is incorrectly flagged as unreachable. I am using Janino 2.3.18.
The problem is related to this earlier bug report:
http://jira.codehaus.org/browse/JANINO-41
The trouble I am having now is that a loop will not notice when
the "keepCompiling" flag for a block is set to false.
% cat loop/Loop1.java
When compiling this code, I would get an error saying that the
return statement was not reachable. I poked around in the
source code and found what I think is the right place to patch
the problem. Included in the loop.zip file is a patch file named
loop.patch that fixes the above test case for me. Trouble is,
it does not fix all the loop problems I have run into. So, I created
the following simple test cases related to loop conditions in
the hope that these tests would help to identify the problem areas.
Loop1.java
Loop2.java
Loop3.java
Loop4.java
Loop5.java
Loop6.java
Each one compiles just fine with Javac but they fail with Janino.
I hope this helps
Mo DeJong