Thread: K5 JBPatch
View Single Post
Old 10-23-2012, 08:03 PM   #859
ixtab
(offline)
ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.ixtab ought to be getting tired of karma fortunes by now.
 
ixtab's Avatar
 
Posts: 2,903
Karma: 6677559
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
Quote:
Originally Posted by knc1 View Post
@ixtab: Isn't Java one of those languages where the interface (definition) and the implementation can be in two different files (here, only one of the required two).

It has been a long time since I Java'd -
One would probably be called an "abstract class" and the "class implementation".
Hence two similar error messages, depending on which of the two can not be found.
Yeah, but that's called "interface"/"abstract class", and I hope that I know the difference.

The thing that I don't understand is why directly referencing an inexistent class gives a ClassNotFoundException (all fine until here), but trying to load an (existing) class which has a reference to an inexistent class gives a "NoSuchClassDefError". The problem is exactly the same - a required class isn't found, so why not throw the same exception?

Answering my own question: it's probably due to an idiosyncrasy of the JVM, namely the difference between checked and unchecked exceptions. In short: trying to load a named class can throw a (checked=must be caught) "ClassNotFoundException". But if that class is actually found, but isn't "initializable" because it itself depends on another non-found class, that produces an unchecked exception, namely "NoClassDefFoundError". Go figure.
ixtab is offline   Reply With Quote