0% found this document useful (0 votes)
5 views

Unit 5Exception Handling

The document discusses exception handling in Java, defining exceptions as abnormal conditions that disrupt program execution. It explains the differences between errors and exceptions, the types of exceptions (checked, unchecked, and errors), and how to handle exceptions using try-catch blocks. It also covers the importance of managing exceptions to maintain the normal flow of applications and provides examples of common exceptions and their handling mechanisms.

Uploaded by

santoshpyaku
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Unit 5Exception Handling

The document discusses exception handling in Java, defining exceptions as abnormal conditions that disrupt program execution. It explains the differences between errors and exceptions, the types of exceptions (checked, unchecked, and errors), and how to handle exceptions using try-catch blocks. It also covers the importance of managing exceptions to maintain the normal flow of applications and provides examples of common exceptions and their handling mechanisms.

Uploaded by

santoshpyaku
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Unit 5: Handling Error and

Exception

Prepared By: Santosh Pyakurel

1
Exception Handling in Java
➢ An exception is an abnormal condition that arises in a code sequence at run time. In other words, an
exception is a runtime error .
➢ An exception is an unwanted or unexpected event, which occurs during the execution of a program i.e. at
run time that disrupts the normal flow of instructions.

➢ An exception is an event that occurs during the execution of a program that disrupts the normal flow of
instructions.
➢ There can be several reasons that can cause a program to throw exception. For example: Opening a non-
existing file in your program, Network connection problem, bad input data provided by user etc.
➢ When an Exception occurs the normal flow of the program is disrupted and the program/Application
terminates abnormally, which is not recommended, therefore, these exceptions are to be handled.
➢ Exceptions hinder normal execution of program. Exception handling is the process of handling errors and
exceptions in such a way that they do not hinder normal execution of the program. For example, User
divides a number by zero, this will compile successfully but an exception or run time error will occur due
to which our applications will be crashed. In order to avoid this, we should include exception handling
techniques in our code.
2
•An Exception is an unwanted event that interrupts the normal flow of the program. When an
exception occurs program execution gets terminated. In such cases we get a system generated
error message. The good thing about exceptions is that they can be handled in Java. By handling
the exceptions we can provide a meaningful message to the user about the issue rather than a
system generated message, which may not be understandable to a user.

•The exception handling in java is one of the powerful mechanism to handle the runtime errors
so that normal flow of the application can be maintained.

3
Why an exception occurs?
An exception (or exceptional event) is a problem that arises during the
execution of a program. When an Exception occurs the normal flow of the
program is disrupted and the program/Application terminates abnormally,
which is not recommended, therefore, these exceptions are to be handled.
An exception can occur for many different reasons. Following are some
scenarios where an exception occurs.
➢A user has entered an invalid data.
➢A file that needs to be opened cannot be found.
➢A network connection has been lost in the middle of communications or
the JVM has run out of memory.

