< prev index next >

src/java.desktop/share/classes/java/awt/Toolkit.java

Print this page
rev 55657 : 8227587: Add internal privileged System.loadLibrary
Reviewed-by: rriggs


1357      * "Toolkit"s/Peer), such as Motif, Microsoft Windows, or Tiny. The
1358      * problem is that this means that the native libraries must be
1359      * loaded by the java.* classes, which do not necessarily know the
1360      * names of the libraries to load. A better way of doing this
1361      * would be to provide a separate library which defines java.awt.*
1362      * initIDs, and exports the relevant symbols out to the
1363      * implementation libraries.
1364      *
1365      * For now, we know it's done by the implementation, and we assume
1366      * that the name of the library is "awt".  -br.
1367      *
1368      * If you change loadLibraries(), please add the change to
1369      * java.awt.image.ColorModel.loadLibraries(). Unfortunately,
1370      * classes can be loaded in java.awt.image that depend on
1371      * libawt and there is no way to call Toolkit.loadLibraries()
1372      * directly.  -hung
1373      */
1374     private static boolean loaded = false;
1375     static void loadLibraries() {
1376         if (!loaded) {
1377             java.security.AccessController.doPrivileged(
1378                 new java.security.PrivilegedAction<Void>() {
1379                     public Void run() {
1380                         System.loadLibrary("awt");
1381                         return null;
1382                     }
1383                 });
1384             loaded = true;
1385         }
1386     }
1387 
1388     static {
1389         AWTAccessor.setToolkitAccessor(
1390                 new AWTAccessor.ToolkitAccessor() {
1391                     @Override
1392                     public void setPlatformResources(ResourceBundle bundle) {
1393                         Toolkit.setPlatformResources(bundle);
1394                     }
1395                 });
1396 
1397         java.security.AccessController.doPrivileged(
1398                                  new java.security.PrivilegedAction<Void>() {
1399             public Void run() {
1400                 try {
1401                     resources = ResourceBundle.getBundle("sun.awt.resources.awt");
1402                 } catch (MissingResourceException e) {
1403                     // No resource file; defaults will be used.




1357      * "Toolkit"s/Peer), such as Motif, Microsoft Windows, or Tiny. The
1358      * problem is that this means that the native libraries must be
1359      * loaded by the java.* classes, which do not necessarily know the
1360      * names of the libraries to load. A better way of doing this
1361      * would be to provide a separate library which defines java.awt.*
1362      * initIDs, and exports the relevant symbols out to the
1363      * implementation libraries.
1364      *
1365      * For now, we know it's done by the implementation, and we assume
1366      * that the name of the library is "awt".  -br.
1367      *
1368      * If you change loadLibraries(), please add the change to
1369      * java.awt.image.ColorModel.loadLibraries(). Unfortunately,
1370      * classes can be loaded in java.awt.image that depend on
1371      * libawt and there is no way to call Toolkit.loadLibraries()
1372      * directly.  -hung
1373      */
1374     private static boolean loaded = false;
1375     static void loadLibraries() {
1376         if (!loaded) {
1377             jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt");






1378             loaded = true;
1379         }
1380     }
1381 
1382     static {
1383         AWTAccessor.setToolkitAccessor(
1384                 new AWTAccessor.ToolkitAccessor() {
1385                     @Override
1386                     public void setPlatformResources(ResourceBundle bundle) {
1387                         Toolkit.setPlatformResources(bundle);
1388                     }
1389                 });
1390 
1391         java.security.AccessController.doPrivileged(
1392                                  new java.security.PrivilegedAction<Void>() {
1393             public Void run() {
1394                 try {
1395                     resources = ResourceBundle.getBundle("sun.awt.resources.awt");
1396                 } catch (MissingResourceException e) {
1397                     // No resource file; defaults will be used.


< prev index next >