8077360: Lower the number of providers created when using ServiceLoader

Change ProviderLoader to be singleton and keep providers in java.base internal

Reviewed-by: mullan
This commit is contained in:
Valerie Peng 2016-04-19 22:24:51 +00:00
parent d7b1616623
commit 16ee51bad7
3 changed files with 7 additions and 12 deletions

View File

@ -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 @@ module java.base {
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;
}

View File

@ -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 @@ final class ProviderConfig {
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 @@ final class ProviderConfig {
// 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

View File

@ -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 final class SunProvider extends Provider {
}
}
public static final SunProvider INSTANCE = new SunProvider();
public SunProvider() {
/* We are the Sun JGSS provider */
super("SunJGSS", 9.0d, INFO);