Results 1 to 4 of 4
  1. #1
    Exploit is offline Member
    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Default Error: Missing Return Statement (Help!)

    Hello, can someone please explain why this error is popping up?


    Java Code:
    final class Class203 {
        static final Object method2704(String string, Applet applet, int i)
                throws Throwable {
            try {
                if (i != -26978)
                    return null;
               // return JSObject.getWindow(applet).call(string, null);
            } catch (RuntimeException runtimeexception) {
                throw runtimeexception;
            }
        } <- Error is here
    Also on this


    Java Code:
    static final Object method2705(int i, Applet applet, String string,
                                       Object[] objects) throws Throwable {
            try {
                if (i != 26635)
                    return null;
               // return JSObject.getWindow(applet).call(string, objects);
            } catch (RuntimeException runtimeexception) {
                throw runtimeexception;
            }
        } <-Error is here
    Last edited by Exploit; 07-13-2013 at 03:52 AM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,501
    Rep Power
    5

    Default Re: Error: Missing Return Statement (Help!)

    Your method signatures say they will return a type of Object. Yet it is possible to reach code where nothing is returned.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    Exploit is offline Member
    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Default Re: Error: Missing Return Statement (Help!)

    Hi Jim, can you try to explain a little bit more? Do you know a fix for this?

    This is the compile message

    Class85.java:67: warning: non-varargs call of varargs method with inexact argume
    nt type for last parameter;
    = (Integer) method.invoke(runtime, null);
    ^
    cast to Object for a varargs call
    cast to Object[] for a non-varargs call and to suppress this warning
    Class203.java:20: error: missing return statement
    }
    ^
    Class203.java:34: error: missing return statement
    }
    ^
    Class340.java:893: warning: non-varargs call of varargs method with inexact argu
    ment type for last parameter;
    null);
    ^
    cast to Class for a varargs call
    cast to Class[] for a non-varargs call and to suppress this warning
    Class340.java:894: warning: non-varargs call of varargs method with inexact argu
    ment type for last parameter;
    Object object = method.invoke(null, null);
    ^
    cast to Object for a varargs call
    cast to Object[] for a non-varargs call and to suppress this warning
    Class96.java:365: warning: non-varargs call of varargs method with inexact argum
    ent type for last parameter;
    = (Long) method.invoke(runtime, null);
    ^
    cast to Object for a varargs call
    cast to Object[] for a non-varargs call and to suppress this warning
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors
    4 warnings
    Press any key to continue . . .
    Last edited by Exploit; 07-13-2013 at 04:18 AM.

  4. #4
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Location
    Sweden
    Posts
    264
    Rep Power
    2

    Default Re: Error: Missing Return Statement (Help!)

    your method has an if condition that if it is true it will return Object, null in your method, that's fine but you need to return Object in case the condition is not true.

    Java Code:
    final class Class203 {
        static final Object method2704(String string, Applet applet, int i)
                throws Throwable {
            try {
                if (i != -26978) {
                    return null;
                }
               return statement here <- 
            } catch (RuntimeException runtimeexception) {
                throw runtimeexception;
            }
        }
    It is the same case as this
    Java Code:
    boolean isTrue() {
    if (condition) {
      return true;
    } //  this method get return statement missing.
    }
    should do this:

    Java Code:
    boolean isTrue() {
    if (condition) {
      return true;
    } else {
      return false;
    }
    }

Similar Threads

  1. missing return statement
    By brian in forum New To Java
    Replies: 2
    Last Post: 05-27-2013, 08:02 PM
  2. Missing return statement
    By Aenohe in forum New To Java
    Replies: 8
    Last Post: 03-07-2012, 01:03 PM
  3. Missing return statement... but there is one
    By Eleeist in forum New To Java
    Replies: 4
    Last Post: 02-05-2012, 07:24 PM
  4. Missing return statement
    By gkoef in forum New To Java
    Replies: 8
    Last Post: 01-01-2011, 02:52 AM
  5. missing return statement
    By bayan in forum New To Java
    Replies: 6
    Last Post: 04-26-2010, 03:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •