I am trying to create a class that implements an interface from a Java library. The ResultSet should be specific, although the specific interface should not be relevant. (I need to overlay a layer on top of a regular ResultSet, which provides some additional features, but I would like the “regular” functions to go through, and I have a couple of functions that should be able to accept either a regular ResultSet or my “advanced” ResultSet.)
My problem: is there a way I can do this so that the class compiles successfully in both Java 5 and Java 6?
There are a number of functions in the ResultSet interface in Java 6 that return objects that are not defined in Java 5. If I enable these functions, my class will not compile in Java 5 because I refer to undefined types, But if I do not include these functions, then my class will not compile in Java 6 because I do not fully implement the interface. I seem to be stuck in something caught-22. I really don't need any of these functions - in fact, my implementation simply throws an “not implemented” exception for all of them.
Some of our programmers work in Java 5, and some of them work in Java 6. Our production environment is Java 5. I believe that in a more advanced world, we will work with the same version. But even if I can change our environment to solve the problem in this case, of course, this problem occurs with open source projects. And if I modify my code to work with Java 5, then, sooner or later, we will switch to Java 6, the class will break, which seems rather annoying.
Update
Ok, thanks for the answers. I rather hoped that someone would tell me: "Oh, if you just add this annotation or write the letter" W "here, everything will work in a magical way." There seems to be no such luck.
( , ) , , " " , .: -)
, - ResultSet , ResultSet, . , , , , .