< prev index next >

src/java.base/share/classes/java/lang/ClassLoader.java

Print this page




 905             checkCerts(name, pd.getCodeSource());
 906         }
 907 
 908         return pd;
 909     }
 910 
 911     private String defineClassSourceLocation(ProtectionDomain pd) {
 912         CodeSource cs = pd.getCodeSource();
 913         String source = null;
 914         if (cs != null && cs.getLocation() != null) {
 915             source = cs.getLocation().toString();
 916         }
 917         return source;
 918     }
 919 
 920     private void postDefineClass(Class<?> c, ProtectionDomain pd) {
 921         // define a named package, if not present
 922         getNamedPackage(c.getPackageName(), c.getModule());
 923 
 924         if (pd.getCodeSource() != null) {
 925             Certificate certs[] = pd.getCodeSource().getCertificates();
 926             if (certs != null)
 927                 setSigners(c, certs);
 928         }
 929     }
 930 
 931     /**
 932      * Converts an array of bytes into an instance of class {@code Class},
 933      * with a given {@code ProtectionDomain}.
 934      *
 935      * <p> If the given {@code ProtectionDomain} is {@code null},
 936      * then a default protection domain will be assigned to the class as specified
 937      * in the documentation for {@link #defineClass(String, byte[], int, int)}.
 938      * Before the class can be used it must be resolved.
 939      *
 940      * <p> The first class defined in a package determines the exact set of
 941      * certificates that all subsequent classes defined in that package must
 942      * contain.  The set of certificates for a class is obtained from the
 943      * {@link java.security.CodeSource CodeSource} within the
 944      * {@code ProtectionDomain} of the class.  Any classes added to that
 945      * package must contain the same set of certificates or a


2533                 synchronized (loadedLibraryNames) {
2534                     /* remove the native library name */
2535                     loadedLibraryNames.remove(name);
2536                     nativeLibraryContext.push(UNLOADER);
2537                     try {
2538                         unload(name, isBuiltin, handle);
2539                     } finally {
2540                         nativeLibraryContext.pop();
2541                     }
2542 
2543                 }
2544             }
2545         }
2546 
2547         // JNI FindClass expects the caller class if invoked from JNI_OnLoad
2548         // and JNI_OnUnload is NativeLibrary class
2549         static native void unload(String name, boolean isBuiltin, long handle);
2550     }
2551 
2552     // The paths searched for libraries
2553     private static String usr_paths[];
2554     private static String sys_paths[];
2555 
2556     private static String[] initializePath(String propName) {
2557         String ldPath = System.getProperty(propName, "");
2558         int ldLen = ldPath.length();
2559         char ps = File.pathSeparatorChar;
2560         int psCount = 0;
2561 
2562         if (ClassLoaderHelper.allowsQuotedPathElements &&
2563             ldPath.indexOf('\"') >= 0) {
2564             // First, remove quotes put around quoted parts of paths.
2565             // Second, use a quotation mark as a new path separator.
2566             // This will preserve any quoted old path separators.
2567             char[] buf = new char[ldLen];
2568             int bufLen = 0;
2569             for (int i = 0; i < ldLen; ++i) {
2570                 char ch = ldPath.charAt(i);
2571                 if (ch == '\"') {
2572                     while (++i < ldLen &&
2573                         (ch = ldPath.charAt(i)) != '\"') {
2574                         buf[bufLen++] = ch;




 905             checkCerts(name, pd.getCodeSource());
 906         }
 907 
 908         return pd;
 909     }
 910 
 911     private String defineClassSourceLocation(ProtectionDomain pd) {
 912         CodeSource cs = pd.getCodeSource();
 913         String source = null;
 914         if (cs != null && cs.getLocation() != null) {
 915             source = cs.getLocation().toString();
 916         }
 917         return source;
 918     }
 919 
 920     private void postDefineClass(Class<?> c, ProtectionDomain pd) {
 921         // define a named package, if not present
 922         getNamedPackage(c.getPackageName(), c.getModule());
 923 
 924         if (pd.getCodeSource() != null) {
 925             Certificate[] certs = pd.getCodeSource().getCertificates();
 926             if (certs != null)
 927                 setSigners(c, certs);
 928         }
 929     }
 930 
 931     /**
 932      * Converts an array of bytes into an instance of class {@code Class},
 933      * with a given {@code ProtectionDomain}.
 934      *
 935      * <p> If the given {@code ProtectionDomain} is {@code null},
 936      * then a default protection domain will be assigned to the class as specified
 937      * in the documentation for {@link #defineClass(String, byte[], int, int)}.
 938      * Before the class can be used it must be resolved.
 939      *
 940      * <p> The first class defined in a package determines the exact set of
 941      * certificates that all subsequent classes defined in that package must
 942      * contain.  The set of certificates for a class is obtained from the
 943      * {@link java.security.CodeSource CodeSource} within the
 944      * {@code ProtectionDomain} of the class.  Any classes added to that
 945      * package must contain the same set of certificates or a


2533                 synchronized (loadedLibraryNames) {
2534                     /* remove the native library name */
2535                     loadedLibraryNames.remove(name);
2536                     nativeLibraryContext.push(UNLOADER);
2537                     try {
2538                         unload(name, isBuiltin, handle);
2539                     } finally {
2540                         nativeLibraryContext.pop();
2541                     }
2542 
2543                 }
2544             }
2545         }
2546 
2547         // JNI FindClass expects the caller class if invoked from JNI_OnLoad
2548         // and JNI_OnUnload is NativeLibrary class
2549         static native void unload(String name, boolean isBuiltin, long handle);
2550     }
2551 
2552     // The paths searched for libraries
2553     private static String[] usr_paths;
2554     private static String[] sys_paths;
2555 
2556     private static String[] initializePath(String propName) {
2557         String ldPath = System.getProperty(propName, "");
2558         int ldLen = ldPath.length();
2559         char ps = File.pathSeparatorChar;
2560         int psCount = 0;
2561 
2562         if (ClassLoaderHelper.allowsQuotedPathElements &&
2563             ldPath.indexOf('\"') >= 0) {
2564             // First, remove quotes put around quoted parts of paths.
2565             // Second, use a quotation mark as a new path separator.
2566             // This will preserve any quoted old path separators.
2567             char[] buf = new char[ldLen];
2568             int bufLen = 0;
2569             for (int i = 0; i < ldLen; ++i) {
2570                 char ch = ldPath.charAt(i);
2571                 if (ch == '\"') {
2572                     while (++i < ldLen &&
2573                         (ch = ldPath.charAt(i)) != '\"') {
2574                         buf[bufLen++] = ch;


< prev index next >