I apologize in advance if this has been covered elsewhere, but the vague/common terms involved means that I found a lot of irrelevant hits and nothing that was helpful. Since my project is rather large I don't think it'd be reasonable for me to provide a M(N)WE, so instead I'm looking for ideas as to what else to check. Here's the code block:
try {
myClassObject = new MyClass(string1, string2, string3, otherClassObject); (1)
System.out.println("Test"); (2)
} catch (Exception e){
System.out.println(e.getMessage() + " " + e.getStackTrace()); (3)
}
My constructor(1) is never called. However, neither (2) nor (3) are called (i.e. the test string is never printed nor is an exception ever printed). From my understand of a try-catch block, this shouldn't be possible.
I use Eclipse's debug mode and am able to step over that line. All 4 objects are defined and can be printed just fine (so it's not an access issue). All 4 objects have their expected value when viewed in debug mode. However, debug mode skips from (1) on to the rest of my code, never hitting (2) nor (3). A debug point placed in the constructor for MyClass is never reached.
I can call a default constructor of MyClass in place of the 4 parameter constructor and it behaves as desired. I can then copy/paste the contents of the 4 parameter constructor after (2) and all 4 parameters set properly and the object is created as desired. Obviously this is a viable work-around, but I can't find a reason that the 4 parameter constructor is failing.
In short, I have no idea how this is possible, let alone how to stop it from happening.
Edit: I've performed clean -> build -> debug on the code several times, so I'm fairly confident it is not a .class issue. Just in case I deleted the .bin and refreshed, which had no effect.