Wrong code analysis on "unreachable statement" for nested loops

Try this with JavaFX 1.2 (NetBeans 6.5.1)
function foo():Void {
    for (i in [0..<10]) {
        for (j in [0..<10]) { // be marked as unreachable statement
            if (match()) {
                break;
            return; // I just want to get out
        // break goes here
}It shows "unreachable statement" at the second 'for'.
Right now I just change "return;" to "if (true) return;" to get it pass.

I agree it is a bug at the compiler level. If I do your change and add println of i and j, I get a trace on j, obviously.
You should file a bug report at [Jira / Kenai|http://javafx-jira.kenai.com/] (or I can do if you don't want to create an account).
[EDIT] Uh, no, it is a known problem: [Bogus 'Unreachable statement' error|http://javafx-jira.kenai.com/browse/JFXC-3323], I will add this thread as a comment.
A more complete use case:
function foo(): Void {
     for (i in [ 0 ..< 5 ]) {
          println("I {i}");
          for (j in [ 0 ..< 5 ]) {
               println("J {j}");
               if (match()) {
                    break;
               println("Some operation in the inner loop");
               if (true) return;
          // break goes here
function match(): Boolean { return Math.random() > 0.5; }
foo();Now, the inner loop isn't really necessary, we never go beyond 0 for j... But technically, there is no unreachable statement, unless it means we never go up to 5 in the inner loop. In this case, Robert Field is right, the error message should be clearer.
Edited by: PhiLho on 29 juil. 2009 10:17

Similar Messages

  • Alternative for nested loops

    Hi Gurus,
    I have the following problem :
    There are 2 internal tables namely 1 &2.
    Now there is a field in table 1 'AUGBL' which should be equal to  field in Table2-BELNR.
    Now if there is a match between TABLE1-AUGBL and TABLE2-BELNR,
    so we move to table 2 to look for 'augbl' associated with 'belnr' in the same table.
    Then I have to give the following logic -
    If table2-belnr = table2-augbr,
       Then do nothing.
    Else.
    Check, for the Augbl which will equal Belnr in a different position in table 2.
    For ex:
    Table1-AUGBL = 2.
    So now we have to search a field when Table1-augbl = Table2-belnr = 2.
    Now for this record in table2, there are 2 conditions:
    When Table2-augbl = 2, (in which case we do nothing)
    or,
    Table2-augbl NE 2, or Table2-augbl = 3.
    In the latter case,  there will be another field in Table2-BELNR = 3. So we go to this record now and check for the associated AUGBL and do the same checks above.
    We keep on continuing for this till the time we do not get the Table2-belnr = Table2-augbl in the end for the same record.
    Now I want to achieve this without using nested loop.
    Kindly help as I already have wated a lot of time.
    Please let me know if there are any clarifications.

    Hey..
    Before u get the data into two internal tables through SELECT stmts.
    U can use JOIN instead of two SELECT stmts ..that wud fetch the data into single internal table..
    and that may ease ur validations and further process..
    try this out..
    Thanks and Regards,
    KC

  • Logic for nested loops

    Hi guy's,
    I required tipical logic pls any body help me,
    I have to fethch EBELN ,BEDAT from EKKO and  MATNR from EKPO
    based on that i have to go KEKO table based on MATNR
    I have to fetch KALNR and KADKY ,  BEDAT should be between range of BIDAT and KADAT.
    Based on KALNR   i have to go for CKIS table now i fetch  COMPONENT MATERIALS and ELEMT
    If i get the ELEMT 000 again i have to take COM.MATNR  again we have to go KEKO I have to get take KALNR KADKY and
    again i have to go for CKIS .
    I have to continue this logic up to in ELEMT = 010 .Here iam geting the problem.
    MATNR   ELEMT        I have to continue this loop up to elemt become 010 . how many tables i have to declared how to read
    A             000                the tabel.Pls any body help me.
    B              010
    C              010
    D              000
    Thanks
    santhosh
    Edited by: santhosh kumar on Sep 2, 2009 10:13 PM

    Hi,
    You have all the tables and field names and the link between each of the tables. Why dont you start with the select query as per the requirement? You can always revert back if you are stuck up anywhere. Generic questions are not allowed here.
    Regards,
    Vikranth

  • Is there any plug-ins for static code analysis in Jdeveloper

    Hi,
    Is there any PMD, check style and static code analysis plug-ins available for JDeveloper? Those are available for Eclipse. How to achieve that in the JDeveloper?
    Regards,
    Raghu.

    This should help-
    PMD plugin for JDeveloper 11.1.2.0
    http://develishdevelopment.wordpress.com/2012/03/12/have-released-pmd-jdeveloper-extension-4-3/
    Always mention you Jdev version. Here I just assumed yours :P

  • Any code analysis , audit tool for adf

    Hi,
    Anyone aware of any code analysis and audit tool for ADF.
    Thanks,
    Rohit

    duplicate.
    Free Security testing tool ADF
    Edited by: ADF 7 on Jan 18, 2012 11:05 PM

  • Switch statement for AS3  - Flash CS3

    Hey guys, I currently have a code of a switch statement for as1- as2.
    This is it:
    switch (int(Math.random() * 20))
        case 0:
            hint = "The total amount of confusion in this world remains constant. It just gets shifted around.";
            break;
        case 1:
            hint = "If you experience poor performance, adjust the quality settings in your preference menu option.";
            break;
        case 2:
            hint = "Anticipation of death is better than death itself.";
            break;
        case 3:
            hint = "At the core of all well-founded belief lies belief that is unfounded.";
            break;
        case 4:
            hint = "The problem with instant gratification is that it takes too long.";
            break;
        case 5:
            hint = "Never let your schooling interfere with your education.";
            break;
        case 6:
            hint = "Beware of geeks bearing gifs.";
            break;
        case 7:
            hint = "Collaboration is essential: It allows you to blame someone else.";
            break;
        case 8:
            hint = "Read my MIPs - no new VAXes.";
            break;
        case 9:
            hint = "Where is the sea, said the fish, as they swam through it.";
            break;
        case 10:
            hint = "You can safely blame any bugs on Aoedipus, who is too busy grinding battlegrounds to do QA on her own work.";
            break;
        case 11:
            hint = "Anything worth doing is worth overdoing.";
            break;
        case 12:
            hint = "There is more to life than increasing its speed.";
            break;
        case 13:
            hint = "Don\'t worry, this will take about as long as the time it takes to play a 2v2 match with 4 ret pallies.";
            break;
        case 14:
            hint = "There is nothing worse than the brilliant image of a fuzzy concept.";
            break;
        case 15:
            hint = "If you are not part of the solution, you are part of the precipitate.";
            break;
        case 16:
            hint = "Two wrongs don\'t make a right, but three lefts do.";
            break;
        case 17:
            hint = "The heresy of today is the logic of tomorrow.";
            break;
        case 18:
            hint = "It\'s not that life is so short, it\'s just that you\'re dead a really long time.";
            break;
        case 19:
            hint = "Those who love sausage, the law, and holy canon should never watch any of them being made.";
            break;
        case 20:
            hint = "What if there were no hypothetical questions?";
            break;
    } // End of switch
    hint = "HINT: " + hint;
    This code is for a dynamic tet with the var 'hint' (No ' ' )
    But in as3 there is no var and I am having trouble converting it to AS3 coding, can someone show me the correct conversion of the code to make it work with AS3. I will make the instance name 'hint'.
    Thank you ahead of time.

    In addition to what other guys said, if you still want to use switch it should be:
    switch (Math.round(Math.random() * 20)) - this will cover all the possible integers.
    Nevertheless, I believe using switch in this case is not as efficient and scalable as using, say, array.
    1. array index access is faster than switch.
    2. if you need to make additions, you will need to make additions in switch while with array you just need to add/subtract member
    3. if you will need to switch to a more dynamic model (say, getting hints from xml) - it will not be possible with switch
    4. you may need a greater degree of randmization (Math.random is not as random as one may think) in which case resorting/reordering array is much simpler and faster.
    So, I suggest you switch to the following code:
    var hints:Array = [];
    hints[0] = "Anticipation of death is better than death itself.";
    hints[1] = "Anything worth doing is worth overdoing.";
    hints[2] = "At the core of all well-founded belief lies belief that is unfounded.";
    hints[3] = "Beware of geeks bearing gifs.";
    hints[4] = "Collaboration is essential: It allows you to blame someone else.";
    hints[5] = "Don\'t worry, this will take about as long as the time it takes to play a 2v2 match with 4 ret pallies.";
    hints[6] = "If you are not part of the solution, you are part of the precipitate.";
    hints[7] = "If you experience poor performance, adjust the quality settings in your preference menu option.";
    hints[8] = "It\'s not that life is so short, it\'s just that you\'re dead a really long time.";
    hints[9] = "Never let your schooling interfere with your education.";
    hints[10] = "Read my MIPs - no new VAXes.";
    hints[11] = "The heresy of today is the logic of tomorrow.";
    hints[12] = "The problem with instant gratification is that it takes too long.";
    hints[13] = "The total amount of confusion in this world remains constant. It just gets shifted around.";
    hints[14] = "There is more to life than increasing its speed.";
    hints[15] = "There is nothing worse than the brilliant image of a fuzzy concept.";
    hints[16] = "Those who love sausage, the law, and holy canon should never watch any of them being made.";
    hints[17] = "Two wrongs don\'t make a right, but three lefts do.";
    hints[18] = "What if there were no hypothetical questions?";
    hints[19] = "Where is the sea, said the fish, as they swam through it.";
    hints[20] = "You can safely blame any bugs on Aoedipus, who is too busy grinding battlegrounds to do QA on her own work.";
    hint = hints[int(Math.random() * hints.length)];
    // OR
    hint = hints[Math.round(Math.random() * (hints.length - 1))];

  • "for each" loop - under the hood question

    Question about the for each loop. Is it optomized? I think this is a poor use of memory management -
    for (int i = 0; i < stop; i++) {
    Object obj = new Object();
    doSomething(obj);
    }And this is the ideal, using the same object -
    Object obj = new Object();
    for (int i = 0; i < stop; i++) {
    doSomething(obj);
    }So underneath the hood, which is the for each loop comparable to? I love the syntax, it's very clean-looking in the code, but at the same time I don't want to hurt performance.

    Question about the for each loop. Is it optomized? I
    think this is a poor use of memory management -
    for (int i = 0; i < stop; i++) {
    Object obj = new Object();
    doSomething(obj);
    }And this is the ideal, using the same object -
    Object obj = new Object();
    for (int i = 0; i < stop; i++) {
    doSomething(obj);
    }So underneath the hood, which is the for each loop
    comparable to? I love the syntax, it's very
    clean-looking in the code, but at the same time I
    don't want to hurt performance.That depends on YOU. You CANNOT write a for-each loop for the code you provided. A for-each loop requires an Iterable. (I think that's what it requires--it at least requires something to iterate over, not just an index variable as you have.)
    Consider the following, however:
    Object o1 = new Object();
    for (Foo foo : fooList) {
        Object o2 = new Object();
         foo.doStuff(o1, o2);
    } It will be equivalent to this:Object o1 = new Object();
    for (Iterator iter = foo.iterator(); iter.hasNext();) {
        Foo foo = (Foo)iter.next();
        Object o2 = new Object();
        foo.doStuf(o1, o2);
    } How could it be any different? It has to keep the behvior of the "old fashioned" iteration.

  • Hash join vs nested loop

    DECLARE @tableA table (Productid varchar(20),Product varchar(20),RateID int)
    insert into @tableA values('1','Mobile',2);
    insert into @tableA values('2','Chargers',4);
    insert into @tableA values('3','Stand',6);
    insert into @tableA values('4','Adapter',8);
    insert into @tableA values('5','Cover',10);
    insert into @tableA values('6','Protector',12);
    --SELECT * FROM @tableA
    DECLARE @tableB table (id varchar(20),RateID int,Rate int)
    insert into @tableB values('1',2,200);
    insert into @tableB values('2',4,40);
    insert into @tableB values('3',6,60);
    insert into @tableB values('4',8,80);
    insert into @tableB values('5',10,10);
    insert into @tableB values('6',12,15);
    --SELECT * FROM @tableB
    SELECT Product,Rate
    FROM @tableA a
    JOIN @tableB b ON a.RateID = b.RateID
    Above is the sample query, where in execution plan it shows the Hash Match (inner Join). Now how do I change it to Nested Loop with out changing the query? help plz

    Is Hash Match(inner join) or Nested loop is better to have in the query?
    That depends on the size of the tables, available indexes etc. The optimizer will (hopefully) make the best choice.
    Above is the sample query, where in execution plan it shows the Hash Match (inner Join). Now how do I change it to Nested Loop with out changing the query?
    The answer that you should leave that to the optimizer in most cases.
    I see that the logical read for nested loop is higher than Hash Match.
    But Hash Match tends to need more CPU. The best way to two compare two queries or plans is wallclock time.
    On a big tables, how do we reduce the logical read? 
    Make sure that there are usable indexes.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • NESTED LOOP or SORT MERGE

    Hi All,
    How can we judge which one is best to use for the query- NESTED LOOP
    - SORT MERGE
    - HASH JOINThanx.. Ratan

    Hi...
    For Nested Loop Joins:
    Nested loop joins are useful when small subsets of data are being joined and if the join condition is an efficient way of accessing the second table.
    It is very important to ensure that the inner table is driven from (dependent on) the outer table. If the inner table's access path is independent of the outer table, then the same rows are retrieved for every iteration of the outer loop, degrading performance considerably. In such cases, hash joins joining the two independent row sources perform better.
    For Hash Join:
    Hash joins are used for joining large data sets. The optimizer uses the smaller of two tables or data sources to build a hash table on the join key in memory. It then scans the larger table, probing the hash table to find the joined rows.
    For Sort Merge Joins:
    Sort merge joins can be used to join rows from two independent sources. Hash joins generally perform better than sort merge joins. On the other hand, sort merge joins can perform better than hash joins if both of the following conditions exist:
    The row sources are sorted already.
    A sort operation does not have to be done.
    However, if a sort merge join involves choosing a slower access method (an index scan as opposed to a full table scan), then the benefit of using a sort merge might be lost.
    Sort merge joins are useful when the join condition between two tables is an inequality condition (but not a nonequality) like <, <=, >, or >=. Sort merge joins perform better than nested loop joins for large data sets. You cannot use hash joins unless there is an equality condition.
    In a merge join, there is no concept of a driving table. The join consists of two steps:
    Sort join operation: Both the inputs are sorted on the join key.
    Merge join operation: The sorted lists are merged together.
    If the input is already sorted by the join column, then a sort join operation is not performed for that row source.

  • Is merge join cartesian more cpu intensibe than nested loop ?

    Hi,
    just wonderning which access method is more cpu intensive , lets supposed we got 2 the same row sources and doing joing via merge join cartesian and next case is nested loop .
    I know NL can be cpu intensive because of tight loop access , but what abour MJC ?
    I can see bufferd sort but not sure is that cpu friendly ?
    Regards
    GregG

    Hi,
    I think in your case it's more accurate to compare a NESTED LOOP (NL) to a MERGE JOIN (MJ), because CARTESIAN MERGE JOIN is a rather special case of MJ.
    Merge join sorts its inputs before combining them, and it could be efficient when one or both of inputs are already sorted.
    Regarding your question (which is more CPU intensive):
    1) if MERGE JOIN involves disk spills, then CPU is probably irrelevant, because disk operations are much more expensive
    2) the amount of work to combine rowsources via a MJ depends on how well they are aligned with respect to each other, so I don't think it can be expressed via a simple formula.
    For nested loops, the situation is much more simple: you don't need to do any special work do combine the rowsource, so the cost is just the sum of the cost acquiring the outer rowsource plus the number of iterations times the cost of one iteration. If the data is read from disk, then CPU probably won't matter much, if most of reads are logical ones than CPU becomes of a factor (it's hard to tell how much work CPU will have to do per one logical read because there are two many factors here -- how many columns are accessed, how they are located within the block, are there any expensive math functions applied to any of them etc.)
    Best regards,
    Nikolay

  • I need help with this code error "unreachable statement"

    the error_
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errors
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    public class Tools//tool class
    private int numberOfToolItems;
    private ToolItems[] toolArray = new ToolItems[10];
    public Tools()//array of tool
    numberOfToolItems = 0;
    for(int i = 0; i < toolArray.length; i++)//for loop to create the array tools
    toolArray[i] = new ToolItems();
    }//end for loop
    }//end of array of tools
    public int search(int id)//search mehtod
    int index = 0;
    while (index < numberOfToolItems)//while and if loop search
    if(toolArray[index].getID() == id)
    return index;
    else
    index ++;
    }//en while and if loop
    return -1;
    }//end search method
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0;
    int index;
    index = search(id); <-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    }//end delete method
    public void display()//display method
    for(int i = 0; i < numberOfToolItems; i++)
    //toolArray.display(g,y,x);
    }//end display method
    public String getRecord(int i)//get record method
    // return toolArray[i].getName()+ "ID: "+toolArray[i].getID()
    }//end getrecod
    }//end class
    Edited by: ladsoftware on Oct 9, 2009 6:08 AM
    Edited by: ladsoftware on Oct 9, 2009 6:09 AM
    Edited by: ladsoftware on Oct 9, 2009 6:10 AM
    Edited by: ladsoftware on Oct 9, 2009 6:11 AM

    ladsoftware wrote:
    Subject: Re: I need help with this code error "unreachable statement"
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errorsThe compiler is telling you exactly what the problems are:
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0; // <<== HERE you return, so everyting in the if block after this is unreachable
    int index;
    index = search(id);  //< -----------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    // <<== HERE where is the return statement?
    }//end delete method
    public String getRecord(int i)//get record method
    // return toolArray.getName()+ "ID: "+toolArray[i].getID() <<== HERE you commented out the return statement
    }//end getrecod
    }//end class

  • Two statements for one report (Analysis)

    Hi all,
    please help me understand the behavior of OBIEE.
    When I open my Analysis, it asks for input parameters. These parameters are collumn prompts with checked "require user input". Sure, user can't run Analysis without any parameters.
    Now what is strange. In Administration -> Manage sessions I can see TWO statements, created by me. I didn't run this report twice. This happens often. It's not all. These two statements are not equal. One of them has WHERE clause with my parameters I've set, but another statement DOESN'T have any WHERE clause. Actually, the first statement runs for a minute or like that. But the second statement can run for an hour and longer. But this is not just my observation, users complain about slow performance. The Analysis DOESN'T return any result untill both statements end their work although the first statement with WHERE clause is already finished.
    How I deal with it... I perform cansel in Administration -> Manage sessions and then run Analysis again with the same input parameters. It returns result in few seconds, it seems like using cache (but repository object is not cashable).
    What is wrong here? This looks like inappropriate behavior. This is not huge problem for business, because we have only few users at this stage. Most of users still use SAP Business Objects. So I can waste my time for canselling of statements for these few users. But the question is what will be in the future. Please, help me.
    Oracle Business Intelligence 11.1.1.6.6

    Remove a column at a time, and see if that makes BI fire only one query. Once you identify column forcing query to split, check RPD model for the logical table for that field. Check content level, logical sources, physical and logical diagrams etc. Also perform consistency check.

  • Transaction code for vendor account statement for perticular duration

    Transaction code for Accounts payable
    statement for perticular date
    duration...... (from date and to date)

    Hi,
    You can use the following reports, there are quite a few other reports but the ones below can be used easily to tweak to your requirement using the many selection and display options available:
    1. S_ALR_87012103 - List of Vendor Line Items
    2.  FBL1N
    Cheers.

  • F.27 - combined statement for different company codes

    Hi,
       In F.27 transaction, for sending account statement to customer, for a customer with open items in different company codes, a different account statement is generated for each company code. The business wants one statement per customer, with open items from all company codes. We have been working on a investigating a solution, but making a Z-copy of the programs and modify looks too complicated. Is there a solution in FI configuration, which leads to generation of just one account statement per customer.
    Help would be appreciated.
    Thanks
    PH

    HI
    Have you tested the statement by giving multiple company codes in F.27 in Company code selection? You have the option of selecting multiple company codes here, It should solve your problem.
    Award points if usefull.
    sarma

  • How to consolidate the financial statements for 3 company codes, assigned t

    Hi Friends,
    How to consolidate the financial statements for 3 company codes, assigned to 3 different companies, 3 different fiscal years, 3 different controlling areas and all the 3 Company Codes assigned to same chart of accounts in the same client?
    Can we need any ABAP program for this (or) Is it possible using Report Painter?
    Please help me.
    Thanks

    Hi friend,
    Is it a real-time situation or something you are visualising ?
    For consolidation, you can use a group chart of accounts and select that in the operative chart of accounts for consolidation purposes.  This would work provided the company codes use the same operative chart of accounts and fiscal year.
    I hope the above would be helpful to you.
    Regards,

Maybe you are looking for

  • Open Dialog box: disable image preview (For large images, it's SLOOOWWWW)

    Open Dialog box in column view: Can I disable image preview? For large images, it's SLOOOWWWW !!!!! ( I often work with 8000 x 3500 panoramic images )

  • Can I use J2ME to send/receive GPRS data?

    Hi guys Firstly, I hope I'm on the most suitable forum - if not, feel free to redirect me to the best place for this question. I'm working on a vehicle tracking project and we're evaluating several devices that are designed to be placed inside vehicl

  • Custom reports execution in Winclient CIC

    I wanted to know the possibility of running customer on-line reports within winclient cic. this allows the agent not to leave the cic to run reports that extracts information for the customer call. thanks in advance for the answer.

  • Inability to see/open RAW images Elements 5.0

    I have a new laptop -which runs on the Vista OS I put on my copy of PSE 5.0 and can do everything under the sun with JPEG images as I could prior with the now defunct laptop. However I cannot get it to recognize RAW files. I've done the most current

  • Implementing a dynamic navigation

    I want to include dynamic a navigation structure under a specific role into the navigation of the portal. The navigation structure should consist of an XML file. The link should opened in the mittle of the portal (content area).