Bug 578382

Summary: PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PAGEABLE, null) in a simple test java program fails to list printers when run with gcj - Any conventional JRE seems to work that I have tested
Product: Red Hat Enterprise Linux 5 Reporter: Michael Kearey <mkearey>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: medium Docs Contact:
Priority: medium    
Version: 5.4CC: aph, iannis, jakub, mnowak, pmuller, tao, twaugh, wmealing
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gcc-4.1.2-49.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-01-13 23:57:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michael Kearey 2010-03-31 06:18:21 UTC
Description of problem:

A simple test program that utilises PrintServiceLookup.lookupPrintServices with an appropriate DocFlavor fails to return a list of printers under gcj. Yet the same program built and run under any conventional JRE I could find does return printers and status.

Version-Release number of selected component (if applicable):


I tested on the following:

 /usr/bin/gcj -V
gcj: '-V' option must have argument
[meon@aserver 649443]$ /usr/bin/gcj -v
Using built-in specs.
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/4.4.1/libgcj.spec
rename spec startfile to startfileorig
rename spec lib to liborig
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i586 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.1 20090725 (Red Hat 4.4.1-2) (GCC) 

How reproducible:
100%

Steps to Reproduce:

1. Create a listprinters.java file with the simple test code
2. Build a binary  gcj -o listprinters --main=listprinters ./listprinters.java
3.  Run the binary 
  
Actual results:
Receive "found 0 services" response from the test program run via gcj.

Expected results:
The gcj executable should display the same printers available on the host as the program run via any conventional JRE does.

Additional info:

I have found that this works under gcj :


import javax.print.attribute.standard.PrinterIsAcceptingJobs;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;


class listprinters {



        public static void main(String[] argv) {
                PrintService ss[] = PrintServiceLookup.lookupPrintServices(null,null);
                System.out.println("found " + ss.length + " services");
                for(int i = 0; i < ss.length; i++) {
                        javax.print.attribute.Attribute att[] = ss[i].getAttributes().toArray();
                        System.out.println("found " + att.length + " attributes for " + ss[i].getName());
                        for(int j = 0; j < att.length; j++)
                                System.out.println(ss[i].getName() + "/" + att[j].getName() +
                                        (att[j].equals(PrinterIsAcceptingJobs.ACCEPTING_JOBS) ?
                                        "" : "not") + " accepting jobs"
                                );
                }
        }
}



Yet the following does not:

import javax.print.attribute.standard.PrinterIsAcceptingJobs;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.DocFlavor;


class listprinters {



        public static void main(String[] argv) {
                /*PrintService ss[] = PrintServiceLookup.lookupPrintServices(null,null);*/
                PrintService ss[] = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
                System.out.println("found " + ss.length + " services");
                for(int i = 0; i < ss.length; i++) {
                        javax.print.attribute.Attribute att[] = ss[i].getAttributes().toArray();
                        System.out.println("found " + att.length + " attributes for " + ss[i].getName());
                        for(int j = 0; j < att.length; j++)
                                System.out.println(ss[i].getName() + "/" + att[j].getName() +
                                        (att[j].equals(PrinterIsAcceptingJobs.ACCEPTING_JOBS) ?
                                        "" : "not") + " accepting jobs"
                                );
                }
        }
}



I used DocFlavor.SERVICE_FORMATTED.PAGEABLE,null as args  to lookupPrintServices. In a standard JRE, it gets a list of printers but in GCJ it fails to return any.

This appears to be a problem in the way it uses DocFlavor I think.

Comment 1 Jakub Jelinek 2010-03-31 08:15:40 UTC
Why do you file this against gcc44 and against RHEL5?  gcc44 shipped in RHEL5 never included Java support (and the latest gcc44 there is 4.4.0-6.el5
anyway) and gcj in RHEL5 is 4.1.x-ish.
gcj in RHEL6 is going to be 4.4.3-ish or later, 4.4.1-2 is Fedora 11 update.

Comment 2 Wade Mealing 2010-04-05 09:43:28 UTC
As Mike is away on leave, I am watching his queue.

The source rpm for libgcj seems to be  gcc-4.1.2-46.el5.src.rpm so I'll file this against gcc for el5.  Feel free to move it to where it needs to be so that it can get the correct visibility to the engineering who can work on it.

Which component should it be filed against ?

Comment 15 Jakub Jelinek 2010-09-27 06:33:44 UTC
In gcc-4.1.2-49.el5

Comment 19 errata-xmlrpc 2011-01-13 23:57:56 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0025.html

Comment 20 Tim Waugh 2011-04-15 12:11:49 UTC
*** Bug 651381 has been marked as a duplicate of this bug. ***