4
Error vs Exception
1. Errors indicate that something severe enough has gone wrong, the application
should crash rather than try to handle the error. Errors are mostly caused by the
environment in which application is running. Example: StackOverflowError,
OutOfMemoryError
2. Exceptions are events that occurs in the code. A programmer can handle such
conditions and take necessary corrective actions. Few examples:
➢ ArithmeticException – When bad data is provided by user, for example, when you try to divide a
number by zero this exception occurs because dividing a number by zero is undefined.
➢ ArrayIndexOutOfBoundsException – When you try to access the elements of an array out of its
bounds, for example array size is 5 (which means it has five elements) and you are trying to
access the 10th element.
3. Recovering from Error is not possible. The only solution to errors is to terminate
the execution. Where as you can recover from Exception by using either try-catch
blocks or throwing exception back to caller.
4. All exception and errors types are sub classes of class Throwable, which is base
class of hierarchy. One branch is headed by Exception. This class is used for
exceptional conditions that user programs should catch. NullPointerException is an
example of such an exception.
5. Another branch, Error are used by the Java run-time system (JVM) to indicate
errors having to do with the run-time environment itself(JRE). StackOverflowError
is an example of such an error. 5
Exception-Handling Fundamentals
✓A Java exception is an object that describes an exceptional (that is, error)
condition that has occurred in a piece of code.
✓When an exceptional condition arises, an object representing that exception is
created and thrown in the method that caused the error. That method may
choose to handle the exception itself, or pass it on.
✓ Either way, at some point, the exception is caught and processed. Exceptions can
be generated by the Java run-time system, or they can be manually generated by
your code.
✓Exceptions thrown by Java relate to fundamental errors that violate the rules of
the Java language or the constraints of the Java execution environment.
✓Manually generated exceptions are typically used to report some error condition
to the caller of a method.
✓Java exception handling is managed via five keywords: try, catch, throw, throws,
and finally.
6
Exception Types
There are mainly two types of exceptions: checked and unchecked. Here, an
error is considered as the unchecked exception. According to Oracle, there are
three types of exceptions:
1. Checked Exception
2. Unchecked Exception
3. Error
1.Checked Exceptions: They are those exceptions which are checked by the
compiler during compilation to see whether the programmer has handled
them or not. If these exceptions are not handled/declared in the program, we
will get compilation error. For example, SQLException, IOException,
ClassNotFoundException etc.
The classes which directly inherit Throwable class except Runtime Exception
and Error fall under checked exceptions .
7
2.Unchecked Exceptions: They are those exceptions which are not
checked at compile-time so compiler does not check whether the
programmer has handled them or not but it’s the responsibility of the
programmer to handle these exceptions and provide a safe exit. For
example,ArithmeticException,NullPointerException,ArrayIndexOutOfBo
undsException etc.
The classes which inherit Runtime Exception are unchecked exceptions
e.g. Unchecked exceptions are not checked at compile-time, but they
are checked at runtime Unchecked Exceptions are also known as
Runtime Exceptions.

3.Errors: They represent serious and usually irrecoverable conditions


like a library incompatibility, infinite recursion, or memory leaks.
Examples: OutOfMemoryError, VirtualMachineError, AssertionError etc
8
9
All exception types are subclasses of the built-in class Throwable. Thus,
Throwable is at the top of the exception class hierarchy.
Immediately below Throwable are two subclasses that partition
exceptions into two distinct branches.
One branch is headed by Exception. This class is used for exceptional
conditions that user programs should catch. This is also the class that you
will subclass to create your own custom exception types. There is an
important subclass of Exception, called RuntimeException. Exceptions of
this type are automatically defined for the programs that you write and
include things such as division by zero and invalid array indexing.
The other branch is topped by Error, which defines exceptions that are not
expected to be caught under normal circumstances by your program.
Exceptions of type Error are used by the Java run-time system to indicate
errors having to do with the run-time environment.

10
11
Uncaught Exceptions
Before you learn how to handle exceptions in your program, it is useful to see what
happens when you don’t handle them. This small program includes an expression
that intentionally causes a divide-by-zero error:

When the Java run-time system detects the attempt to divide by zero, it constructs a
new exception object and then throws this exception. This causes the execution of
Exc0 to stop, because once an exception has been thrown, it must be caught by an
exception handler and dealt with immediately. In this example, we haven’t supplied
any exception handlers of our own, so the exception is caught by the default handler
provided by the Java run-time system. Any exception that is not caught by your
program will ultimately be processed by the default handler. The default handler
displays a string describing the exception, prints a stack trace from the point at which
the exception occurred, and terminates the program.
Here is the exception generated when this example is executed:

12
How JVM handle an Exception?
Default Exception Handling : Whenever inside a method, if an exception has occurred, the method
creates an Object known as Exception Object and hands it off to the run-time system(JVM). The
exception object contains name and description of the exception, and current state of the program
where exception has occurred. Creating the Exception Object and handling it to the run-time system is
called throwing an Exception. There might be the list of the methods that had been called to get to the
method where exception was occurred. This ordered list of the methods is called Call Stack. Now the
following procedure will happen.
▪ The run-time system searches the call stack to find the method that contains block of code that can
handle the occurred exception. The block of the code is called Exception handler.
▪ The run-time system starts searching from the method in which exception occurred, proceeds
through call stack in the reverse order in which methods were called.
▪ If it finds appropriate handler then it passes the occurred exception to it. Appropriate handler
means the type of the exception object thrown matches the type of the exception object it can
handle.
▪ If run-time system searches all the methods on call stack and couldn’t have found the appropriate
handler then run-time system handover the Exception Object to default exception handler,which is
part of run-time system. This handler prints the exception information in the following format and
terminates program abnormally.
Exception in thread "xxx" Name of Exception : Description
... ...... .. // Call Stack

