<AWT Dev> JDK 9 RFR of JDK-8039109 : Fix unchecked and raw lint warnings in java.awt
Remi Forax
forax at univ-mlv.fr
Wed Apr 30 10:40:52 UTC 2014
On 04/29/2014 10:26 PM, Joe Darcy wrote:
> Hello,
>
> Now that Henry's fixes of raw and unchecked warnings in sun.awt has
> been pushed, please review this change to fix issues in java.awt:
>
> JDK-8039109 : Fix unchecked and raw lint warnings in java.awt
> http://cr.openjdk.java.net/~darcy/8039109.1/
>
> Full patch below. A few points of interest in the patch:
>
> * There is a change to the signature of a public method in
> java.awt.image.renderable.ParameterBlock.java (I believe that is the
> only such change in this patch; internally, a ccc request will be
> filed for this part of the fix.)
>
> * In my estimation the changes in java.awt.GraphicsEnvironment.java
> are a better use of generics and reflection.
>
> Thanks,
>
> -Joe
>
Hi Joe,
in AWTKeyStroke, instead of
Class<AWTKeyStroke> clazz = (Class<AWTKeyStroke>)AppContext.getAppContext().get(AWTKeyStroke.class);
I should have the right type Class<? extends ...> (the class is a
subclass of AWTKeyStroke) and
do a classcheck at runtime when the class is extracted instead of later
Class<? extends AWTKeyStroke> clazz = ((Class<?>)AppContext.getAppContext().get(AWTKeyStroke.class)).asSubClass(AWTKeyStroke.class);
and I think the second @SuppressWarnings in getCachedStroke() is
unnecessary.
in GraphicsEnvironment, the last line of your diff can be simplified,
ge = GraphicsEnvironment.class.cast(geCls.newInstance());
can be written
ge = (GraphicsEnvironment)geCls.newInstance();
which is more readable IMO but will also generate exactly the same
bytecode as the current implementation.
in KeyboardFocusManager,
private Set<AWTKeyStroke>[] defaultFocusTraversalKeys = new Set[4];
should be
private Set<AWTKeyStroke>[] defaultFocusTraversalKeys = new Set<?>[4];
so @SuppressWarnings("rawtypes") is not needed.
in DragGestureEvent, the newEvents should be a List<? extends InputEvent>,
and @SuppressWarnings("rawtypes") should be a @SuppressWarnings("unchecked")
in RenderableImageOp,
getRenderableSources() should return a Vector of RenderableImage,
public Vector<RenderableImage> getSources() {
getRenderableSources();
}
private Vector<RenderableImage> getRenderableSources() {
Vector<RenderableImage sources = null;
all other modifications are OK for me.
regards,
Rémi
More information about the awt-dev
mailing list