changeset 2295:494f5e4f24da

Merge
author lana
date Tue, 09 Mar 2010 15:26:32 -0800
parents 03cd9e62961f 1d7db2d5c4c5
children 2fe4e72288ce
files
diffstat 3 files changed, 30 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/awt/AlphaComposite.java	Thu Mar 04 13:50:23 2010 -0800
+++ b/src/share/classes/java/awt/AlphaComposite.java	Tue Mar 09 15:26:32 2010 -0800
@@ -614,14 +614,15 @@
     }
 
     private AlphaComposite(int rule, float alpha) {
-        if (alpha < 0.0f || alpha > 1.0f) {
-            throw new IllegalArgumentException("alpha value out of range");
-        }
         if (rule < MIN_RULE || rule > MAX_RULE) {
             throw new IllegalArgumentException("unknown composite rule");
         }
-        this.rule = rule;
-        this.extraAlpha = alpha;
+        if (alpha >= 0.0f && alpha <= 1.0f) {
+            this.rule = rule;
+            this.extraAlpha = alpha;
+        } else {
+            throw new IllegalArgumentException("alpha value out of range");
+        }
     }
 
     /**
--- a/src/share/classes/sun/font/SunFontManager.java	Thu Mar 04 13:50:23 2010 -0800
+++ b/src/share/classes/sun/font/SunFontManager.java	Tue Mar 09 15:26:32 2010 -0800
@@ -3058,7 +3058,7 @@
             return;
         }
         /* Use lock specific to the font system */
-        synchronized (lucidaFontName) {
+        synchronized (this) {
             if (FontUtilities.debugFonts()) {
                 Thread.dumpStack();
                 FontUtilities.getLogger()
@@ -3194,7 +3194,7 @@
             return;
         }
         /* Use lock specific to the font system */
-        synchronized (lucidaFontName) {
+        synchronized (this) {
             if (FontUtilities.debugFonts()) {
                 Thread.dumpStack();
                 FontUtilities.getLogger().info("loadAllFontFiles() called");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/AlphaComposite/TestAlphaCompositeForNaN.java	Tue Mar 09 15:26:32 2010 -0800
@@ -0,0 +1,22 @@
+/*
+ * @test
+ * @bug 6918065
+ * @summary Test for passing NaN as alpha
+ *          should throw IllegalArgumentException
+ */
+
+import java.awt.*;
+
+public class TestAlphaCompositeForNaN {
+  public static void main(String[] args) {
+    try {
+      AlphaComposite a = AlphaComposite.getInstance(AlphaComposite.DST, Float.NaN);
+      System.out.println("Failed");
+      throw new RuntimeException(a + " failed to throw IllegalArgumentException for alpha = " + Float.NaN);
+    }
+    catch (IllegalArgumentException ie) {
+      System.out.println("Passed");
+      System.out.println("Caught " + ie);
+    }
+  }
+}