13
How Programmer handles an exception?
Customized (User Defined) Exception Handling : Java exception handling is
managed via five keywords: try, catch, throw, throws, and finally. Briefly,
here is how they work.
➢Program statements that you think can raise exceptions are contained
within a try block.
➢If an exception occurs within the try block, it is thrown. Your code can
catch this exception (using catch block) and handle it in some rational
manner. System-generated exceptions are automatically thrown by the
Java run-time system.
➢To manually throw an exception, use the keyword throw.
➢ Any exception that is thrown out of a method must be specified as such by
a throws clause.
➢Any code that absolutely must be executed after a try block completes is
put in a finally block.

14
Exceptions Methods
Sr.No. Method & Description
1 public String getMessage() :Returns a detailed message about the exception that has occurred. This message
is initialized in the Throwable constructor.

2 public Throwable getCause() :Returns the cause of the exception as represented by a Throwable object.

3 public String toString() :Returns the name of the class concatenated with the result of getMessage().

4 public void printStackTrace() :Prints the result of toString() along with the stack trace to System.err, the error
output stream.
5 public StackTraceElement [] getStackTrace() :Returns an array containing each element on the stack trace. The
element at index 0 represents the top of the call stack, and the last element in the array represents the
method at the bottom of the call stack.

6 public Throwable fillInStackTrace(): Fills the stack trace of this Throwable object with the current stack trace,
adding to any previous information in the stack trace.

15
Using try and catch
Although the default exception handler provided by the Java run-time system is useful for
debugging, you will usually want to handle an exception yourself. Doing so provides two
benefits. First, it allows you to fix the error. Second, it prevents the program from automatically
terminating.

To guard against and handle a run-time error, simply enclose the code that you want to monitor
inside a try block. Immediately following the try block, include a catch clause that specifies the
exception type that you wish to catch.
try {
//statements that may cause an exception
} catch (ExceptionType name) {
//exception handling code
}

16
The following program includes a try block and a catch clause that processes the
ArithmeticException generated by the division-by-zero error:

public class DivisionByZeroExample {


public static void main(String[] args) {
try {
int numerator = 10;
int denominator = 0; // This will cause an ArithmeticException
int result = numerator / denominator;
System.out.println("Result: " + result);
} catch (ArithmeticException e) {
System.out.println("Exception caught: Division by zero is not allowed.");
}
System.out.println("Program continues after exception handling.");
}
}

17
common scenarios of Java exceptions
1. A scenario where ArithmeticException occurs: If we divide any number by
zero, an ArithmeticException occurs.
int a = 50 / 0; // ArithmeticException

2. A scenario where NullPointerException occurs: If we have a null value in any


variable, performing any operation on the variable throws a
NullPointerException.
String s = null;
System.out.println(s.length()); // NullPointerException
3. A scenario where NumberFormatException occurs: The wrong formatting of
any value may cause NumberFormatException. For example, converting a string
variable that contains characters into a digit will cause this exception.
String s = "abc";
int i = Integer.parseInt(s); // NumberFormatException
18
Multiple catch Clauses
In some cases, more than one exception could be raised by a single piece of code. To handle
this type of situation, you can specify two or more catch clauses, each catching a different
type of exception.
When an exception is thrown, each catch statement is inspected in order, and the first one
whose type matches that of the exception is executed. After one catch statement executes,
the others are bypassed, and execution continues after the try / catch block.
Syntax:
try {
// Statements that may cause an exception
} catch (ExceptionType1 name1) {
// Exception handling code for ExceptionType1
} catch (ExceptionType2 name2) {
// Exception handling code for ExceptionType2
}

19
Here two catch blocks are shown, but you can have any number of
them after a single try. If an exception occurs in the protected code
(inside try), the exception is thrown to the first catch block in the list. If
the data type of the exception thrown matches ExceptionType1, it gets
caught there. If not, the exception passes down to the second catch
statement. This continues until the exception either is caught or falls
through all catches, in which case the current method stops execution
and the exception is thrown down to the previous method on the call
stack.

