< prev index next >

src/java.desktop/share/classes/java/awt/image/ColorModel.java

Print this page
rev 55657 : 8227587: Add internal privileged System.loadLibrary
Reviewed-by: rriggs
   1 /*
   2  * Copyright (c) 1995, 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


 186      * the JNI field and method ids used in the native portion of
 187      * their implementation.
 188      *
 189      * Since the use and storage of these ids is done by the
 190      * implementation libraries, the implementation of these method is
 191      * provided by the particular AWT implementations (for example,
 192      * "Toolkit"s/Peer), such as Motif, Microsoft Windows, or Tiny. The
 193      * problem is that this means that the native libraries must be
 194      * loaded by the java.* classes, which do not necessarily know the
 195      * names of the libraries to load. A better way of doing this
 196      * would be to provide a separate library which defines java.awt.*
 197      * initIDs, and exports the relevant symbols out to the
 198      * implementation libraries.
 199      *
 200      * For now, we know it's done by the implementation, and we assume
 201      * that the name of the library is "awt".  -br.
 202      */
 203     private static boolean loaded = false;
 204     static void loadLibraries() {
 205         if (!loaded) {
 206             java.security.AccessController.doPrivileged(
 207                 new java.security.PrivilegedAction<Void>() {
 208                     public Void run() {
 209                         System.loadLibrary("awt");
 210                         return null;
 211                     }
 212                 });
 213             loaded = true;
 214         }
 215     }
 216     private static native void initIDs();
 217     static {
 218         /* ensure that the proper libraries are loaded */
 219         loadLibraries();
 220         initIDs();
 221     }
 222     private static ColorModel RGBdefault;
 223 
 224     /**
 225      * Returns a {@code DirectColorModel} that describes the default
 226      * format for integer RGB values used in many of the methods in the
 227      * AWT image interfaces for the convenience of the programmer.
 228      * The color space is the default {@link ColorSpace}, sRGB.
 229      * The format for the RGB values is an integer with 8 bits
 230      * each of alpha, red, green, and blue color components ordered
 231      * correspondingly from the most significant byte to the least
 232      * significant byte, as in:  0xAARRGGBB.  Color components are


   1 /*
   2  * Copyright (c) 1995, 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


 186      * the JNI field and method ids used in the native portion of
 187      * their implementation.
 188      *
 189      * Since the use and storage of these ids is done by the
 190      * implementation libraries, the implementation of these method is
 191      * provided by the particular AWT implementations (for example,
 192      * "Toolkit"s/Peer), such as Motif, Microsoft Windows, or Tiny. The
 193      * problem is that this means that the native libraries must be
 194      * loaded by the java.* classes, which do not necessarily know the
 195      * names of the libraries to load. A better way of doing this
 196      * would be to provide a separate library which defines java.awt.*
 197      * initIDs, and exports the relevant symbols out to the
 198      * implementation libraries.
 199      *
 200      * For now, we know it's done by the implementation, and we assume
 201      * that the name of the library is "awt".  -br.
 202      */
 203     private static boolean loaded = false;
 204     static void loadLibraries() {
 205         if (!loaded) {
 206             jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt");






 207             loaded = true;
 208         }
 209     }
 210     private static native void initIDs();
 211     static {
 212         /* ensure that the proper libraries are loaded */
 213         loadLibraries();
 214         initIDs();
 215     }
 216     private static ColorModel RGBdefault;
 217 
 218     /**
 219      * Returns a {@code DirectColorModel} that describes the default
 220      * format for integer RGB values used in many of the methods in the
 221      * AWT image interfaces for the convenience of the programmer.
 222      * The color space is the default {@link ColorSpace}, sRGB.
 223      * The format for the RGB values is an integer with 8 bits
 224      * each of alpha, red, green, and blue color components ordered
 225      * correspondingly from the most significant byte to the least
 226      * significant byte, as in:  0xAARRGGBB.  Color components are


< prev index next >