-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SortedMultiset.elementSet should return NavigableSet #942
Comments
Original comment posted by kevinb@google.com on 2012-03-18 at 04:12 AM Changing a return type is ordinarily a binary-compatibility problem, but here I think we might get away with it because it's already a narrowed return type from the parent type (Multiset), so there's already a bridge method being created! Status: |
Original comment posted by wasserman.louis on 2012-03-18 at 12:35 PM Normally we might have an issue with changing an interface spec, but I'm hoping that nobody's actually gone and implemented SortedMultiset for themselves... |
Original comment posted by cpovirk@google.com on 2012-03-22 at 04:18 PM GWT is a problem here, since it doesn't have a NavigableSet. We could add one, but it may bloat GWT code size. It's on my plate to analyze just how much and make a decision. Louis has sent http://codereview.appspot.com/5867050/ (which otherwise LGTM). |
Original comment posted by kevinb@google.com on 2012-03-22 at 04:32 PM re:comment 2, as an interface it's @Beta. It's just the TreeMultiset implementation that's non-beta and really at issue here. |
Original comment posted by wasserman.louis on 2012-03-22 at 04:40 PM Hrrrrm. I'd like to change the interface, ASAP, before Jane Random Coder decides to implement it herself and then gets broken by the change. That said, I could settle for speccing TreeMultiset to return NavigableSet, and leaving the interface as-is for the moment. It strikes me that that would be easier, just in terms of GWT compatibility -- for example, we could have the GWT implementation spec'd to only return a SortedSet...I don't know if that'd work, but it might reduce the GWT complexity. |
Original comment posted by cpovirk@google.com on 2012-03-22 at 06:01 PM $ tail -n 999 *.java && javac *.java && javap SortedMultiset && javap TreeMultiset && javap -c Caller ==> Multiset.java <== ==> NavigableSet.java <== ==> Set.java <== ==> SortedMultiset.java <== ==> SortedSet.java <== ==> TreeMultiset.java <== Compiled from "TreeMultiset.java" Compiled from "Caller.java" static void multiset(); static void sortedMultiset(); static void treeMultiset(); public static void main(java.lang.String[]); } If we make TreeMultiset return NavigableSet, we get the same methods, except that "SortedSet elementSet()" is now a bridge method (fine) and of course "NavigableSet elementSet()" exists (also fine). If I make this change, recompile only the Multiset classes, and run Caller, everything is fine. If we make both TreeMultiset and SortedMultiset return NavigableSet, we see the SortedSet-returning method in each going away in favor of a NavigableSet-returning method (not good). If I make this change, recompile only the Multiset classes, and run Caller, I get an error: $ javac Multiset.java Set.java && java Caller I should note that the problem exists with the call through the TreeMultiset API, too, not just through the @Beta SortedMultiset API. I confirmed this by commenting out the sortedMultiset() call: Exception in thread "main" java.lang.NoSuchMethodError: TreeMultiset.elementSet()LSortedSet; I conclude that we can change TreeMultiset but not SortedMultiset -- ironic, given the @Beta situation. Unless, of course, we're clever.... $ tail -n 999 Multiset.java ==> SortedMultisetBridgeInjector.java <== ==> SortedMultiset.java <== ==> TreeMultiset.java <== This works. $ javap TreeMultiset $ java Caller |
Original comment posted by wasserman.louis on 2012-03-26 at 01:24 PM I like the "clever solution." |
Original comment posted by kevinb@google.com on 2012-04-03 at 05:40 PM (No comment entered for this change.) Labels: |
Original comment posted by lowasser@google.com on 2012-12-10 at 05:25 PM (No comment entered for this change.) Status: |
Original issue created by wasserman.louis on 2012-03-17 at 08:15 PM
Related to issue 664. I'd prefer not to go down the route of the JDK in having separate Sorted/Navigable interfaces, but I'd like SortedMultiset.elementSet to return NavigableSet.
Would this break anyone's code? How can we migrate users?
The text was updated successfully, but these errors were encountered: