--- old/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2015-11-13 13:04:31.212105298 +0530 +++ new/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2015-11-13 13:04:31.048105299 +0530 @@ -740,7 +740,19 @@ } updatePageAttributes(service, page); - PageFormat newPage = pageDialog(attributes); + PageFormat newPage = null; + DialogTypeSelection dts = + (DialogTypeSelection)attributes.get(DialogTypeSelection.class); + if (dts == DialogTypeSelection.NATIVE) { + // Remove DialogTypeSelection.NATIVE to prevent infinite loop in + // RasterPrinterJob. + attributes.remove(DialogTypeSelection.class); + newPage = pageDialog(attributes); + // restore attribute + attributes.add(DialogTypeSelection.NATIVE); + } else { + newPage = pageDialog(attributes); + } if (newPage == null) { return page; @@ -881,7 +893,7 @@ PrintService service = java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public PrintService run() { - PrintService service = getPrintService(); + PrintService service = getPrintService(); if (service == null) { ServiceDialog.showNoPrintService(gc); return null; @@ -927,7 +939,7 @@ PrintService newService; // temporarily add an attribute pointing back to this job. PrinterJobWrapper jobWrapper = new PrinterJobWrapper(this); - attributes.add(jobWrapper); + attributes.add(jobWrapper); try { newService = ServiceUI.printDialog(gc, x, y, @@ -1614,7 +1626,7 @@ * for a printer may override this method. */ public PageFormat defaultPage(PageFormat page) { - PageFormat newPage = (PageFormat)page.clone(); + PageFormat newPage = (PageFormat)page.clone(); newPage.setOrientation(PageFormat.PORTRAIT); Paper newPaper = new Paper(); double ptsPerInch = 72.0;