Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find out when this Java API change happened?

Tags:

java

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?

like image 745
jjujuma Avatar asked Jul 22 '09 13:07

jjujuma


People also ask

How do I find my Java API?

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.

What is WatchService in Java?

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.

What is Changelistener in Java?

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.

Can we monitor a directory for adding new files in Java?

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.


3 Answers

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.

like image 163
cletus Avatar answered Oct 01 '22 05:10

cletus


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.)

like image 22
Jon Skeet Avatar answered Oct 01 '22 05:10

Jon Skeet


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.

like image 44
Michael Borgwardt Avatar answered Oct 01 '22 06:10

Michael Borgwardt