8157489: AppleProvider in java.base/macosx/classes/module-info.java.extra
Summary: Remove the line for ServiceLoader lookup
Reviewed-by: mchung
--- a/jdk/src/java.base/macosx/classes/module-info.java.extra Mon Jun 13 21:49:12 2016 +0000
+++ b/jdk/src/java.base/macosx/classes/module-info.java.extra Mon Jun 13 21:49:37 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -24,4 +24,3 @@
*/
exports jdk.internal.loader to java.desktop;
-provides java.security.Provider with apple.security.AppleProvider;
--- a/jdk/test/java/security/Provider/DefaultProviderList.java Mon Jun 13 21:49:12 2016 +0000
+++ b/jdk/test/java/security/Provider/DefaultProviderList.java Mon Jun 13 21:49:37 2016 +0000
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 7191662 8157469
+ * @bug 7191662 8157469 8157489
* @summary Ensure non-java.base providers can be found by ServiceLoader
* @author Valerie Peng
*/
@@ -33,6 +33,7 @@
import java.util.Arrays;
import java.util.Iterator;
import java.util.ServiceLoader;
+import java.lang.reflect.Module;
public class DefaultProviderList {
@@ -43,37 +44,54 @@
ServiceLoader<Provider> sl = ServiceLoader.load(Provider.class);
boolean failed = false;
+
+ Module baseMod = Object.class.getModule();
+
+ // Test#1: check that all non-base security providers can be found
+ // through ServiceLoader
for (Provider p : defaultProvs) {
String pName = p.getName();
- // only providers outside java.base are loaded by ServiceLoader
- if (pName.equals("SUN") || pName.equals("SunRsaSign") ||
- pName.equals("SunJCE") || pName.equals("SunJSSE") ||
- pName.equals("Apple")) {
- System.out.println("Skip test for provider " + pName);
- continue;
- }
- String pClassName = p.getClass().getName();
- // Should be able to find each one through ServiceLoader
- Iterator<Provider> provIter = sl.iterator();
- boolean found = false;
- while (provIter.hasNext()) {
- Provider pFromSL = provIter.next();
- if (pFromSL.getClass().getName().equals(pClassName)) {
- found = true;
- break;
+ Class pClass = p.getClass();
+
+ if (pClass.getModule() != baseMod) {
+ String pClassName = pClass.getName();
+ Iterator<Provider> provIter = sl.iterator();
+ boolean found = false;
+ while (provIter.hasNext()) {
+ Provider pFromSL = provIter.next();
+
+ // check for match by class name because PKCS11 provider
+ // will have a different name after being configured.
+ if (pFromSL.getClass().getName().equals(pClassName)) {
+ found = true;
+ System.out.println("SL found provider " + pName);
+ break;
+ }
+ }
+ if (!found) {
+ failed = true;
+ System.out.println("Error: SL cannot find provider " +
+ pName);
}
}
- System.out.println("Found " + p.getName() + " = " + found);
- if (!found) {
+ }
+
+ // Test#2: check that all security providers found through ServiceLoader
+ // are not from base module
+ Iterator<Provider> provIter = sl.iterator();
+ while (provIter.hasNext()) {
+ Provider pFromSL = provIter.next();
+ if (pFromSL.getClass().getModule() == baseMod) {
failed = true;
- System.out.println("Error: no provider class " + pClassName +
- " found");
+ System.out.println("Error: base provider " +
+ pFromSL.getName() + " loaded by SL");
}
}
+
if (!failed) {
System.out.println("Test Passed");
} else {
- throw new Exception("One or more provider not loaded by SL");
+ throw new Exception("One or more tests failed");
}
}
}