< prev index next >

src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java

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


  94     // cache of font peers
  95     private Hashtable<String,FontPeer> cacheFontPeer;
  96 
  97     // Windows properties
  98     private WDesktopProperties  wprops;
  99 
 100     // Dynamic Layout Resize client code setting
 101     protected boolean dynamicLayoutSetting = false;
 102 
 103     //Is it allowed to generate events assigned to extra mouse buttons.
 104     //Set to true by default.
 105     private static boolean areExtraMouseButtonsEnabled = true;
 106 
 107     /**
 108      * Initialize JNI field and method IDs
 109      */
 110     private static native void initIDs();
 111     private static boolean loaded = false;
 112     public static void loadLibraries() {
 113         if (!loaded) {
 114             java.security.AccessController.doPrivileged(
 115                 new java.security.PrivilegedAction<Void>() {
 116                     @Override
 117                     public Void run() {
 118                         System.loadLibrary("awt");
 119                         return null;
 120                     }
 121                 });
 122             loaded = true;
 123         }
 124     }
 125 
 126     private static native String getWindowsVersion();
 127 
 128     static {
 129         loadLibraries();
 130         initIDs();
 131 
 132         // Print out which version of Windows is running
 133         if (log.isLoggable(PlatformLogger.Level.FINE)) {
 134             log.fine("Win version: " + getWindowsVersion());
 135         }
 136 
 137         AccessController.doPrivileged(
 138             new PrivilegedAction <Void> ()
 139         {
 140             @Override
 141             public Void run() {


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


  94     // cache of font peers
  95     private Hashtable<String,FontPeer> cacheFontPeer;
  96 
  97     // Windows properties
  98     private WDesktopProperties  wprops;
  99 
 100     // Dynamic Layout Resize client code setting
 101     protected boolean dynamicLayoutSetting = false;
 102 
 103     //Is it allowed to generate events assigned to extra mouse buttons.
 104     //Set to true by default.
 105     private static boolean areExtraMouseButtonsEnabled = true;
 106 
 107     /**
 108      * Initialize JNI field and method IDs
 109      */
 110     private static native void initIDs();
 111     private static boolean loaded = false;
 112     public static void loadLibraries() {
 113         if (!loaded) {
 114             jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt");







 115             loaded = true;
 116         }
 117     }
 118 
 119     private static native String getWindowsVersion();
 120 
 121     static {
 122         loadLibraries();
 123         initIDs();
 124 
 125         // Print out which version of Windows is running
 126         if (log.isLoggable(PlatformLogger.Level.FINE)) {
 127             log.fine("Win version: " + getWindowsVersion());
 128         }
 129 
 130         AccessController.doPrivileged(
 131             new PrivilegedAction <Void> ()
 132         {
 133             @Override
 134             public Void run() {


< prev index next >