# HG changeset patch # User valeriep # Date 1302908172 25200 # Node ID 499a73f2934741faf7bd97ec0aa82c97a2f83327 # Parent f66626469aa8c01b61a84de4d41a675d678ddf86 7035115: sun/security/pkcs11/Provider/ConfigShortPath.java compilation failed Summary: Updated the test to use reflection and skip when SunPKCS11 provider not present. Reviewed-by: weijun diff -r f66626469aa8 -r 499a73f29347 jdk/test/sun/security/pkcs11/Provider/ConfigShortPath.java --- a/jdk/test/sun/security/pkcs11/Provider/ConfigShortPath.java Thu Apr 14 21:27:10 2011 -0700 +++ b/jdk/test/sun/security/pkcs11/Provider/ConfigShortPath.java Fri Apr 15 15:56:12 2011 -0700 @@ -29,23 +29,36 @@ import java.security.*; import java.io.*; +import java.lang.reflect.*; public class ConfigShortPath { private static final String[] configNames = { "csp.cfg", "cspPlus.cfg" }; - public static void main(String[] args) { + public static void main(String[] args) throws Exception { + Constructor cons = null; + try { + Class clazz = Class.forName("sun.security.pkcs11.SunPKCS11"); + cons = clazz.getConstructor(String.class); + } catch (Exception ex) { + System.out.println("Skipping test - no PKCS11 provider available"); + return; + } String testSrc = System.getProperty("test.src", "."); for (int i = 0; i < configNames.length; i++) { String configFile = testSrc + File.separator + configNames[i]; + System.out.println("Testing against " + configFile); try { - Provider p = new sun.security.pkcs11.SunPKCS11(configFile); - } catch (ProviderException pe) { - String cause = pe.getCause().getMessage(); - if (cause.indexOf("Unexpected token") != -1) { - // re-throw to indicate test failure - throw pe; + Object obj = cons.newInstance(configFile); + } catch (InvocationTargetException ite) { + Throwable cause = ite.getCause(); + if (cause instanceof ProviderException) { + String causeMsg = cause.getCause().getMessage(); + // Indicate failure if due to parsing config + if (causeMsg.indexOf("Unexpected token") != -1) { + throw (ProviderException) cause; + } } } }