<Swing Dev> RFR: JDK-8242808 Fix all remaining deprecation warnings in jdk.hotspot.agent
Magnus Ihse Bursie
magnus.ihse.bursie at oracle.com
Wed Apr 15 13:00:27 UTC 2020
Here is an updated version, that avoids the SuppressWarnings for
modelToView:
http://cr.openjdk.java.net/~ihse/JDK-8242808-fix-all-SA-deprecation/webrev.02
(Only change is in SourceCodePanel.java compared to v01)
/Magnus
On 2020-04-15 14:30, Magnus Ihse Bursie wrote:
>
>
> On 2020-04-15 12:59, Prasanta Sadhukhan wrote:
>> Hi Magnus,
>>
>> Why can't we just use modelToView2D() to get Rectangle2D and then
>> cast to Rectangle tobe used in scrollRectToVisible() or else use
>> (int)Rectangle2D.getX(), (int)getY(), getWidth(), getHeight() to
>> construct a new Rectangle()?
> Casting a Rectangle2D to a Rectangle does not seem to me to be an
> improvement. That presupposes even more knowledge about implementation
> details.
>
> However, I'll look into constructing a Rectangle using the getters
> from the Rectangle2D, as you suggested. Thanks!
>
> /Magnus
>>
>> Regard
>> Prasanta
>> On 15-Apr-20 3:35 PM, Magnus Ihse Bursie wrote:
>>> Hi swing-dev,
>>>
>>> Do you have any other suggestions for how to resolve the deprecation
>>> of modelToView() in this code?
>>>
>>> Basically, the code does this:
>>>
>>> Rectangle rect = source.modelToView(offset);
>>> source.scrollRectToVisible(rect);
>>>
>>> but scrollRectToVisible() requires a Rectangle (a subtype of
>>> Rectangle2D), and modelToView() is deprecated with reference to
>>> modelToView2D(), which returns a Rectangle2D, which is thus unusable
>>> by scrollRectToVisible(). I also cannot find a way to create a new
>>> Rectangle, given a Rectangle2D.
>>>
>>> In practice, under the hood, it's still just Rectangles (not
>>> Rectangle2D).
>>>
>>> /Magnus
>>>
>>> On 2020-04-15 11:37, David Holmes wrote:
>>>> Hi Magnus,
>>>>
>>>> This one sounds like it needs a Swing/Java2D developer to review it :)
>>>>
>>>> Cheers,
>>>> David
>>>>
>>>> On 15/04/2020 7:13 pm, Magnus Ihse Bursie wrote:
>>>>> After JDK-8242804, a few places remain which are using deprecated
>>>>> methods. They too should be fixed, and the deprecation warning
>>>>> should no longer be disabled.
>>>>>
>>>>> This patch presupposes the fix for JDK-8242804 has been applied
>>>>> (otherwise we cannot turn the deprecation warning back on).
>>>>>
>>>>> Some brief comments about each fix:
>>>>>
>>>>> * In ConstantPool.java, there was a boxing deprecation that I
>>>>> missed in JDK-8242804 (sorry!)
>>>>>
>>>>> * In HighPrecisionJScrollBar.java, there is a trivial replacement
>>>>> to use BigDecimal.divide with RoundingMode semantics.
>>>>>
>>>>> * In SourceCodePanel.java, I settled for suppressing the warning.
>>>>> The issue here is that modelToView (which returns a Rectangle) is
>>>>> deprecated in favor of modelToView2D, which returns a Rectangle2D
>>>>> (which is a supertype of Rectangle). But we use the result in
>>>>> scrollRectToVisible, and there exist no version of that which
>>>>> accepts a Rectangle2D instead of a Rectangle, nor a way to created
>>>>> a Rectangle from a Rectangle2D (that I could find). In practice,
>>>>> this is just a game of types -- under the hood, modelToView2D
>>>>> still returns a Rectangle (even though it only promises a
>>>>> Rectangle2D). The alternative here would be to cast the result of
>>>>> modelToView2D to a Rectangle, but I found that less attractive.
>>>>>
>>>>> * In JTreeTable.java, I've replaced the use of the old-style
>>>>> modifier mask with the new-style extended modifier mask. To the
>>>>> best of my understanding, this will just work the same for the
>>>>> code here (and for the MouseEvent constructor, using the extended
>>>>> mask is actually prescribed).
>>>>>
>>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8242808
>>>>> WebRev:
>>>>> http://cr.openjdk.java.net/~ihse/JDK-8242808-fix-all-SA-deprecation/webrev.01
>>>>>
>>>>>
>>>
>
More information about the serviceability-dev
mailing list