java.util.concurrent.TimeUnit
has this source:
public long convert(long sourceDuration, TimeUnit sourceUnit) {
throw new AbstractMethodError();
}
Why isn't this an abstract
method like
abstract int excessNanos(long d, long m);
Single line comments above the method declaration says following,
// To maintain full signature compatibility with 1.5, and to improve the
// clarity of the generated javadoc (see 6287639: Abstract methods in
// enum classes should not be listed as abstract), method convert
// etc. are not declared abstract but otherwise act as abstract methods.
Here, 6287639
is bug id which says,
JDK-6287639 : Abstract methods in enum classes should not be listed as abstract
Now consider the following enum
considering it as class and every enum constant as an Object
, it is clear that if we create Object
of something abstract we must provide implementation and to avoid this convert
is not abstract
,
enum Blocks {
A1, B1, C1;
// It will say enum constant must implement
// the abstract method test
abstract int test();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With