20
public class MultipleExceptionsExample {
public static void main(String[] args) {
try {
int[] numbers = {10, 20, 30};
int result = numbers[5] / 0;
} catch (ArithmeticException e) {
System.out.println("Arithmetic Exception: Division by zero is not allowed.");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Array Index Out of Bounds Exception: Invalid array index
accessed.");
}
System.out.println("Program continues after exception handling.");
}
}
21
4. A scenario where ArrayIndexOutOfBoundsException occurs:
If you insert any value at an invalid index, it results in
anArrayIndexOutOfBoundsException.

int a[] = new int[5];


a[10] = 50; // ArrayIndexOutOfBoundsException

22
Nested try Statements
Sometimes a situation may arise where a part of a block may cause one
error and the entire block itself may cause another error. In such cases,
exception handlers have to be nested.

The try statement can be nested. That is, a try statement can be inside
the block of another try. Each time a try statement is entered, the
context of that exception is pushed on the stack. If an inner try
statement does not have a catch handler for a particular exception, the
stack is unwound and the next try statement’s catch handlers are
inspected for a match. This continues until one of the catch statements
succeeds, or until all of the nested try statements are exhausted. If no
catch statement matches, then the Java run-time system will handle
the exception.

23
Syntax:
try {
statement1;
statement2;
// More statements...

try {
statement1;
statement2;
// More statements...
} catch (Exception e) {
// Inner exception handling code
}

} catch (Exception e) {
// Outer exception handling code
}

24
public class NestedTryCatchExample {
public static void main(String[] args) {
try {
System.out.println("Outer try block");
int[] numbers = {10, 20, 30};

try {
System.out.println("Inner try block");
int result = numbers[5] / 0; // May cause ArrayIndexOutOfBoundsException or ArithmeticException
} catch (ArithmeticException e) {
System.out.println("Inner catch: Division by zero is not allowed.");
}

} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Outer catch: Array index out of bounds.");
}
System.out.println("Program continues after exception handling.");
}
}

25
throw
So far, you have only been catching exceptions that are thrown by the Java runtime system.
However, it is possible for your program to throw an exception explicitly using the throw
statement.
General Form of throw:
throw ThrowableInstance;
Here, ThrowableInstance must be an object of type Throwable or a subclass of Throwable.
Primitive types such as int or char, as well as non-Throwable classes like String and Object,
cannot be used as exceptions.
Ways to Obtain a Throwable Object:
1. Using a parameter in a catch clause
2. Creating one using the new operator
The flow of execution stops immediately after the throw statement. Any subsequent
statements are not executed. The nearest enclosing try block is inspected to check if it has
a catch statement matching the type of exception. If a match is found, control is
transferred to that statement. If not, the next enclosing try statement is checked, and so
on. If no matching catch is found, the default exception handler halts the program and
prints the stack trace.

26
Key Points About throw:

The Java throw keyword is used to explicitly throw an exception.


Both checked and unchecked exceptions can be thrown using throw.
The throw keyword is mainly used for custom exceptions.
Only objects of Throwable class or its subclasses can be thrown.
Execution stops immediately when a throw statement is
encountered, and the closest catch statement is checked for a match.

27
28
This program gets two chances to deal with the same error. First, main() sets up
an exception-handling context and then calls demoproc(). The demoproc()
method sets up another exception-handling context and immediately throws a
new instance of NullPointerException, which is caught on the next line.

Additionally, this program illustrates how to create one of Java’s standard


exception objects. Pay close attention to this line:
throw new NullPointerException("Error Message");
Here, new is used to construct an instance of NullPointerException. Many of
Java’s built-in runtime exceptions have at least two constructors: one without
parameters and one that takes a String parameter. When the second form is
used, the argument specifies a string describing the exception. This string is
displayed when the object is passed to print() or println(), and it can also be
obtained using getMessage(), which is defined by Throwable.
29
Throws
➢ If a method is capable of causing an exception that it does not handle, it must specify this
behavior so that callers of the method can guard themselves against the exception. This is done
by including a throws clause in the method’s declaration.
➢ The throws keyword is used to declare that a method may throw one or more exceptions. The
caller must handle these exceptions.
➢ A throws clause lists the types of exceptions that a method might throw. This is necessary for all
exceptions except those of type Error, RuntimeException, or their subclasses.
➢ Any other exception that a method can throw must be declared in the throws clause, or else a
compile-time error will occur.
➢ General Form of a Method with throws:
returnType methodName() throws ExceptionType1, ExceptionType2 {
// Method code
}
Here, exception-list is a comma-separated list of the exceptions that a method can throw.

30
If you are calling a method that declares an exception, you must either:
Case 1: Catch the exception using try-catch.
Case 2: Declare the exception using throws.
If the exception is declared but does not occur, the code executes normally.If the exception occurs
and is not caught, it will be thrown at runtime, as throws does not handle the exception.
Following is an example of an incorrect program that tries to throw an exception that it does not
catch. Because the program does not specify a throws clause to declare this fact, the program will
not compile .

31
To make this example compile, you need to make two changes. First, you need to declare that throwOne(
) throws IllegalAccessException. Second, main( ) must define a try /catch statement that catches this
exception. The corrected example is shown here:

// This is now correct.


class ThrowsDemo {
static void throwOne() throws IllegalAccessException {
System.out.println("Inside throwOne.");
throw new IllegalAccessException("demo");
}
public static void main(String args[]) {
try {
throwOne();
} catch (IllegalAccessException e) {
System.out.println("Caught " + e);
}
}
}

32
Example of throws:
public class ThrowsExample {
// Method declares that it may throw an exception
static void divide() throws ArithmeticException {
int result = 10 / 0; // This will cause ArithmeticException
}

public static void main(String[] args) {


try {
divide(); // Calling the method that may throw an exception
} catch (ArithmeticException e) {
System.out.println("Exception caught: " + e.getMessage());
}
System.out.println("Program continues normally...");
}
}

33
Advantage of Java throws keyword
➢Checked Exception can be propagated (forwarded in call stack).
➢It provides information to the caller of the method about the exception.

Let's see the example of java throws clause which describes that checked
exceptions can be propagated by throws keyword.

import java.io.IOException;

class Testthrows1 {
// Method `m()` throws an IOException
void m() throws IOException {
throw new IOException("device error"); // Checked exception
}
34
// Method `n()` also declares `throws IOException` and calls `m()`
void n() throws IOException {
m();
}

// Method `p()` calls `n()` inside a try-catch block


void p() {
try {
n();
} catch (Exception e) {
System.out.println("Exception handled");
}
}

public static void main(String args[]) {


Testthrows1 obj = new Testthrows1();
obj.p(); // Call `p()` method
System.out.println("Normal flow...");
}
}
35
Step-by-Step Execution:
▪ main() creates an object obj and calls obj.p().
▪ Inside p(), the method n() is called inside a try-catch block.
▪ n() calls m(), which throws an IOException.
▪ Since n() does not handle the exception, it propagates the exception to
p().
▪ p() catches the exception in its catch block, and "Exception handled" is
printed.
▪ Execution continues normally, printing "Normal flow...".

36
Key Concepts in the Code
Exception Propagation:IOException is thrown in m(), propagated
through n(), and caught in p().
Checked Exception Handling:IOException is a checked exception,
meaning it must be handled or declared using throws.
Program Flow Continuation:Even after an exception occurs, the
program does not crash because it is handled properly.

37
S.No. throw throws

1) Java throw keyword is used to explicitly Java throws keyword is used to declare an
throw an exception. exception.

2) Checked exception cannot be Checked exception can be propagated with


propagated using throw only. throws.

3) Throw is followed by an instance. Throws is followed by class.

4) Throw is used within the method. Throws is used with the method signature.

5) You cannot throw multiple exceptions. You can declare multiple exceptions e.g.

void method()throws IOException,SQLException.

38
Finally
• When exceptions are thrown, execution in a method takes a rather abrupt, nonlinear path that alters the
normal flow through the method. Depending upon how the method is coded, it is even possible for an
exception to cause the method to return prematurely. This could be a problem in some methods. For
example, if a method opens a file upon entry and closes it upon exit, then you will not want the code that
closes the file to be bypassed by the exception-handling mechanism. The finally keyword is designed to
address this contingency.
• finally creates a block of code that will be executed after a try / catch block has completed and before the
code following the try/catch block.
• The finally block will execute whether or not an exception is thrown.

