The problem is caused by the fact that UnknownInputException is probably a nested class, and if you create an instance with the new operator as a nested class, it must have access to the "parent" object - which does not exist because the class was created in a static context. For more information about this, see Static Method Returning an Inner Class .
A possible solution would be to declare UnknownInputException as static as follows:
private static class UnknownInputException extends Exception { ... }
Of course, you will not be able to access any instances of (non-static) methods and / or fields of this class, but this may not be a problem in your case (especially in the case of the Exception class).
In addition, the return ing value after the throw line is not required, since execution will never reach that line.
dnet
source share