Closed khatchad closed 6 years ago
In your example, the project catches InvalidClassFileException at first, then throws a IllegalArgumentException. However, in findEntryPoints():
Line 438 throws an IllegalArgumentException and line 441 throws InvalidClassFileException, i.e., the project cannot catch InvalidClassFileException at first. As such, how can I rewrite code?
I'll have a look later. Please move on if you are stuck.
@saledouble Actually, please just do the best you can and propose a fix.
The problem is that in your expectant example, the project catches InvalidClassFileException
at first, then throws IllegalArgumentException
, but in the method findEntryPoints()
, the project throws IllegalArgumentException
at first, then throws InvalidClassFileException
. It seems that the sequence of throwing makes the change impossible.
FIrst step is remove the throws clause on the method header: https://github.com/ponder-lab/Java-8-Stream-Refactoring/blob/9ad92cac25819eb617749f9b678ace4c3a5dd880/edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/Util.java#L426
Then, you need to adjust the method definition to accomidate not throwing the exception in a similar fashion as described in https://github.com/ponder-lab/Java-8-Stream-Refactoring/issues/115#issue-276666264.
@saledouble, after looking at the
Util
class a bit, I believe that theInvalidClassFileException
should be handled similarly to the other methods in the same class. Could you please quickly alter thefindEntryPoints()
method in theUtil
class to throw anIllegalArgumentException
in a similar fashion as the below method?https://github.com/ponder-lab/Java-8-Stream-Refactoring/blob/9ad92cac25819eb617749f9b678ace4c3a5dd880/edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/Util.java#L240-L248
If this exception happens, it is a problem with the argument. Thank you.