Community
Participate
Working Groups
Created attachment 276758 [details] JDK 1.6. is used in the project I have a Save Action defined to put @Override wherever necessary. Now, one of the files is java.sql.Driver implementer. The Driver interface defines the following method: public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException When I save the implementer class file - it will automatically add @Override annotation to the implemented method name getParentLogger(). However, this method is only available starting JDK 1.7. Hence, it will fail if I build with JDK 1.6. Eclipse runs with JDK 1.8, but the Maven project is specified to use JDK 1.6. source-target. So, how come, the Save action still adds the @Override annotation? (Which causes my build to fail.)
Please attach a test case/project.
This is the case: ``` import java.sql.Connection; import java.sql.DriverPropertyInfo; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; public class DummyDriver implements java.sql.Driver { @Override public boolean acceptsURL(String url) throws SQLException { // TODO Auto-generated method stub return false; } @Override public Connection connect(String url, Properties info) throws SQLException { // TODO Auto-generated method stub return null; } @Override public int getMajorVersion() { // TODO Auto-generated method stub return 0; } @Override public int getMinorVersion() { // TODO Auto-generated method stub return 0; } // jdbc 1.7 feature //@Override public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException { throw new SQLFeatureNotSupportedException(); } @Override public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { // TODO Auto-generated method stub return null; } @Override public boolean jdbcCompliant() { // TODO Auto-generated method stub return false; } } ```
Now, I have to say, that, in the latest version of Eclipse (2019-01), it works as expected. Once this is defined in .classpath, the @Override is not being added on Save: <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> Changing 1.6 to 1.8, the @Override is being added on Save: <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> So, I guess, it works properly.