• If an exception is thrown, the finally block will execute even if no catch statement matches the exception.
• Any time a method is about to return to the caller from inside a try/catch block, via an uncaught exception
or an explicit return statement, the finally clause is also executed just before the method returns.
• This can be useful for closing file handles and freeing up any other resources that might have been allocated
at the beginning of a method with the intent of disposing of them before returning.
• finally block in java can be used to put "cleanup" code such as closing a file, closing connection etc.
• The finally clause is optional. However, each try statement requires at least one catch or a finally clause.

39
40
• If you don't handle exception, before terminating the program, JVM executes finally block(if any)
• For each try block there can be zero or more catch blocks, but only one finally block.
• The finally block will not be executed if program exits (either by calling System.exit() or by causing
a fatal error that causes the process to abort).
• A finally block appears at the end of the catch blocks (or after try block if catch is not present, and
has the following Syntax

41
try {
// Protected code
} catch (ExceptionType1 e1) {
// Catch block for ExceptionType1
} catch (ExceptionType2 e2) {
// Catch block for ExceptionType2
} catch (ExceptionType3 e3) {
// Catch block for ExceptionType3
} finally {
// The finally block always executes
}
42
public class Example {
public static void main(String[] args) {
try {
// Protected code: trying to divide by zero
int result = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Caught ArithmeticException: " + e.getMessage());
} finally {
System.out.println("This block always executes.");
}
}
}

43
public class ExcepTest {
public static void main(String args[]) {
int a[] = new int[2];

try {
// Attempt to access a[3] which does not exist, will throw ArrayIndexOutOfBoundsException
System.out.println("Access element three :" + a[3]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Exception thrown :" + e);
} finally {
// This block always executes
a[0] = 6;
System.out.println("First element value: " + a[0]);
System.out.println("The finally statement is executed");
}
}
}

44
Java’s Built-in Exceptions
Inside the standard package java.lang, Java defines several exception
classes. A few have been used by the preceding examples. The most
general of these exceptions are subclasses of the standard type
RuntimeException. As previously explained, these exceptions need not be
included in any method’s throws list. In the language of Java, these are
called unchecked exceptions because the compiler does not check to see
if a method handles or throws these exceptions. The checked exceptions
defined by java.lang must be included in a method’s throws list if that
method can generate one of these exceptions and does not handle it
itself. These are called checked exceptions.
Java Unchecked Exceptions
Java's Unchecked RuntimeException Subclasses defined in java.lang:

45
Exception Description
ArithmeticException Arithmetic error, such as divide-by-zero
ArrayIndexOutOfBoundsException Array index is out-of-bounds
ArrayStoreException Assignment to an array element of an incompatible type
ClassCastException Invalid cast
EnumConstantNotPresentException An attempt is made to use an undefined enumeration value
IllegalArgumentException Illegal argument used to invoke a method
IllegalMonitorStateException Illegal monitor operation, such as waiting on an unlocked thread

IllegalStateException Environment or application is in incorrect state


IllegalThreadStateException Requested operation not compatible with current thread state
IndexOutOfBoundsException Some type of index is out-of-bounds
NegativeArraySizeException Array created with a negative size
NullPointerException Invalid use of a null reference
NumberFormatException Invalid conversion of a string to a numeric format
SecurityException Attempt to violate security
StringIndexOutOfBounds Attempt to index outside the bounds of a string
TypeNotPresentException Type not found
UnsupportedOperationException An unsupported operation was encountered
46
Java Checked Exceptions
Java's Checked Exceptions Defined in java.lang:
Exception Description
ClassNotFoundException Class not found
CloneNotSupportedException Attempt to clone an object that doesn't implement the
Cloneable interface

IllegalAccessException Access to a class is denied


InstantiationException Attempt to create an object of an abstract class or interface
InterruptedException One thread has been interrupted by another thread
NoSuchFieldException A requested field does not exist
NoSuchMethodException A requested method doesn't exist
ReflectiveOperationException Superclass of reflection-related exceptions
47

You might also like