harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pavlenko, Andrey A" <andrey.a.pavle...@intel.com>
Subject RE: [classlib][awt] RenderingHints.Key.isCompatibleValue(). Method sence.
Date Mon, 11 Dec 2006 17:01:48 GMT
Hi, Alexander,

In the Harmony implementation a value have to be an instance of
KeyValue, but not Value. See the implementation of the isCompatibleValue
method.

        public boolean isCompatibleValue(Object val) {
            if (!(val instanceof KeyValue)) {
                return false;
            }

            return ((KeyValue)val).key == this;
        }

RI also does not return true in any case, see the following example.

        System.out.println(RenderingHints.KEY_ANTIALIASING
                .isCompatibleValue(new Object()));
        System.out.println(RenderingHints.KEY_ANTIALIASING
                .isCompatibleValue(null));
        System.out.println(RenderingHints.KEY_ANTIALIASING
                .isCompatibleValue(RenderingHints.VALUE_ANTIALIAS_ON));

Output:
false
false
true

-----Original Message-----
From: Shipilov, Alexander D [mailto:alexander.d.shipilov@intel.com] 
Sent: Monday, December 11, 2006 1:53 PM
To: dev@harmony.apache.org
Subject: [classlib][awt] RenderingHints.Key.isCompatibleValue(). Method
sence.

Hi, folks,
 I found a JIRA http://issues.apache.org/jira/browse/HARMONY-2066.
Essence of this JIRA is a too hard restriction imposed by a method
RenderingHints.Key.isCompatibleValue(Object value).

Spec says about this method:
 "Returns true if the specified object is a valid value for this Key."
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/RenderingHints.Key.html
#isCompatibleValue(java.lang.Object)

Harmony implements this method in a following way. It returns true only
if the value is an instance of the Key. Why it so?
RI returns true in any case, even if the value is just Object, even if
the value is null.

Should we decrease restriction imposed by this method?

Thanks,
Alexander Shipilov

Mime
View raw message