changeset 14247:a7bb22e03a2d

8077360: Lower the number of providers created when using ServiceLoader Summary: Change ProviderLoader to be singleton and keep providers in java.base internal Reviewed-by: mullan
author valeriep
date Tue, 19 Apr 2016 22:24:51 +0000
parents 0be735572230
children feef55acfb91
files src/java.base/share/classes/module-info.java src/java.base/share/classes/sun/security/jca/ProviderConfig.java src/java.security.jgss/share/classes/sun/security/jgss/SunProvider.java
diffstat 3 files changed, 7 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/module-info.java	Tue Apr 19 11:42:29 2016 -0700
+++ b/src/java.base/share/classes/module-info.java	Tue Apr 19 22:24:51 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -300,9 +300,5 @@
 
     provides java.nio.file.spi.FileSystemProvider with
         jdk.internal.jrtfs.JrtFileSystemProvider;
-    provides java.security.Provider with sun.security.provider.Sun;
-    provides java.security.Provider with sun.security.rsa.SunRsaSign;
-    provides java.security.Provider with com.sun.crypto.provider.SunJCE;
-    provides java.security.Provider with com.sun.net.ssl.internal.ssl.Provider;
 }
 
--- a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java	Tue Apr 19 11:42:29 2016 -0700
+++ b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java	Tue Apr 19 22:24:51 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -236,9 +236,8 @@
                 if (debug != null) {
                     debug.println("Loading provider " + ProviderConfig.this);
                 }
-                ProviderLoader pl = new ProviderLoader();
                 try {
-                    Provider p = pl.load(provName);
+                    Provider p = ProviderLoader.INSTANCE.load(provName);
                     if (p != null) {
                         if (hasArgument()) {
                             p = p.configure(argument);
@@ -303,9 +302,11 @@
 
     // Inner class for loading security providers listed in java.security file
     private static final class ProviderLoader {
+        static final ProviderLoader INSTANCE = new ProviderLoader();
+
         private final ServiceLoader<Provider> services;
 
-        ProviderLoader() {
+        private ProviderLoader() {
             // VM should already been booted at this point, if not
             // - Only providers in java.base should be loaded, don't use
             //   ServiceLoader
--- a/src/java.security.jgss/share/classes/sun/security/jgss/SunProvider.java	Tue Apr 19 11:42:29 2016 -0700
+++ b/src/java.security.jgss/share/classes/sun/security/jgss/SunProvider.java	Tue Apr 19 22:24:51 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -97,8 +97,6 @@
         }
     }
 
-    public static final SunProvider INSTANCE = new SunProvider();
-
     public SunProvider() {
         /* We are the Sun JGSS provider */
         super("SunJGSS", 9.0d, INFO);