-
Notifications
You must be signed in to change notification settings - Fork 908
Remove use of deprecated Integer constructor in NotifyDescriptor #8799
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
base: master
Are you sure you want to change the base?
Conversation
This change keeps the existing value relationship with JOptionPane int constants, which involves managing YES and OK now having the same identity. It is no longer possible to maintain both aspects.
API does not specify these as supported options, and the implementation will no longer allow mixed with OK.
Marking ready for review but do not merge. This would be my preferred option to #8407 for handling the necessary changes for The test change is required because it will no longer be possible to specify both |
this essentially boils down to the question what type of client code we want to break. The introduction of value based objects has the potential to break things for everyone who expected them to have object identity. in this case here: a) There is code which follows the rules, looks at the API, sees keys of type b) And there is code which looks at the NB impl, or looks at the keys in the debugger, sees that they are of type if we want to keep code of kind a) working, but are ok to break b) then we have to replace the If we say that too many looked at the source code and took impl details for granted (b)), we break the object identity of the keys and let I do gravitate most of the time to the simpler solution, so I am slightly in favor of simply mapping everything to |
What timeframe are we expecting these Integer constructors to be removed at? Will it happen sooner than, say, 5 years from now? I'm wondering if it might be better to wait until JEP 401 is actually stable, since the removal of constructors might then come with alternatives such as a drop-in static constructor. Looking at the Javadoc for Java 25 EA, the constructors are still there: https://download.java.net/java/early_access/jdk25/docs/api/java.base/java/lang/Integer.html#%3Cinit%3E(int) |
the removal of the constructors is IMO a distraction in this discussion since the behavior of The deprecation and javadoc notes on value objects describe what applications should do to be future proof. We shouldn't wait with making changes and fix every deprecation we can before they pile up - waiting till the last moment is never a good idea. (Thread.stop() is deprecated since Java 1.2 and throws exceptions now and we still have usage! #4952) |
That's good for new code, but for existing APIs, perhaps it's better to just leave them as-is? I'd be surprised if JDK changes behavior in a way that is likely to break client applications. (The example they give of a possible future change is that "synchronization may fail", but that would be a much more obscure use of an Integer instance.) |
doc: the class's methods treat instances as freely substitutable when equal, meaning that interchanging any two instances x and y that are equal according to equals() produces no visible change in the behavior of the class's methods; once Integer is a value based object, OK option will have the same We should offer builds compatible with that state well before that happens in a controlled manner so netbeans and netbeans based applications can be made future proof. Waiting makes no sense here IMO. |
(I haven't formed strong opinions on this, so please bear with me...)
If the answer is (1) yes and (2) no, then I'd be inclined to agree with Neil's earlier position:
|
well the little key identity crisis would already break our impl, the tests did notice it too although indirectly (thats why this PR has to change impl code when OK is made identical to YES). JEP 401 is worth reading btw, well written including ASCII art. If the constructors would get removed our build would fail and NB 27 based apps will throw Exceptions on newer JDKs since
so I am +1 for Neil's proposal assuming nothing shows up during testing. But I think we should update the doc to mention that the key values are boxed I would be curious if changing the keys from |
What a lot of discussion! 😄 Let's ignore any usage of these values outside of the Dialog API and our implementation. For any other purposes they're unknown Objects that might be equal or identical to each other, and this is not specified anywhere. The values here serve two purposes - input (custom options, etc.) or output (return value) from the Dialog API. On the return values, the only need to differentiate the identities of The That change fixed some of the test issues. It is also worth considering what broke in those tests. The return value test passed, the test failed on the button text. In a lot of the rare cases where this change might affect an application it should be a wrongly labelled button, not functionality. I considered adding some documentation to clarify what the values, identities are. I decided not to at this stage because it potentially locks down the API spec and it might be better to still allow ourselves further leeway in case of regressions. But open to changing that if you think we should? |
Removes use of deprecated Integer constructors for NotifyDescriptor constants. Alternative to #8407 for testing and discussion.
This change keeps the existing value relationship with JOptionPane int constants, which involves managing
YES
andOK
now having the same identity. It is no longer possible to maintain both aspects, just choose the one that offers best compatibility.Various usages in the NetBeans codebase suggest that keeping the values might lead to less hidden issues in our and third-party usage. eg.
netbeans/php/php.dbgp/src/org/netbeans/modules/php/dbgp/ServerThread.java
Line 113 in 2c92300
netbeans/php/php.smarty/src/org/netbeans/modules/php/smarty/editor/TplEditorSupport.java
Line 137 in 2c92300
There's a mix in code that checks return values by equals and by identity. Having these work the same might be desirable.
The key place that not being able to differentiate
OK
andYES
might cause problems is in the specification of custom options. The API does not actually sayYES
is a valid argument, but that is currently supported in the main implementation. This change assumesYES
is wanted ifNO
is also present. Return values should work as before.fixes #8257 (yey!)