Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
110 views

I am upgrading AWS' Java SDK from 1.x to 2.x. In 2.x, it seems that most exceptional cases are modeled with Unchecked Exceptions, as opposed to Checked Exceptions like it was in 1.x. When trying to ...
davidalayachew's user avatar
9 votes
2 answers
587 views

Checked Exceptions are powerful because they allow you to force the use-site to deal with an exceptional case. If the use-site does not handle an exceptional case (or publically announce that they are ...
davidalayachew's user avatar
0 votes
0 answers
195 views

For a simple Spring Boot app with Spring Security, I want to trigger a RequestRejectedException and see it in my console output. I think I'm able to trigger a runtime expection of this type, but no ...
EHammond's user avatar
0 votes
0 answers
34 views

I got one doubt regarding exception handling. We have checked and unchecked exceptions. Why they have given like that? irrespective checked or unchecked we have to handle the exception. Then i am ...
Praveen kumar's user avatar
0 votes
2 answers
188 views

In Java, both checked exception and unchecked exception can be thrown explicitly, i.e, by a throw statement. Besides, unchecked exceptions like ArithmeticException and OutOfMemoryError can be ...
cbcwestwolf's user avatar
7 votes
2 answers
712 views

I was reading about checked vs unchecked exceptions in Java and when to use each: Here's the bottom line: If a client can reasonably be expected to recover from an exception, make it a checked ...
temporary_user_name's user avatar
0 votes
0 answers
216 views

How do I determine what exception to use for unchecked exceptions? For example @Override protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) { LOG....
developers's user avatar
0 votes
1 answer
4k views

I'm trying to switch from a window to another one. This is my code: public class SelectTypeController implements Initializable { @FXML private Button buttonVai; @FXML private ComboBox&...
user avatar
-4 votes
1 answer
954 views

I'm learning Java and am a bit confused, why Lambda Expressions can't throw checked exceptions. Anyone has an understandable explanation for this? I read through this post: Java 8 Lambda function that ...
hallo545401's user avatar
1 vote
3 answers
241 views

I am very new at programming and the problem thus might seem very silly. The below mentioned method has a return type as an int array. When we don't throw any unchecked exception it throws an error ...
the_novice's user avatar
1 vote
0 answers
51 views

I am trying to read a list from a specific object key cars Input is jsonString: { "id": 600000, "name": "Ayman", "cars": [ { "manufacturer": "Volvo", "economy" : 65, "...
Ayman Arif's user avatar
  • 1,735
0 votes
1 answer
2k views

Is this the correct way to check if an exception is a checked exception at runtime? public boolean isChecked(final Throwable e) { return !(RuntimeException.class.isAssignableFrom(e.getClass()) ...
user avatar
2 votes
1 answer
513 views

Should transaction rolled back here? @Service public class Serv { @Transactional public void method1() { method2(); } private void method2(){ throw new ...
J.J. Beam's user avatar
  • 3,179
3 votes
4 answers
2k views

I want to write a custom Throwable that is unchecked. There are ways to trick the compiler at throw time (e.g. Utility class that re-throws a throwable as unchecked?), which I have implemented thus: ...
Gordon Bean's user avatar
  • 4,682
3 votes
2 answers
148 views

Why first line in main does not throw ClassCastException while the second does? import java.util.function.Function; class Scratch { static <T> T getSomething(Function<Integer, T> ...
Julian Rubin's user avatar
  • 1,255
0 votes
0 answers
104 views

In Java, calls to functions that can throw Exceptions need to anticipate them with either a try-catch or by adding a throws Exception to their function signature. My main use for them is in my top-...
Floating Sunfish's user avatar
0 votes
0 answers
25 views

I was told to propagate all exceptions. This sentence means active propagation such like : public void doSomething() throws SomeException{ try{ doSomethingThatCanThrowException(); } catch (...
Tonyukuk's user avatar
  • 6,295
0 votes
0 answers
293 views

I have a method that does comparison of two jsons. import org.json.JSONException; import org.junit.Test; import org.skyscreamer.jsonassert.*; import org.skyscreamer.jsonassert.comparator....
Saffik's user avatar
  • 1,013
3 votes
2 answers
5k views

I am trying to write a test in Kotlin that makes sure an unchecked exception is thrown in specific circumstances. I am trying to use org.junit.jupiter.api.Assertions.assertThrows like this: ...
Marcus Lanvers's user avatar
0 votes
1 answer
102 views

Why JVM does not allow to throw Unchecked Exception from static block? But it still allows them implicitly (e.g: calling method on null object). Note: The question is more academic and not from real ...
Andranik Chorokhyan's user avatar
0 votes
2 answers
1k views

As I understood, we use Guava Preconditions to fail fast, before changing some objects states (a nice answer here from stackoverflow). And this is good. However it throws Runtime exceptions and this ...
Farah's user avatar
  • 2,631
2 votes
2 answers
1k views

Are there any keywords or special syntax of code that if I look at it, I'll know that here unchecked exception is being used or a checked exception is being used? From reading previous posts that ...
Viola's user avatar
  • 43
0 votes
1 answer
290 views

I need to create a method to find an employee by employee's name. There are three possible solution to implement this as below : Employee findEmployeeById(long empId) throws ...
jason zhang's user avatar
-2 votes
1 answer
103 views

Consider the following code public void myMethod1() { try { this.getClass().getMethod("myMethod").invoke(this); } catch (Exception e) { throw e; } } public void ...
user1589188's user avatar
  • 5,788
-1 votes
1 answer
212 views

I written my own two customized Exception one is checked and other is unchecked when i'm executing my code is shows only checked Exception Why i'm not able to get unchecked Exception output?? ...
Rohit Maurya's user avatar
0 votes
1 answer
8k views

I send email in Spring Batch Tasklet. SMTP server is down so unchecked MailSendException exception occurred. Next step in transition is declared as (from email sending): FlowBuilder<Flow> ...
gavenkoa's user avatar
  • 49.7k
3 votes
1 answer
2k views

According to [1], "When deciding on checked exceptions vs. unchecked exceptions, ask yourself, What action can the client code take when the exception occurs?. If the Client code cannot do ...
Grainier's user avatar
  • 1,654
4 votes
2 answers
4k views

From the book Java 8 for the impatient by Cay Horstmann: Didn’t you always hate it that you had to deal with checked exceptions in a Runnable? Write a method uncheck that catches all checked ...
user1539343's user avatar
  • 1,679
6 votes
2 answers
6k views

I was reading an article about checked and unchecked Exceptions in Java and found this article/link: https://projectlombok.org/disableCheckedExceptions.html According to the article it's just a hack ...
NaveeNeo's user avatar
  • 205
2 votes
3 answers
5k views

Can anybody tell me how to create an array-arraylist the right way ?! .\File.java:5: warning: [unchecked] unchecked conversion ArrayList<myObjectType> myParkingLotArray[] = new ...
2vkIYKaT4mNOMe0uRjtsoT5AF's user avatar
0 votes
2 answers
684 views

I want to know how does one know to create and throw a checked exception or an unchecked exception. For example I have a service which takes some data and validates it before using it. During ...
Krishna Chaitanya's user avatar
0 votes
3 answers
2k views

Here says that it is impossible to recover from errors. I am not sure what does it mean because I can catch Error just like Exception. Eg: public static void main(String args[]) { while (true) { ...
expoter's user avatar
  • 1,650
8 votes
1 answer
3k views

I've been told that I should consider throwing Unchecked exception over Checked exception in my code and not only that, but to extend the RuntimeException with my own one. Now, I do understand the ...
Nimrod's user avatar
  • 1,140
5 votes
2 answers
136 views

I've got a method which invokes another method like this: public void m1() { m2(10); } public void m2(int v) { if(v < 10) throw new MyException(); } public class MyException ...
Alupkers's user avatar
  • 223
1 vote
2 answers
5k views

For a project I've been working on, we have some blocks that look like this: Class A: try { callSomeMethod(); } catch (Exception e) { throw new SomeCustomExceptionTypeForMetrics(""); } ...
CustardBun's user avatar
  • 3,906
20 votes
2 answers
6k views

I mostly understand the potential issues with checked exceptions and why Kotlin omits them. However, the issue I am encountering is I can't find any foolproof way of clearly indicating to the caller ...
zjuhasz's user avatar
  • 1,559
1 vote
2 answers
4k views

I have public method add(String) that calls private method inspectSequence(String) to check whether String valid or not. This method returns array if passed String is valid, if it's invalid then ...
Mike Herasimov's user avatar
35 votes
3 answers
8k views

In Java, methods that throw checked exceptions (Exception or its subtypes - IOException, InterruptedException, etc) must declare throws statement: public abstract int read() throws IOException; ...
AdamSkywalker's user avatar
0 votes
1 answer
157 views

I am aware of the Checked and Unchecked Exception in Java. In a multi-tiered environment, does unchecked Exception has a better performance over checked Exception?
SyntaX's user avatar
  • 2,128
1 vote
4 answers
199 views

Whether the Customized Exception is Checked or Unchecked Exception? How?
dgl viru's user avatar
  • 177
-3 votes
1 answer
2k views

I'm trying to learn about exceptions in Java and, for educational purposes, it would be nice if I could get hold of a reference of all checked exceptions and all unchecked exceptions in the standard ...
Sizons's user avatar
  • 684
1 vote
2 answers
2k views

Okay guys I've been trying to figure this out for the past day or so. My homework assignment has me creating both Unchecked and Checked Exceptions. The checked exceptions I believe I get basically ...
Joseph hooper's user avatar
1 vote
2 answers
123 views

I was trying out to run the below code sample but getting StackOverflow error. It seems to stuck up in the infinite loop. Can anybody help me out in knowing what's going on in here? Please find below ...
Sunny Gujarati's user avatar
5 votes
2 answers
1k views

I have been re-factoring some Java code lately... I have found that there were many RuntimeExceptions being thrown (i.e. unchecked exceptions). I have created my own checked exception and replaced ...
Chris Bolton's user avatar
  • 2,324
3 votes
2 answers
1k views

Can Unchecked Exceptions be converted into Checked Exceptions in Java? If yes, please suggest ways to convert/wrap an Unchecked Exception into a Checked Exception.
Randhish kumar's user avatar
1 vote
1 answer
110 views

Why it is not recommended to handle unchecked exceptions by using try...catch blocks? Why we need to avoid them through some conditional checkings only?
user3971066's user avatar
0 votes
1 answer
1k views

I have a service that allow users to add dynamic content to a repository. So basically I have a generic Document class that contains a list of property for that specific object depending on what type ...
Nicola's user avatar
  • 2,976
5 votes
2 answers
914 views

While creating custom exceptions, If we want to create a checked Exception we extend the Exception class and for unchecked exception we extend the RuntimeException class. My question is, how JVM ...
gaurs's user avatar
  • 603
15 votes
3 answers
2k views

If I have a method which throws an unchecked exception, e.g.: void doSomething(int i) { if (i < 0) throw new IllegalArgumentException("Too small"); // ... } is there any advantage to ...
Andy Turner's user avatar
0 votes
1 answer
185 views

I'm working on webservices with Axis and among the checked exceptions that its methods declare I have: ServiceException, RemoteException and AxisFault (those depend, of course, on the specific method ...
watery's user avatar
  • 5,557