#239 Taming bug: java.awt.Color.getComponents and related

Need_for_security
closed-fixed
5
2005-07-24
2005-07-17
No

FIXED
From
http://www.eros-os.org/pipermail/e-lang/2004-May/009836.html

These enabled methods of java.awt.Color modify the
passed arrays, and
are documented to do so:

getColorComponents(ColorSpace, float[])
getColorComponents(float[])
getComponents(ColorSpace, float[])
getComponents(float[])
getRGBColorComponents(float[])
getRGBComponents(float[])
static float[] RGBtoHSB(int, int, int, float[])

I suggest creating sugar methods which do not have the
float[]
arguments, and pass null to the original methods.

? def red := <awt:Color>.getRed()
# value: java.awt.Color[r=255,g=0,b=0]

? def blue := <awt:Color>.getBlue()
# value: java.awt.Color[r=0,g=0,b=255]

? def rl1 := red.getColorComponents(null)
# value: [1.0, 0.0, 0.0]

? def rl2 := red.getColorComponents(null)
# value: [1.0, 0.0, 0.0]

? rl1 == rl2
# value: true

? def bl := blue.getColorComponents(rl1)
# value: [0.0, 0.0, 1.0]

? rl1 == rl2 # <-- Oops!
# value: false

Followups

Comment Date By
From
http://www.eros-os.org/pipermail/e-lang/2004-June/009857.html

In the upcoming 0.8.28e release, I've taken your
suggestion: I've added sugar
methods for all these without the last float[]
argument, that pass null to
the original. Because two of the originals already
overloaded on arity, I
added an informative error when a ColorSpace argument
is null:

? def red := <awt:Color>.getRed()
# value: java.awt.Color[r=255,g=0,b=0]

? def rl1 := red.getColorComponents(null)
# problem: Failed: Use getColorComponents/0

? def rl1 := red.getColorComponents()
# value: [1.0, 0.0, 0.0] 2004-Jun-10 19:24 markm
Dependent on Task:
Dependent on Bug:
No Other Bugs are Dependent on This Bug
Bug Change History

Field Old Value Date By
status_id Open 2004-Jun-10 19:24 markm
resolution_id None 2004-Jun-10 19:24 markm
close_date 1970-Jan-01 00:00 2004-Jun-10 19:24 markm

Discussion

  • Steve Jenson

    Steve Jenson - 2005-07-18
    • status: open --> open-fixed
     
  • Steve Jenson

    Steve Jenson - 2005-07-18
    • status: open-fixed --> closed-fixed
     
  • Mark Samuel Miller

    • assigned_to: nobody --> caplet
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks