Merge
authorjgodinez
Tue, 05 May 2009 09:09:24 -0700
changeset 2701 a5de22fb74cd
parent 2692 345bc8d65b19 (current diff)
parent 2700 5adcd22eb61b (diff)
child 2708 d01743017349
child 2761 ff6d1d0b4180
child 2793 5ceefad7dbd7
child 3006 8201b60ec5eb
Merge
jdk/src/share/native/sun/java2d/pipe/RenderBuffer.c
--- a/jdk/make/sun/awt/FILES_c_unix.gmk	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/make/sun/awt/FILES_c_unix.gmk	Tue May 05 09:09:24 2009 -0700
@@ -125,7 +125,6 @@
         FourByteAbgrPre.c \
 	BufferedMaskBlit.c \
 	BufferedRenderPipe.c \
-	RenderBuffer.c \
 	ShapeSpanIterator.c \
 	SpanClipRenderer.c \
 	awt_ImageRep.c \
--- a/jdk/make/sun/awt/FILES_c_windows.gmk	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/make/sun/awt/FILES_c_windows.gmk	Tue May 05 09:09:24 2009 -0700
@@ -70,7 +70,6 @@
         FourByteAbgrPre.c \
 	BufferedMaskBlit.c \
 	BufferedRenderPipe.c \
-	RenderBuffer.c \
 	ShapeSpanIterator.c \
 	SpanClipRenderer.c \
 	SurfaceData.c \
--- a/jdk/make/sun/awt/mapfile-vers	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/make/sun/awt/mapfile-vers	Tue May 05 09:09:24 2009 -0700
@@ -65,7 +65,6 @@
 		Java_sun_awt_image_ShortComponentRaster_initIDs;
                 Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile;
                 Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans;
-                Java_sun_java2d_pipe_RenderBuffer_copyFromArray;
 		Java_sun_java2d_pipe_SpanClipRenderer_eraseTile;
 		Java_sun_java2d_pipe_SpanClipRenderer_fillTile;
                 Java_sun_java2d_pipe_ShapeSpanIterator_addSegment;
--- a/jdk/make/sun/awt/mapfile-vers-linux	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/make/sun/awt/mapfile-vers-linux	Tue May 05 09:09:24 2009 -0700
@@ -117,7 +117,6 @@
 		Java_sun_java2d_loops_MaskBlit_MaskBlit;
 		Java_sun_java2d_loops_MaskFill_MaskFill;
                 Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans;
-                Java_sun_java2d_pipe_RenderBuffer_copyFromArray;
 		Java_sun_java2d_pipe_SpanClipRenderer_initIDs;
 		sun_awt_image_GifImageDecoder_initIDs;
 
--- a/jdk/src/share/classes/sun/font/TrueTypeFont.java	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/src/share/classes/sun/font/TrueTypeFont.java	Tue May 05 09:09:24 2009 -0700
@@ -552,17 +552,6 @@
         ByteBuffer os2_Table = getTableBuffer(os_2Tag);
         setStyle(os2_Table);
         setCJKSupport(os2_Table);
-
-        ByteBuffer head_Table = getTableBuffer(headTag);
-        int upem = -1;
-        if (head_Table != null && head_Table.capacity() >= 18) {
-            ShortBuffer sb = head_Table.asShortBuffer();
-            upem = sb.get(9) & 0xffff;
-        }
-        setStrikethroughMetrics(os2_Table, upem);
-
-        ByteBuffer post_Table = getTableBuffer(postTag);
-        setUnderlineMetrics(post_Table, upem);
     }
 
     /* The array index corresponds to a bit offset in the TrueType
@@ -1020,8 +1009,26 @@
     }
 
     public void getStyleMetrics(float pointSize, float[] metrics, int offset) {
+
+        if (ulSize == 0f && ulPos == 0f) {
+
+            ByteBuffer head_Table = getTableBuffer(headTag);
+            int upem = -1;
+            if (head_Table != null && head_Table.capacity() >= 18) {
+                ShortBuffer sb = head_Table.asShortBuffer();
+                upem = sb.get(9) & 0xffff;
+            }
+
+            ByteBuffer os2_Table = getTableBuffer(os_2Tag);
+            setStrikethroughMetrics(os2_Table, upem);
+
+            ByteBuffer post_Table = getTableBuffer(postTag);
+            setUnderlineMetrics(post_Table, upem);
+        }
+
         metrics[offset] = stPos * pointSize;
         metrics[offset+1] = stSize * pointSize;
+
         metrics[offset+2] = ulPos * pointSize;
         metrics[offset+3] = ulSize * pointSize;
     }
--- a/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java	Tue May 05 09:09:24 2009 -0700
@@ -63,7 +63,7 @@
      * (This value can be adjusted if the cost of JNI downcalls is reduced
      * in a future release.)
      */
-    private static final int COPY_FROM_ARRAY_THRESHOLD = 28;
+    private static final int COPY_FROM_ARRAY_THRESHOLD = 6;
 
     protected final Unsafe unsafe;
     protected final long baseAddress;
@@ -93,20 +93,6 @@
     }
 
     /**
-     * Copies length bytes from the Java-level srcArray to the native
-     * memory located at dstAddr.  Note that this method performs no bounds
-     * checking.  Verification that the copy will not result in memory
-     * corruption should be done by the caller prior to invocation.
-     *
-     * @param srcArray the source array
-     * @param srcPos the starting position of the source array (in bytes)
-     * @param dstAddr pointer to the destination block of native memory
-     * @param length the number of bytes to copy from source to destination
-     */
-    private static native void copyFromArray(Object srcArray, long srcPos,
-                                             long dstAddr, long length);
-
-    /**
      * The behavior (and names) of the following methods are nearly
      * identical to their counterparts in the various NIO Buffer classes.
      */
@@ -147,9 +133,9 @@
 
     public RenderBuffer put(byte[] x, int offset, int length) {
         if (length > COPY_FROM_ARRAY_THRESHOLD) {
-            long offsetInBytes = offset * SIZEOF_BYTE;
+            long offsetInBytes = offset * SIZEOF_BYTE + Unsafe.ARRAY_BYTE_BASE_OFFSET;
             long lengthInBytes = length * SIZEOF_BYTE;
-            copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
+            unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
             position(position() + lengthInBytes);
         } else {
             int end = offset + length;
@@ -178,9 +164,9 @@
     public RenderBuffer put(short[] x, int offset, int length) {
         // assert (position() % SIZEOF_SHORT == 0);
         if (length > COPY_FROM_ARRAY_THRESHOLD) {
-            long offsetInBytes = offset * SIZEOF_SHORT;
+            long offsetInBytes = offset * SIZEOF_SHORT + Unsafe.ARRAY_SHORT_BASE_OFFSET;
             long lengthInBytes = length * SIZEOF_SHORT;
-            copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
+            unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
             position(position() + lengthInBytes);
         } else {
             int end = offset + length;
@@ -215,9 +201,9 @@
     public RenderBuffer put(int[] x, int offset, int length) {
         // assert (position() % SIZEOF_INT == 0);
         if (length > COPY_FROM_ARRAY_THRESHOLD) {
-            long offsetInBytes = offset * SIZEOF_INT;
+            long offsetInBytes = offset * SIZEOF_INT + Unsafe.ARRAY_INT_BASE_OFFSET;
             long lengthInBytes = length * SIZEOF_INT;
-            copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
+            unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
             position(position() + lengthInBytes);
         } else {
             int end = offset + length;
@@ -246,9 +232,9 @@
     public RenderBuffer put(float[] x, int offset, int length) {
         // assert (position() % SIZEOF_FLOAT == 0);
         if (length > COPY_FROM_ARRAY_THRESHOLD) {
-            long offsetInBytes = offset * SIZEOF_FLOAT;
+            long offsetInBytes = offset * SIZEOF_FLOAT + Unsafe.ARRAY_FLOAT_BASE_OFFSET;
             long lengthInBytes = length * SIZEOF_FLOAT;
-            copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
+            unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
             position(position() + lengthInBytes);
         } else {
             int end = offset + length;
@@ -277,9 +263,9 @@
     public RenderBuffer put(long[] x, int offset, int length) {
         // assert (position() % SIZEOF_LONG == 0);
         if (length > COPY_FROM_ARRAY_THRESHOLD) {
-            long offsetInBytes = offset * SIZEOF_LONG;
+            long offsetInBytes = offset * SIZEOF_LONG + Unsafe.ARRAY_LONG_BASE_OFFSET;
             long lengthInBytes = length * SIZEOF_LONG;
-            copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
+            unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
             position(position() + lengthInBytes);
         } else {
             int end = offset + length;
--- a/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java	Tue May 05 09:09:24 2009 -0700
@@ -95,6 +95,11 @@
      * <pre>
      *     java -Dsun.java2d.renderer=&lt;classname&gt;
      * </pre>
+     *
+     * If no specific {@code RenderingEngine} is specified on the command
+     * or Ductus renderer is specified, it will attempt loading the
+     * sun.dc.DuctusRenderingEngine class using Class.forName as a fastpath;
+     * if not found, use the ServiceLoader.
      * If no specific {@code RenderingEngine} is specified on the command
      * line then the last one returned by enumerating all subclasses of
      * {@code RenderingEngine} known to the ServiceLoader is used.
@@ -115,9 +120,21 @@
         reImpl = (RenderingEngine)
             AccessController.doPrivileged(new PrivilegedAction() {
                 public Object run() {
+                    final String ductusREClass = "sun.dc.DuctusRenderingEngine";
                     String reClass =
-                        System.getProperty("sun.java2d.renderer",
-                                           "sun.dc.DuctusRenderingEngine");
+                        System.getProperty("sun.java2d.renderer", ductusREClass);
+                    if (reClass.equals(ductusREClass)) {
+                        try {
+                            Class cls = Class.forName(ductusREClass);
+                            return cls.newInstance();
+                        } catch (ClassNotFoundException x) {
+                            // not found
+                        } catch (IllegalAccessException x) {
+                            // should not reach here
+                        } catch (InstantiationException x) {
+                            // should not reach here
+                        }
+                    }
 
                     ServiceLoader<RenderingEngine> reLoader =
                         ServiceLoader.loadInstalled(RenderingEngine.class);
--- a/jdk/src/share/classes/sun/java2d/pisces/Stroker.java	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/src/share/classes/sun/java2d/pisces/Stroker.java	Tue May 05 09:09:24 2009 -0700
@@ -181,7 +181,7 @@
                               Transform4 transform) {
         this.lineWidth = lineWidth;
         this.lineWidth2 = lineWidth >> 1;
-        this.scaledLineWidth2 = (long)transform.m00*lineWidth2;
+        this.scaledLineWidth2 = ((long)transform.m00*lineWidth2) >> 16;
         this.capStyle = capStyle;
         this.joinStyle = joinStyle;
         this.miterLimit = miterLimit;
@@ -243,8 +243,8 @@
             if (ilen == 0) {
                 dx = dy = 0;
             } else {
-                dx = (int)( (ly*scaledLineWidth2)/ilen >> 16);
-                dy = (int)(-(lx*scaledLineWidth2)/ilen >> 16);
+                dx = (int)( (ly*scaledLineWidth2)/ilen);
+                dy = (int)(-(lx*scaledLineWidth2)/ilen);
             }
         } else {
             double dlx = x1 - x0;
--- a/jdk/src/share/native/sun/java2d/pipe/RenderBuffer.c	Mon May 04 18:28:26 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-#include "jni.h"
-#include "jni_util.h"
-#include "jlong.h"
-#include <string.h>
-
-#include "sun_java2d_pipe_RenderBuffer.h"
-
-/**
- * Note: The code in this file is nearly identical to that in
- *       java/nio/Bits.c...
- */
-
-#define MBYTE 1048576
-
-JNIEXPORT void JNICALL
-Java_sun_java2d_pipe_RenderBuffer_copyFromArray
-    (JNIEnv *env, jclass rb,
-     jobject srcArray, jlong srcPos, jlong dstAddr, jlong length)
-{
-    jbyte *bytes;
-    size_t size;
-
-    while (length > 0) {
-        /*
-         * Copy no more than one megabyte at a time, to allow for GC.
-         * (Probably not an issue for STR, since our buffer size is likely
-         * much smaller than a megabyte, but just in case...)
-         */
-        size = (size_t)(length > MBYTE ? MBYTE : length);
-
-        bytes = (*env)->GetPrimitiveArrayCritical(env, srcArray, NULL);
-        if (bytes == NULL) {
-            JNU_ThrowInternalError(env, "Unable to get array");
-            return;
-        }
-
-        memcpy(jlong_to_ptr(dstAddr), bytes + srcPos, size);
-
-        (*env)->ReleasePrimitiveArrayCritical(env, srcArray,
-                                              bytes, JNI_ABORT);
-
-        length -= size;
-        dstAddr += size;
-        srcPos += size;
-    }
-}
--- a/jdk/test/java/awt/PrintJob/EdgeTest/EdgeTest.java	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/test/java/awt/PrintJob/EdgeTest/EdgeTest.java	Tue May 05 09:09:24 2009 -0700
@@ -27,6 +27,7 @@
  * @summary Verifies that (0, 0) is the upper-left corner of the page, not
  *          the upper-left corner adjusted for the margins.
  * @author dpm
+ * @run main/manual EdgeTest
  */
 
 import java.awt.*;
@@ -43,7 +44,9 @@
                                 }
                             );
         f.setVisible(true);
-        PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", null);
+        JobAttributes job = new JobAttributes();
+        job.setDialog(JobAttributes.DialogType.NONE);
+        PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", job, null);
         if (pj != null) {
             Graphics g = pj.getGraphics();
             Dimension d = pj.getPageDimension();
--- a/jdk/test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java	Tue May 05 09:09:24 2009 -0700
@@ -44,7 +44,10 @@
     public MultipleEndFrame() {
         super("MultipleEnd");
         setVisible(true);
-        PrintJob pj  = getToolkit().getPrintJob(this, "MuiltipleEnd", null);
+
+        JobAttributes job = new JobAttributes();
+        job.setDialog(JobAttributes.DialogType.NONE);
+        PrintJob pj  = getToolkit().getPrintJob(this, "MultipleEnd", job, null);
         if (pj != null) {
             pj.end();
             pj.end();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/Collate2DPrintingTest.java	Tue May 05 09:09:24 2009 -0700
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6362683
+ * @summary Collation should work.
+ * @run main/manual Collate2DPrintingTest
+ */
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+import javax.print.attribute.standard.*;
+import javax.print.attribute.*;
+import javax.print.*;
+import java.io.*;
+
+public class Collate2DPrintingTest
+    extends Frame implements Doc, Printable, ActionListener {
+
+        Button print2D = new Button("2D Print");
+        Button printMerlin = new Button("PrintService");
+        PrinterJob pj = PrinterJob.getPrinterJob();
+        PrintService defService = null;
+        HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
+
+    public Collate2DPrintingTest() {
+
+        Panel butPanel = new Panel();
+        butPanel.add(print2D);
+        butPanel.add(printMerlin);
+        print2D.addActionListener(this);
+        printMerlin.addActionListener(this);
+        addWindowListener (new WindowAdapter() {
+            public void windowClosing (WindowEvent e) {
+                dispose();
+            }
+        });
+        add("South", butPanel);
+
+        defService = PrintServiceLookup.lookupDefaultPrintService();
+        PrintService[] pservice;
+        if (defService == null) {
+            pservice = PrintServiceLookup.lookupPrintServices(null, null);
+            if (pservice.length == 0) {
+                throw new RuntimeException("No printer found.  TEST ABORTED");
+            }
+            defService = pservice[0];
+        }
+        prSet.add(SheetCollate.COLLATED);
+        prSet.add(new Copies(2));
+        pj.setPrintable(Collate2DPrintingTest.this);
+        setSize(300, 200);
+        setVisible(true);
+    }
+
+
+    public int print(Graphics g, PageFormat pf, int pageIndex)
+          throws PrinterException {
+        g.drawString("Page: " + pageIndex, 100, 100);
+        if (pageIndex == 2) {
+            return Printable.NO_SUCH_PAGE;
+        } else {
+            return Printable.PAGE_EXISTS;
+        }
+    }
+
+    public void actionPerformed (ActionEvent ae) {
+        try {
+            if (ae.getSource() == print2D) {
+                if (pj.printDialog(prSet)) {
+                    pj.print(prSet);
+                }
+            } else {
+                DocPrintJob pj = defService.createPrintJob();
+                pj.print(this, prSet);
+            }
+            System.out.println ("DONE");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public DocAttributeSet getAttributes() {
+        return null;
+    }
+
+    public DocFlavor getDocFlavor() {
+        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
+        return flavor;
+    }
+
+    public Object getPrintData() {
+        return this;
+    }
+
+    public Reader getReaderForText() {
+        return null;
+    }
+
+    public InputStream getStreamForBytes() {
+        return null;
+    }
+
+  public static void main( String[] args) {
+
+  String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "The print result should be collated."
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+     new Collate2DPrintingTest();
+  }
+}
+
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.setVisible(true);
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.setVisible(true);
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      setVisible(true);
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/PrtException.java	Tue May 05 09:09:24 2009 -0700
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+  @test
+  @bug 4429544
+  @summary This test should not throw a printer exception. Test has been modified to correspond with the behavior of 1.5 and above.
+  @run main PrtException
+*/
+
+import java.awt.*;
+import java.awt.print.*;
+import javax.print.*;
+
+public class PrtException implements Printable {
+    PrinterJob pj;
+
+    public PrtException() {
+
+        try{
+            PrintService[] svc;
+            PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
+            if (defService == null) {
+                svc = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
+                if (svc.length == 0) {
+                    throw new RuntimeException("Printer is required for this test.  TEST ABORTED");
+                }
+                defService = svc[0];
+            }
+
+            System.out.println("PrintService found : "+defService);
+            pj = PrinterJob.getPrinterJob();;
+            pj.setPrintService(defService);
+            //pj.setPrintable(this); // commenting this line should not result in PrinterException
+            pj.print();
+        } catch(PrinterException e ) {
+            e.printStackTrace();
+            throw new RuntimeException(" PrinterException should not be thrown. TEST FAILED");
+        }
+        System.out.println("TEST PASSED");
+    }
+
+
+    public int print(Graphics g,PageFormat pf,int pageIndex) {
+        Graphics2D g2= (Graphics2D)g;
+        if(pageIndex>=1){
+            return Printable.NO_SUCH_PAGE;
+        }
+        g2.translate(pf.getImageableX(), pf.getImageableY());
+        g2.setColor(Color.black);
+        g2.drawString("Hello world.", 10, 10);
+
+        return Printable.PAGE_EXISTS;
+    }
+
+    public static void main(String arg[]) {
+        PrtException sp = new PrtException();
+    }
+}
--- a/jdk/test/javax/print/CheckDupFlavor.java	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/test/javax/print/CheckDupFlavor.java	Tue May 05 09:09:24 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2004-2009 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,17 +35,19 @@
 
 public class CheckDupFlavor {
     public static void main(String[] args){
-        PrintService pservice =
-                     PrintServiceLookup.lookupDefaultPrintService();
-
-        if (pservice == null) {
-                System.out.println("No default PrintService found. Test ABORTED.");
-            return;
+        PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
+        PrintService[] pservice;
+        if (defService == null) {
+            pservice = PrintServiceLookup.lookupPrintServices(null, null);
+            if (pservice.length == 0) {
+                throw new RuntimeException("No printer found.  TEST ABORTED");
+            }
+            defService = pservice[0];
         }
 
-        System.out.println("Default service = "+pservice);
+        System.out.println("PrintService = "+defService);
 
-        DocFlavor[] flavors = pservice.getSupportedDocFlavors();
+        DocFlavor[] flavors = defService.getSupportedDocFlavors();
         if (flavors==null) {
             System.out.println("No flavors supported. Test PASSED.");
             return;
@@ -54,13 +56,13 @@
 
         ArrayList flavorList = new ArrayList();
         for (int i=0; i<flavors.length; i++) {
-                if (flavors[i] == null) {
-                        throw new RuntimeException("Null flavor. Test FAILED.");
-                } else if (flavorList.contains(flavors[i])) {
-                        throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
-                } else {
-                        flavorList.add(flavors[i]);
-                }
+            if (flavors[i] == null) {
+                 throw new RuntimeException("Null flavor. Test FAILED.");
+            } else if (flavorList.contains(flavors[i])) {
+                 throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
+            } else {
+                flavorList.add(flavors[i]);
+            }
         }
         System.out.println("No duplicate found. Test PASSED.");
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/print/LookupServices.java	Tue May 05 09:09:24 2009 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4510477 6520186
+ * @summary No crash with HP OfficeJet 600 installed.
+ * @run main LookupServices
+*/
+
+import javax.print.attribute.*;
+import javax.print.*;
+
+public class LookupServices {
+    public static void main (String [] args) {
+
+        DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
+        HashPrintRequestAttributeSet prSet = null;
+
+        PrintService[] serv = PrintServiceLookup.lookupPrintServices(flavor, null);
+        System.out.println("default "+PrintServiceLookup.lookupDefaultPrintService());
+        if (serv.length==0) {
+            System.out.println("no PrintService supports GIF");
+            return;
+        }
+
+        System.out.println("Selected print service: "+ serv[0]);
+    }
+
+}
--- a/jdk/test/javax/print/TestRaceCond.java	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/test/javax/print/TestRaceCond.java	Tue May 05 09:09:24 2009 -0700
@@ -43,6 +43,10 @@
         PrintService[] pservs = PrintServiceLookup.lookupPrintServices(null, null);
         PrintService pserv2 = PrintServiceLookup.lookupDefaultPrintService();
 
+        if ((pserv1 == null) || (pserv2==null)) {
+            return;
+        }
+
         if (pserv1.hashCode() != pserv2.hashCode()) {
             throw new RuntimeException("Different hashCodes for equal print "
                             + "services: " + pserv1.hashCode() + " "
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/print/attribute/Chroma.java	Tue May 05 09:09:24 2009 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test 1.3 01/05/11
+ * @bug 4456750
+ * @summary Test for supported chromaticity values with null DocFlavor.
+ *          No exception should be thrown.
+ * @run main Chroma
+*/
+
+// Chroma.java
+import java.io.*;
+
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class Chroma {
+
+   public static void main(String args[]) {
+
+      StreamPrintServiceFactory []fact =
+        StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
+              DocFlavor.SERVICE_FORMATTED.PRINTABLE,
+              DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
+
+      if (fact.length != 0) {
+          OutputStream out = new ByteArrayOutputStream();
+          StreamPrintService sps = fact[0].getPrintService(out);
+          checkChroma(sps);
+      }
+
+      PrintService defSvc = PrintServiceLookup.lookupDefaultPrintService();
+      if (defSvc != null) {
+           checkChroma(defSvc);
+      }
+
+   }
+
+    static void checkChroma(PrintService svc) {
+       if (svc.isAttributeCategorySupported(Chromaticity.class)) {
+            svc.getSupportedAttributeValues(Chromaticity.class,null,null);
+       }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/print/attribute/ChromaticityValues.java	Tue May 05 09:09:24 2009 -0700
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 4446106
+ * @summary Test for chromaticity values.
+ * @run main ChromaticityValues
+*/
+
+
+
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+import java.util.ArrayList;
+
+public class ChromaticityValues {
+
+    public static void main(String args[]) {
+        System.out.println("=======================================================================");
+        System.out.println("INSTRUCTIONS: This test is only for WINDOWS platform. ");
+        System.out.println("You should have a printer configured as your default printer in your system.");
+        System.out.println("=======================================================================");
+
+        String os=System.getProperty("os.name").toLowerCase();
+
+        if (!(os.indexOf("win")>=0)) {
+            System.out.println("Not a Windows System.  TEST ABORTED");
+            return;
+        }
+
+        PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();
+        if (pservice == null) {
+            throw new RuntimeException("A printer is required for this test.");
+        }
+
+        System.out.println("Default Service is "+pservice);
+        ColorSupported psa = (ColorSupported)pservice.getAttribute(ColorSupported.class);
+        ArrayList cValues = new ArrayList();
+
+        if (pservice.isAttributeCategorySupported(Chromaticity.class)) {
+            Chromaticity[] values =(Chromaticity[])
+                (pservice.getSupportedAttributeValues(Chromaticity.class, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null));
+            if ((values != null) && (values.length > 0)) {
+                for (int i=0; i<values.length; i++) {
+                    cValues.add(values[i]);
+                }
+            } else {
+                System.out.println("Chromaticity value is unknown. TEST ABORTED");
+                return;
+            }
+
+        } else {
+            System.out.println("Chromaticity is not supported. TEST ABORTED");
+            return;
+
+        }
+
+        if (psa != null) {
+            if (psa.equals(ColorSupported.SUPPORTED)) {
+                if (cValues.size() < 2) {
+                    throw new RuntimeException("ColorSupported is supported, values for Chromaticity should be monochrome and color.");
+                }
+            } else {
+                if ((cValues.size() != 1) ||
+                    (!cValues.contains(Chromaticity.MONOCHROME))) {
+                    throw new RuntimeException("ColorSupported is not supported, values for Chromaticity should only be monochrome.");
+                }
+            }
+        } else { // ColorSupported unknown
+            if (!cValues.contains(Chromaticity.COLOR)) {
+                throw new RuntimeException("ColorSupported is unknown, values for Chromaticity should at least include color.");
+            }
+
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/print/attribute/GetCopiesSupported.java	Tue May 05 09:09:24 2009 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+  @test
+  @bug 4463280
+  @summary No ClassCastException should occur.
+  @run main GetCopiesSupported
+*/
+
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class GetCopiesSupported {
+
+    public static void main(String args[]) {
+        PrintService service = PrintServiceLookup.lookupDefaultPrintService();
+        PrintService[] pservice;
+        if (service == null) {
+             pservice = PrintServiceLookup.lookupPrintServices(null, null);
+            if (pservice.length == 0) {
+                    throw new RuntimeException("No printer found.  TEST ABORTED");
+            }
+            service = pservice[0];
+        }
+
+        if (service != null) {
+            CopiesSupported c = (CopiesSupported)
+               service.getSupportedAttributeValues(Copies.class,
+                                                   null, null);
+
+           System.out.println("CopiesSupported : "+c);
+        }
+    }
+
+
+}
--- a/jdk/test/javax/print/attribute/PSCopiesFlavorTest.java	Mon May 04 18:28:26 2009 -0700
+++ b/jdk/test/javax/print/attribute/PSCopiesFlavorTest.java	Tue May 05 09:09:24 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2007-2009 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,26 +37,26 @@
    public static void main(String args[]) {
 
        DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
-       PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
-       if (!(ps.isDocFlavorSupported(flavor))) {
-           System.out.println("unsupported flavor :" + flavor);
-           return;
+       PrintService[] ps = PrintServiceLookup.lookupPrintServices(flavor, null);
+       if (ps.length > 0) {
+           System.out.println("found PrintService: "+ps[0]);
+           Copies c = new Copies(1);
+           PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+           aset.add(c);
+           boolean suppVal = ps[0].isAttributeValueSupported(c, flavor, null);
+           AttributeSet us = ps[0].getUnsupportedAttributes(flavor, aset);
+           if (suppVal || us == null) {
+               throw new RuntimeException("Copies should be unsupported value");
+           }
+
+           Object value = ps[0].getSupportedAttributeValues(Copies.class,
+                                                            flavor, null);
+
+            //Copies Supported
+            if(value instanceof CopiesSupported) {
+                throw new RuntimeException("Copies should have no supported values.");
+            }
        }
-       Copies c = new Copies(1);
-       PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
-       aset.add(c);
-       boolean suppVal = ps.isAttributeValueSupported(c, flavor, null);
-       AttributeSet us = ps.getUnsupportedAttributes(flavor, aset);
-       if (suppVal || us == null) {
-           throw new RuntimeException("Copies should be unsupported value");
-       }
-
-       Object value = ps.getSupportedAttributeValues(Copies.class, flavor, null);
-
-        //Copies Supported
-        if(value instanceof CopiesSupported) {
-            throw new RuntimeException("Copies should have no supported values.");
-        }
 
    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/print/attribute/SidesPageRangesTest.java	Tue May 05 09:09:24 2009 -0700
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 4903366
+ * @summary No crash should occur.
+ * @run main SidesPageRangesTest
+*/
+import java.awt.*;
+import javax.print.*;
+import javax.print.attribute.standard.*;
+import javax.print.attribute.*;
+import java.io.*;
+import java.util.Locale;
+import java.net.URL;
+
+public class SidesPageRangesTest {
+        /**
+         * Constructor
+         */
+         public SidesPageRangesTest() {
+                super();
+        }
+        /**
+         * Starts the application.
+         */
+        public static void main(java.lang.String[] args) {
+                SidesPageRangesTest pd = new SidesPageRangesTest();
+                PrintService defService = null;
+                DocFlavor flavors[]  = null;
+                PrintService[] pservice;
+                defService = PrintServiceLookup.lookupDefaultPrintService();
+                if (defService == null) {
+                    pservice = PrintServiceLookup.lookupPrintServices(null, null);
+                    if (pservice.length == 0) {
+                        throw new RuntimeException("Printer is required for this test.  TEST ABORTED");
+                    }
+                    defService = pservice[0];
+                }
+                System.out.println("Default Print Service "+defService);
+
+
+                if (defService.isAttributeCategorySupported(PageRanges.class)) {
+                        System.out.println("\nPageRanges Attribute category is supported");
+                } else {
+                        System.out.println("\nPageRanges Attribute category is not supported. terminating...");
+                        System.exit(1);
+                }
+
+                flavors = defService.getSupportedDocFlavors();
+                System.out.println("\nGetting Supported values for PageRanges for each supported DocFlavor");
+                System.out.println("===============================================================\n");
+                for (int y = 0; y < flavors.length; y ++) {
+                    System.out.println("\n\n");
+
+                    System.out.println("Doc Flavor: "+flavors[y]);
+                    System.out.println("-----------------------------");
+
+                    Object vals = defService.getSupportedAttributeValues(PageRanges.class, flavors[y], null);
+                    if (vals == null) {
+                        System.out.println("No supported values for PageRanges for this doc flavor. ");
+                    }
+
+                    PageRanges[] pr = null;
+                    if (vals instanceof PageRanges[]) {
+                        pr = (PageRanges[]) vals;
+                        for (int x = 0; x < pr.length; x ++) {
+                            System.out.println("\nSupported Value "+pr[x]);
+                            System.out.println("is "+pr[x]+" value supported? "+defService.isAttributeValueSupported(pr[x], flavors[y], null));
+
+                            if (!defService.isAttributeValueSupported(pr[x], flavors[y], null)) {
+                                throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
+                            }
+                        }
+                    } else if (vals instanceof PageRanges) {
+                        System.out.println(vals);
+                        System.out.println("is "+vals+" value supported? "+defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null));
+                        if (!defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null)) {
+                            throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
+                        }
+                    }
+
+                    // SIDES test
+                    vals = defService.getSupportedAttributeValues(Sides.class, flavors[y], null);
+                    if (vals == null) {
+                        System.out.println("No supported values for Sides for this doc flavor. ");
+                    }
+
+                    Sides[] s = null;
+                    if (vals instanceof Sides[]) {
+                        s = (Sides[]) vals;
+                        for (int x = 0; x < s.length; x ++) {
+                            System.out.println("\nSupported Value "+s[x]);
+                            System.out.println("is "+s[x]+" value supported? "+defService.isAttributeValueSupported(s[x], flavors[y], null));
+                            if  (!defService.isAttributeValueSupported(s[x], flavors[y], null)) {
+                                throw new RuntimeException("Sides contradicts getSupportedAttributeValues");
+                            }
+                        }
+                    }
+                }
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/print/attribute/SupportedPrintableAreas.java	Tue May 05 09:09:24 2009 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4762773 6289206 6324049 6362765
+ * @summary Tests that get non-null return list of printable areas.
+ * @run main SupportedPrintableAreas
+ */
+
+
+import javax.print.*;
+import javax.print.event.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class SupportedPrintableAreas {
+
+  public static void main(String[] args) {
+     PrintService[] svc;
+     PrintService printer = PrintServiceLookup.lookupDefaultPrintService();
+     if (printer == null) {
+         svc = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
+         if (svc.length == 0) {
+             throw new RuntimeException("Printer is required for this test.  TEST ABORTED");
+         }
+         printer = svc[0];
+     }
+     System.out.println("PrintService found : "+printer);
+
+     if (!printer.isAttributeCategorySupported(MediaPrintableArea.class)) {
+         return;
+     }
+     Object value = printer.getSupportedAttributeValues(
+                    MediaPrintableArea.class, null, null);
+     if (!value.getClass().isArray()) {
+         throw new RuntimeException("unexpected value");
+      }
+
+     PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+     value = printer.getSupportedAttributeValues(
+                    MediaPrintableArea.class, null, aset);
+     if (!value.getClass().isArray()) {
+         throw new RuntimeException("unexpected value");
+      }
+
+     Media media = (Media)printer.getDefaultAttributeValue(Media.class);
+     aset.add(media);
+     value = printer.getSupportedAttributeValues(
+                    MediaPrintableArea.class, null, aset);
+     if (!value.getClass().isArray()) {
+         throw new RuntimeException("unexpected value");
+     }
+
+     // test for 6289206
+     aset.add(MediaTray.MANUAL);
+     value = printer.getSupportedAttributeValues(
+                    MediaPrintableArea.class, null, aset);
+     if ((value != null) && !value.getClass().isArray()) {
+         throw new RuntimeException("unexpected value");
+     }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/print/attribute/autosense/PrintAutoSenseData.java	Tue May 05 09:09:24 2009 -0700
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4468109
+ * @summary Test for printing AUTOSENSE DocFlavor.  No exception should be thrown.
+ * @run main PrintAutoSenseData
+*/
+
+import java.io.*;
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+import java.net.URL;
+
+public class PrintAutoSenseData
+{
+  private DocFlavor flavor = DocFlavor.URL.AUTOSENSE; //represents the docflavor.
+  private PrintService[] service = PrintServiceLookup.lookupPrintServices(flavor, null);
+
+
+  public PrintAutoSenseData()
+  {
+     if (service.length == 0)
+     {
+        System.out.println("No print service available...");
+        return;
+     }
+
+     System.out.println("selected PrintService: " + this.service[0]);
+     if (service[0].isDocFlavorSupported(flavor)) {
+         System.out.println("DocFlavor.URL.AUTOSENSE supported");
+     } else {
+         System.out.println("DocFlavor.URL.AUTOSENSE not supported. Testing aborted !!");
+         return;
+     }
+
+     DocPrintJob job = service[0].createPrintJob();
+     this.print();
+  }
+
+  // The print method prints sample file with DocFlavor.URL.AUTOSENSE.
+  void print()
+  {
+         String fileName = "./sample.txt";
+         DocPrintJob job = service[0].createPrintJob();
+
+         // The representation class is a URL.
+         System.out.println("printing " + fileName + " using doc flavor: " + this.flavor);
+         System.out.println("Rep. class name: " + this.flavor.getRepresentationClassName() + " MimeType: " + this.flavor.getMimeType());
+
+         Doc doc = new URLDoc(fileName, this.flavor);
+         HashPrintRequestAttributeSet prSet =
+             new HashPrintRequestAttributeSet();
+         prSet.add(new Destination(new File("./dest.prn").toURI()));
+         //print the document.
+         try {
+            job.print(doc, prSet);
+         } catch ( Exception e ) {
+            e.printStackTrace();
+         }
+  }
+
+  public static void main(String[] args) {
+     new PrintAutoSenseData();
+  }
+
+}
+
+/* This class is for reading autosense data with URL representation class */
+
+class URLDoc implements Doc
+{
+   protected String fileName = null;
+   protected DocFlavor flavor = null;
+   protected Object printData = null;
+   protected InputStream instream = null;
+
+   public URLDoc(String filename, DocFlavor docFlavor)
+   {
+      this.fileName = filename;
+      this.flavor = docFlavor;
+   }
+
+   public DocFlavor getDocFlavor() {
+       return DocFlavor.URL.AUTOSENSE;
+   }
+
+   public DocAttributeSet getAttributes()
+   {
+       HashDocAttributeSet hset = new HashDocAttributeSet();
+       return hset;
+   }
+
+   public Object getPrintData()
+   {
+     if ( this.printData == null )
+     {
+        this.printData = URLDoc.class.getResource(this.fileName);
+        System.out.println("getPrintData(): " + this.printData);
+     }
+     return this.printData;
+   }
+
+   public Reader getReaderForText()
+   {
+     return null;
+   }
+
+   public InputStream getStreamForBytes()
+   {
+     System.out.println("getStreamForBytes(): " + this.printData);
+     try
+     {
+        if ( (this.printData != null) && (this.printData instanceof URL) )
+        {
+           this.instream = ((URL)this.printData).openStream();
+        }
+        if (this.instream == null)
+        {
+           URL url = URLDoc.class.getResource(this.fileName);
+           this.instream = url.openStream();
+        }
+      }
+      catch ( IOException ie )
+      {
+         System.out.println("URLDoc: exception: " + ie.toString());
+      }
+      return this.instream;
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/pisces/StrokeShapeTest.java	Tue May 05 09:09:24 2009 -0700
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+import java.awt.*;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.GeneralPath;
+import java.awt.image.BufferedImage;
+import java.io.File;
+
+import javax.imageio.ImageIO;
+
+/**
+ * @author chrisn@google.com (Chris Nokleberg)
+ * @author yamauchi@google.com (Hiroshi Yamauchi)
+ */
+public class StrokeShapeTest {
+  public static void main(String[] args) throws Exception {
+    BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
+    Graphics2D g = image.createGraphics();
+    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+    g.setPaint(Color.WHITE);
+    g.fill(new Rectangle(image.getWidth(), image.getHeight()));
+    g.translate(25, 100);
+
+    Stroke stroke = new BasicStroke(200, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
+    Shape shape = new Polygon(new int[] {0, 1500, 0}, new int[] {750, 0, -750}, 3);
+
+    g.scale(.1, .1);
+    g.setPaint(Color.BLACK);
+    g.setStroke(stroke);
+    g.draw(shape);
+    g.setPaint(Color.RED);
+    g.fill(stroke.createStrokedShape(shape));
+
+    // To visually check it
+    //ImageIO.write(image, "PNG", new File(args[0]));
+
+    boolean blackPixelFound = false;
+    outer:
+    for (int x = 0; x < 200; ++x) {
+      for (int y = 0; y < 200; ++y) {
+        if (image.getRGB(x, y) == Color.BLACK.getRGB()) {
+          blackPixelFound = true;
+          break outer;
+        }
+      }
+    }
+    if (blackPixelFound) {
+      throw new RuntimeException("The shape hasn't been filled in red.");
+    }
+  }
+}