< prev index next >

src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java

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


  40 
  41     private static final int UNINITALIZED_LS_INFO = -1;
  42 
  43     // Constants from LaunchServices.h
  44     static final int kLSItemInfoIsPlainFile        = 0x00000001; /* Not a directory, volume, or symlink*/
  45     static final int kLSItemInfoIsPackage          = 0x00000002; /* Packaged directory*/
  46     static final int kLSItemInfoIsApplication      = 0x00000004; /* Single-file or packaged application*/
  47     static final int kLSItemInfoIsContainer        = 0x00000008; /* Directory (includes packages) or volume*/
  48     static final int kLSItemInfoIsAliasFile        = 0x00000010; /* Alias file (includes sym links)*/
  49     static final int kLSItemInfoIsSymlink          = 0x00000020; /* UNIX sym link*/
  50     static final int kLSItemInfoIsInvisible        = 0x00000040; /* Invisible by any known mechanism*/
  51     static final int kLSItemInfoIsNativeApp        = 0x00000080; /* Carbon or Cocoa native app*/
  52     static final int kLSItemInfoIsClassicApp       = 0x00000100; /* CFM/68K Classic app*/
  53     static final int kLSItemInfoAppPrefersNative   = 0x00000200; /* Carbon app that prefers to be launched natively*/
  54     static final int kLSItemInfoAppPrefersClassic  = 0x00000400; /* Carbon app that prefers to be launched in Classic*/
  55     static final int kLSItemInfoAppIsScriptable    = 0x00000800; /* App can be scripted*/
  56     static final int kLSItemInfoIsVolume           = 0x00001000; /* Item is a volume*/
  57     static final int kLSItemInfoExtensionIsHidden  = 0x00100000; /* Item has a hidden extension*/
  58 
  59     static {
  60         java.security.AccessController.doPrivileged(
  61             new java.security.PrivilegedAction<Void>() {
  62                 public Void run() {
  63                     System.loadLibrary("osxui");
  64                     return null;
  65                 }
  66             });
  67     }
  68 
  69     // TODO: Un-comment this out when the native version exists
  70     //private static native String getNativePathToRunningJDKBundle();
  71     private static native String getNativePathToSharedJDKBundle();
  72 
  73     private static native String getNativeMachineName();
  74     private static native String getNativeDisplayName(final byte[] pathBytes, final boolean isDirectory);
  75     private static native int getNativeLSInfo(final byte[] pathBytes, final boolean isDirectory);
  76     private static native String getNativePathForResolvedAlias(final byte[] absolutePath, final boolean isDirectory);
  77 
  78     private static final RecyclableSingleton<String> machineName = new RecyclableSingleton<String>() {
  79         @Override
  80         protected String getInstance() {
  81             return getNativeMachineName();
  82         }
  83     };
  84     private static String getMachineName() {
  85         return machineName.get();
  86     }


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


  40 
  41     private static final int UNINITALIZED_LS_INFO = -1;
  42 
  43     // Constants from LaunchServices.h
  44     static final int kLSItemInfoIsPlainFile        = 0x00000001; /* Not a directory, volume, or symlink*/
  45     static final int kLSItemInfoIsPackage          = 0x00000002; /* Packaged directory*/
  46     static final int kLSItemInfoIsApplication      = 0x00000004; /* Single-file or packaged application*/
  47     static final int kLSItemInfoIsContainer        = 0x00000008; /* Directory (includes packages) or volume*/
  48     static final int kLSItemInfoIsAliasFile        = 0x00000010; /* Alias file (includes sym links)*/
  49     static final int kLSItemInfoIsSymlink          = 0x00000020; /* UNIX sym link*/
  50     static final int kLSItemInfoIsInvisible        = 0x00000040; /* Invisible by any known mechanism*/
  51     static final int kLSItemInfoIsNativeApp        = 0x00000080; /* Carbon or Cocoa native app*/
  52     static final int kLSItemInfoIsClassicApp       = 0x00000100; /* CFM/68K Classic app*/
  53     static final int kLSItemInfoAppPrefersNative   = 0x00000200; /* Carbon app that prefers to be launched natively*/
  54     static final int kLSItemInfoAppPrefersClassic  = 0x00000400; /* Carbon app that prefers to be launched in Classic*/
  55     static final int kLSItemInfoAppIsScriptable    = 0x00000800; /* App can be scripted*/
  56     static final int kLSItemInfoIsVolume           = 0x00001000; /* Item is a volume*/
  57     static final int kLSItemInfoExtensionIsHidden  = 0x00100000; /* Item has a hidden extension*/
  58 
  59     static {
  60         jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("osxui");






  61     }
  62 
  63     // TODO: Un-comment this out when the native version exists
  64     //private static native String getNativePathToRunningJDKBundle();
  65     private static native String getNativePathToSharedJDKBundle();
  66 
  67     private static native String getNativeMachineName();
  68     private static native String getNativeDisplayName(final byte[] pathBytes, final boolean isDirectory);
  69     private static native int getNativeLSInfo(final byte[] pathBytes, final boolean isDirectory);
  70     private static native String getNativePathForResolvedAlias(final byte[] absolutePath, final boolean isDirectory);
  71 
  72     private static final RecyclableSingleton<String> machineName = new RecyclableSingleton<String>() {
  73         @Override
  74         protected String getInstance() {
  75             return getNativeMachineName();
  76         }
  77     };
  78     private static String getMachineName() {
  79         return machineName.get();
  80     }


< prev index next >