At some point java.lang.Override
started to be available for use with implementations of methods declared in interfaces. I'm pretty sure there was a time when it just worked for overrides of methods defined in superclasses.
How can I find out when (i.e. at which version) this change happened?
You can find it in the src. zip in the JDK installation directory. Your IDE may also provide a Go to reference command that let you access the source code in src. zip when you use it on a method of the Java class library.
A watch service that watches registered objects for changes and events. For example a file manager may use a watch service to monitor a directory for changes so that it can update its display of the list of files when files are created or deleted.
A change listener is similar to a property change listener. A change listener is registered on an object — typically a component, but it could be another object, like a model — and the listener is notified when the object has changed.
Create a WatchService "watcher" for the file system. For each directory that you want monitored, register it with the watcher. When registering a directory, you specify the type of events for which you want notification. You receive a WatchKey instance for each directory that you register.
Use of the @Override
annotation on methods that are implemented from interfaces and not overridden from a superclass is a new feature in Java 6. See @Override specification changes in Java 6:
Between Java 5 and Java 6 changes to the specification of @Override have been made. In Java 6 it is possible to add the @Override annotation to methods that implement methods of an interface which is not allowed in Java 5.
I noticed the difference when a friend told me that he had to remove all the @Override annotations to make his Java 6 project compile with Java 5.
The interesting thing is that there is no documentation about this change. The API specification of @Override is exactly the same in both Java versions. I found out that this was forgotten by Sun developers. Peter Ahé, a former developer at Sun, calls it the @Override Snafu.
I don't know how you'd find this out, but it happened between 5 and 6. (i.e. it's forbidden in 5 but accepted in 6.)
You cannot "officially" find out because someone at Sun messed up and did not update the specification in the API doc of java.lang.Override
when the implementation was changed, and apparently changing the specification after the release is not allowed.
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