There's some third party code that looks like the following. Assume there are two classes, classA and classB, their definitions are correct and they work as expected.
// this function does not have a *throws Exception* in its definition
public Collection<classA> doSomething(String someStr) {
List<ClassA> ClassAList = new ArrayList<ClassA>();
int a = 0;
while (a < 5) {
classAList.add(
new classA(
someStr,
new Callable<classB>() {
public classB call() throws Exception {
// do some work here
try {
// try something new
} catch (Exception e) { // <---- THIS EXCEPTION
// do something exceptional
throw e;
}
// do more work here, because why not?
}
}
)
);
a++;
}
return classAList;
}
This is a contrived example, so it may not be completely sensible. However, it accurately reflects the code I have.
What I'm trying to figure out is, what happens if the exception is thrown? Does the exception break through, and the entire doSomething function fails? (I suspect this is the case, but the upper level function doesn't have a "throws Exception", so may be I'm wrong?)
I'm relatively new to Java, and have definitely not seen this style of programming before (also, if you know what it's called, so I can research it more, please let me know) - I have a background in C and Python, so -__(o.O)__/-
Note: this is an extension to something, and therefore cannot be run directly for debugging.
Note 2: This question was marked as a possible duplicate of this. I am not asking how this compiles without the exception thrown clause. I'm trying to figure out where/when the exception is thrown.