I have discovered there are 2 NotImplementedException:
Since there is not an available documentation for the first one, I'm not able to understand the difference between them. What is this difference? Is one of them better than the other one?
I have discovered there are 2
NotImplementedException
I found more examples than that. It depends on how hard you look ... and where.
Since there is not an available documentation for the first one ...
That is because sun.reflect.generics.reflectiveObjects.NotImplementedException
is an internal class. The source code says:
"Temporary class used to indicate missing functionality"
What is this difference?
They both mean the same thing, more or less. Some piece of functionality has not been implemented.
Is one of them better than the other one?
I assume that you are really asking whether you can and should reuse either of these exceptions in your code.
Since the sun.reflect...
exception is an internal class (see @GhostCat's answer), it is inadvisable to use it in your code. There is a chance that the class will "go away" in a future release of Java1. That will present problems for your codebase.
It is reasonable to reuse the org.apache.commons...
exception. Indeed, my reading of the javadoc, it is designed to be generally reusable. However:
org.apache.commons.lang
and org.apache.commons.lang3
. (See bullet #1!)The other alternatives are to declare your own custom exception, or simply use the existing java.lang.UnsupportedOperationException
... which is standard, doesn't add a new dependency, and won't be removed in a future Java release.
1. I'm not sure of this, but I think that access to sun.reflect.generics.reflectiveObjects
is blocked in Java 9.