Home > Software > Override from 5 to 6

Override from 5 to 6


One of the way of learning something is through exercise and trial and error process. And in the end you have the solution. Unfortunately, not everyone is documenting and sharing their learning.
This is a small tip that I learned while I had to maintain backward compatibility with Java 5 for an application written in Java 6.
While building the application, the compiler reported this error: “method does not override a method from its superclass”. Even though it seems very strange, the cause is very simple. Override annotation in Java 6 works for both methods in super classes and interfaces, as opposed to Java 5 where it works only for super classes. So actually in Java 6 this also means Implement. Unfortunately, there is no reference about it in JavaDoc.
One more tip: if you’re using Eclipse is not enough to change the JDK. You also have to change the Compiler compliance level. Just go to Project > Properties > Java Compiler and select 1.5 for Compiler compliance level.
.

Categories: Software Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: