2

This is my first time editing a program made in java, i just know how to program in PHP, the problem is that I'm editing a program previously done in Java, as was done just dedicated myself to add a few lines of code to extend its capabilities (copy and paste only ) Well is that I have this WebScraper.class file and I could decompile and convert java to edit ,when compile I get the following error:

I tested with Eclipse and when I give Run does nothing , I tried changing the version of JDK and nothing I tried on another computer and still nothing , I've been reading on previous responses is due to the "goto " but I have not managed to fix it , since I do not know how this part must be programmed to be successfully compiled. Greatly appreciate your help, or tell me how to use the Eclipse or exactly what to put to fix the mistakes I have.

C:\Users\Tecnicom\Downloads\Prog>javac WebScraper.java
WebScraper.java:99: error: illegal start of expression
        if (i >= 3) goto _L2; else goto _L1
                    ^
WebScraper.java:99: error: not a statement
        if (i >= 3) goto _L2; else goto _L1
                         ^
WebScraper.java:99: error: 'else' without 'if'
        if (i >= 3) goto _L2; else goto _L1
                              ^
WebScraper.java:99: error: illegal start of expression
        if (i >= 3) goto _L2; else goto _L1
                                   ^
WebScraper.java:99: error: ';' expected
        if (i >= 3) goto _L2; else goto _L1
                                           ^
WebScraper.java:143: error: illegal start of expression
          goto _L3
          ^
WebScraper.java:144: error: ';' expected
_L2:
   ^
7 errors

I'll show a part of the code where it show the error:

  static Hashtable parseFirmwarePage(String s)
    {
        Matcher matcher = pattern.matcher(s);
        Hashtable hashtable = new Hashtable();
        do
        {
            if(!matcher.find())
                break;
            String s1 = matcher.group(1);
            if(s1 != null && s1.trim().length() != 0 && displayFields.contains(s1))
            {
                String s3 = matcher.group(2);
                if(s3 != null && s3.trim().length() != 0 && !s3.toLowerCase().contains("todo"))
                    hashtable.put(matcher.group(1), s3);
            }
        } while(true);
        String s2 = String.format("%s_%s", new Object[] {
            hashtable.get("device"), hashtable.get("build")
        });
        if(s2.equalsIgnoreCase("ipod11_7E18"))
            hashtable.put("downloadurl", "iPod1,1_3.1.3_7E18_Restore.ipsw");
        return hashtable;
    }

    static String wikiMarkupForPage(String s)
    {
        int i = 0;
_L3:
        if(i >= 3) goto _L2; else goto _L1
_L1:
        if(i != 0)
        {
            gui.error("The iPhone Wiki seems a bit down; retrying in %d sec..", new Object[] {
                Integer.valueOf(30)
            });
            try
            {
                Thread.sleep(30000L);
            }
            catch(InterruptedException interruptedexception)
            {
                gui.exc(interruptedexception);
            }
        }
Makoto
  • 104,088
  • 27
  • 192
  • 230
Zhamir
  • 21
  • 2

2 Answers2

1

goto is a keyword which has no use. It has use in other language such as C or C++, but not Java.

The keywords const and goto are reserved, even though they are not currently used. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in programs.

Given that it's tough to say what you should do since we don't know your code structure, consider this:

  • goto in general was used to jump to a specific identifier. You may want to replace this with a method call instead.
  • Think about the natural flow of your program, if not in an OO fashion, at least through a procedural fashion. The OO can come on a second revision of the code.
Makoto
  • 104,088
  • 27
  • 192
  • 230
0

Following Sun specifications, the keyword goto is reserved, even though not currently used. That's probably the reason why your code shows errors.

You may have to reformulate its flow and replace this keyword for the desired behavior specified on Labels, or with method calls.

BernatL
  • 72
  • 10