Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Labels:None
Description
Hello
I ran into a problem with incorrect generation of an unreachable statement
error using Janino. In the following test case, foo() compiles but bar()
generates a compile time error. This class compiles correctly with javac.
% cat IfNoReach.java
public class IfNoReach {
void foo() {
if (true) {
return;
}
return;
}
void bar() {
{
if (true) { return; } }
}
return;
}
}
I poked around the the code, and there seems to be specific If statement and block logic
to deal with this issue. Sadly, it does not work. I found the following test case in the
janino code, it does not pass currently.
% cat DeadCode.java
public class DeadCode {
void foo() {
int a, b;
b = 2; // Same thing.
}
}
Any advice on how this could be fixed in the source code?
thanks
Mo DeJong
"Block.followingStatementsAreDead()" now calls itself recursively for immediately enclosing blocks. Maybe not the ultimate solution to this REALLY difficult problem, but it fixes the case documented in this issue.
Will be released as 2.3.18.