Why doesn't Java allow generic subclasses of Throwable? -


According to the third version:

I want to understand why this decision has been taken. What is wrong with generic exceptions?

(As far as I know, generic bus compiles time-bound syntax, and will be translated into object anyway. files Therefore, it is to effectively declare a general class as if everything in it had a object . Please correct me if I am wrong.)

As Mark said, the types are not reusable, the following cases There is a problem in the field:

  try {doSomeStuff (); } Hold (some expansions & lt; integer & gt; e) catch (some expansion & lt; string & gt; e) {crashAndBurn ()}  

both SomeException & lt ; Integer & gt; and some expansions & lt; String & gt; is erased by the same type, there is no way JVM to differentiate between exception examples, and therefore it should not be said that the hold block should be executed.


Comments