When I launch the SWT application (via the Eclipse startup profile), I get the following stack trace:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jface/resource/FontRegistry
at org.eclipse.jface.resource.JFaceResources.getFontRegistry(JFaceResources.java:338)
at org.eclipse.jface.window.Window.close(Window.java:313)
at org.eclipse.jface.dialogs.Dialog.close(Dialog.java:971)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.close(ProgressMonitorDialog.java:348)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.finishedRun(ProgressMonitorDialog.java:582)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:498)
at com.blah.si.workflow.SWTApplication.main(SWTApplication.java:135)
Now, what does this odd do:
- When I change the build path of the project and replace jface.jar with the original project (the same version is 3.3.1), the error disappears.
- In other applications that use the same ATM, and a copy of the same startup profile and project, everything works fine.
- This is NOT a
ClassNotFoundException. A class is on its way to classes. If I attach the source to the jar, I can debug the getFontRegistry method. The method will execute successfully several times before finally throwing a lineNoClassDefFoundErroron line 338. Line 337 is the if variable == null statement that checks whether a static variable has been initialized. Line 338 initializes it, if it is not yet initialized. For the first time, with the completion of the zero check, initialization is performed. Subsequent passes through the method pass a zero check, and thus, an already initialized static value is returned. On the last pass (the one that fails), the null check completes again (even if the static variable is already initialized), and when it tries to reinitialize the static variable, it is generated NoClassDefFoundError. Here is the corresponding source (starting at line 336, note that fontRegistry is a private static variable that is not set anywhere else):
.
public static FontRegistry getFontRegistry() {
if (fontRegistry == null) {
fontRegistry = new FontRegistry(
"org.eclipse.jface.resource.jfacefonts");
}
return fontRegistry;
}
.
- ( , ) .classpath .project . .
- № 3 , - wierd classloader - , ?
?
:. , Pourquoi Litytestdata, , try 458 ProgressMonitorDialog. , , finally. ( JFontRegistry , , - .) , , , Pourquoi, . .