< prev index next >

src/java.desktop/unix/classes/sun/print/CUPSPrinter.java

Print this page
rev 55657 : 8227587: Add internal privileged System.loadLibrary
Reviewed-by: rriggs
   1 /*
   2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  64     //public static boolean useIPPMedia = false; will be used later
  65 
  66     private MediaPrintableArea[] cupsMediaPrintables;
  67     private MediaSizeName[] cupsMediaSNames;
  68     private CustomMediaSizeName[] cupsCustomMediaSNames;
  69     private MediaTray[] cupsMediaTrays;
  70 
  71     public  int nPageSizes = 0;
  72     public  int nTrays = 0;
  73     private  String[] media;
  74     private  float[] pageSizes;
  75     int[]   resolutionsArray;
  76     private String printer;
  77 
  78     private static boolean libFound;
  79     private static String cupsServer = null;
  80     private static int cupsPort = 0;
  81 
  82     static {
  83         // load awt library to access native code
  84         java.security.AccessController.doPrivileged(
  85             new java.security.PrivilegedAction<Void>() {
  86                 public Void run() {
  87                     System.loadLibrary("awt");
  88                     return null;
  89                 }
  90             });
  91         libFound = initIDs();
  92         if (libFound) {
  93            cupsServer = getCupsServer();
  94            cupsPort = getCupsPort();
  95         }
  96     }
  97 
  98 
  99     CUPSPrinter (String printerName) {
 100         if (printerName == null) {
 101             throw new IllegalArgumentException("null printer name");
 102         }
 103         printer = printerName;
 104         cupsMediaSNames = null;
 105         cupsMediaPrintables = null;
 106         cupsMediaTrays = null;
 107         initialized = false;
 108 
 109         if (!libFound) {
 110             throw new RuntimeException("cups lib not found");


   1 /*
   2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  64     //public static boolean useIPPMedia = false; will be used later
  65 
  66     private MediaPrintableArea[] cupsMediaPrintables;
  67     private MediaSizeName[] cupsMediaSNames;
  68     private CustomMediaSizeName[] cupsCustomMediaSNames;
  69     private MediaTray[] cupsMediaTrays;
  70 
  71     public  int nPageSizes = 0;
  72     public  int nTrays = 0;
  73     private  String[] media;
  74     private  float[] pageSizes;
  75     int[]   resolutionsArray;
  76     private String printer;
  77 
  78     private static boolean libFound;
  79     private static String cupsServer = null;
  80     private static int cupsPort = 0;
  81 
  82     static {
  83         // load awt library to access native code
  84         jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt");






  85         libFound = initIDs();
  86         if (libFound) {
  87            cupsServer = getCupsServer();
  88            cupsPort = getCupsPort();
  89         }
  90     }
  91 
  92 
  93     CUPSPrinter (String printerName) {
  94         if (printerName == null) {
  95             throw new IllegalArgumentException("null printer name");
  96         }
  97         printer = printerName;
  98         cupsMediaSNames = null;
  99         cupsMediaPrintables = null;
 100         cupsMediaTrays = null;
 101         initialized = false;
 102 
 103         if (!libFound) {
 104             throw new RuntimeException("cups lib not found");


< prev index next >