Remove deprecated Integer constructor usage.#8391
Conversation
| Integer ADDED_CHILD = new Integer(0); | ||
| Integer REMOVED_CHILD = new Integer(1); | ||
| Integer ADDED_CHILD = 0; | ||
| Integer REMOVED_CHILD = 1; |
There was a problem hiding this comment.
switched all usages which compared with == to equals
usages in FolderObj and ChildrenSupportTest, no public API.
| public static final Object YES_OPTION = new Integer(JOptionPane.YES_OPTION); | ||
| public static final Object YES_OPTION = JOptionPane.YES_OPTION; | ||
|
|
||
| /** Return value if NO is chosen. */ | ||
| public static final Object NO_OPTION = new Integer(JOptionPane.NO_OPTION); | ||
| public static final Object NO_OPTION = JOptionPane.NO_OPTION; | ||
|
|
||
| /** Return value if CANCEL is chosen. */ | ||
| public static final Object CANCEL_OPTION = new Integer(JOptionPane.CANCEL_OPTION); | ||
| public static final Object CANCEL_OPTION = JOptionPane.CANCEL_OPTION; | ||
|
|
||
| /** Return value if OK is chosen. */ | ||
| public static final Object OK_OPTION = new Integer(JOptionPane.OK_OPTION); | ||
| public static final Object OK_OPTION = JOptionPane.OK_OPTION; | ||
|
|
||
| /** Return value if user closes the window without pressing any button. */ | ||
| public static final Object CLOSED_OPTION = new Integer(JOptionPane.CLOSED_OPTION); | ||
| public static final Object CLOSED_OPTION = JOptionPane.CLOSED_OPTION; |
There was a problem hiding this comment.
i think this should be ok unless someone relied on the fact that YES_OPTION != OK_OPTION object identity wise (it has the same int value).
Considered making everything new Object but this would cause problems if someone would compare the values. BigInteger would work as last resort.
edit: this won't work
3dd5b3c to
838983f
Compare
ef742fc to
7635ea1
Compare
7635ea1 to
b53c321
Compare
b53c321 to
b1ebec8
Compare
| public static final Object ADD_SPLITTER = new Integer(0); | ||
| public static final Object ADD_SPLITTER = new Object(); | ||
|
|
||
| /** constraints constant for adding a component to the first (left/top) pane */ | ||
| public static final Object ADD_FIRST = new Integer(1); | ||
| public static final Object ADD_FIRST = new Object(); | ||
|
|
||
| /** constraints constant for adding a component to the second (right/bottom) pane */ | ||
| public static final Object ADD_SECOND = new Integer(2); | ||
| public static final Object ADD_SECOND = new Object(); |
There was a problem hiding this comment.
this panel is public unfortunately, but unused and deprecated. This should be still compatible unless someone casts down to Integer.
There was a problem hiding this comment.
Could have kept 0, 1, and, 2...
There was a problem hiding this comment.
yeah I think so. Not sure why I didn't. Will change it.
| */ | ||
| public static final String PROP_INFO_NOTIFICATION = "infoNotification"; // NOI18N | ||
|
|
||
| /** |
There was a problem hiding this comment.
Does this worth doing at all? The only advantage over simple auto boxing is to have unique Object instances for each option.
Do we really need that? Also it could break comparisons like ret.equals(0).
Object YES_OPTION = JOptionPane.YES_OPTION;would make more sense.
There was a problem hiding this comment.
this doesn't work since two options (JOptionPane.YES_OPTION and JOptionPane.OK_OPTION) would have the same int value which would return the same Integer instance due to the vlaueOf() cache (also used by auto boxing). Two return options with the same identity would be an incompatible change. This fails several tests across NB (already tried with #8391 (comment)).
Also it could break comparisons like ret.equals(0)
this is hopefully unlikely since the return type is Object not Integer. It being an Integer is an implementation detail but not in the doc.
There was a problem hiding this comment.
moved the NotifyDescriptor changes to a separate PR #8407
lkishalmi
left a comment
There was a problem hiding this comment.
Looks good save the last commit, where things got over-engineered.
b1ebec8 to
47275af
Compare
|
extracted the |
|
thanks for review, will merge after looking through it for the last time. |
| <ResourceString bundle="org/netbeans/modules/web/project/ui/wizards/Bundle.properties" key="LBL_NWP1_ProjectName_LabelMnemonic" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> | ||
| <ResourceString bundle="" key="LBL_NWP1_ProjectName_LabelMnemonic" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
There was a problem hiding this comment.
this example broke since the package was changed without updating the bundle path most likely. Will fix it.
47275af to
5496ae9
Compare
The feared
IntegerPR - this should hopefully be the last one in the chain.NotifyDescriptorchanges were extracted to [NotifyDescriptor] Refactor return values to not rely on Integer identity #8407Integer.valueOf()part of #8257