public class A { private static A staticInstance; public A () { staticInstance = this; } public void f () { System.out.println ("Af () called"); } static class B extends A { public B () { super (); throw new RuntimeException (); } public void f () { System.out.println ("Bf () called"); } } public static void main (String [] args) { try { new B (); } catch (Throwable t) { / * do nothing * / } if (staticInstance == null) { System.out.println ("staticInstance is null"); } else { staticInstance.f (); } } }
Source: https://habr.com/ru/post/50102/
All Articles