jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Janino
  • JANINO-41

Janino unreachable error with block statements

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major 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;

{ if (true) return; a = 1; // Physically unreachable, but not an error, i.e. "dead" }

b = 2; // Same thing.
}
}

Any advice on how this could be fixed in the source code?

thanks
Mo DeJong

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Arno Unkrig added a comment - 23/Feb/06 3:23 PM

"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.

Show
Arno Unkrig added a comment - 23/Feb/06 3:23 PM "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.

People

  • Assignee:
    Arno Unkrig
    Reporter:
    Arno Unkrig
Vote (0)
Watch (0)

Dates

  • Created:
    23/Feb/06 3:21 PM
    Updated:
    23/Feb/06 3:23 PM
    Resolved:
    23/Feb/06 3:23 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.