Please Visit: http://ift.tt/1ajReyV
from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/1pa5u6j
via LifeLong Community
Why doesn't Java allow generic subclasses of Throwable? - Stack Overflow
As mark said, the types are not reifiable, which is a problem in the following case:
try {
doSomeStuff();
} catch (SomeException<Integer> e) {
// ignore that
} catch (SomeException<String> e) {
crashAndBurn()
}
Both SomeException<Integer> and SomeException<String> are erased to the same type, there is no way for the JVM to distinguish the exception instances, and therefore no way to tell which catch block should be executed.
http://ift.tt/1lJD8QY
http://ift.tt/1lJD8QZ
As mark said, the types are not reifiable, which is a problem in the following case:
try {
doSomeStuff();
} catch (SomeException<Integer> e) {
// ignore that
} catch (SomeException<String> e) {
crashAndBurn()
}
Both SomeException<Integer> and SomeException<String> are erased to the same type, there is no way for the JVM to distinguish the exception instances, and therefore no way to tell which catch block should be executed.
http://ift.tt/1lJD8QY
http://ift.tt/1lJD8QZ
from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/1pa5u6j
via LifeLong Community
No comments:
Post a Comment