Context: The java.io.File class has a static inner class method as follows:
LazyInitialization.temporaryDirectory();
[EDITED added a few more codes] My code below ultimately calls the above line of code. The exception is thrown from the timeDirectory () method, which in my context is accurate / expected.
try { File tempFile = File.createTempFile("aaa", "aaa"); } catch (Exception e) {
Then, when I call the same method again (createTempFile), I get a "java.lang.NoClassDefFound error". Failed to initialize class java.io.File $ LazyInitialization "
Question: I suggested that the inner LazyInitialization class should be loaded by the class loader when its static method was called, although the inner method threw an exception. However, why do I see a NoClassDefFound error when called a second time? Wrong initial assumption?
source share