diff --git a/src/share/classes/java/security/cert/PKIXParameters.java b/src/share/classes/java/security/cert/PKIXParameters.java index 7608d9f7b3900366a37ec1f436a7a619cfe44888..f9f95ce7841dfb81745da5434f73859aca3b1e03 100644 --- a/src/share/classes/java/security/cert/PKIXParameters.java +++ b/src/share/classes/java/security/cert/PKIXParameters.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2000-2009 Sun Microsystems, Inc. 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 @@ -663,15 +663,23 @@ public class PKIXParameters implements CertPathParameters { */ public Object clone() { try { - Object copy = super.clone(); - // Must clone these because addCertStore, et al. modify them + PKIXParameters copy = (PKIXParameters)super.clone(); + + // must clone these because addCertStore, et al. modify them if (certStores != null) { - certStores = new ArrayList(certStores); + copy.certStores = new ArrayList(certStores); } if (certPathCheckers != null) { - certPathCheckers = - new ArrayList(certPathCheckers); + copy.certPathCheckers = + new ArrayList(certPathCheckers.size()); + for (PKIXCertPathChecker checker : certPathCheckers) { + copy.certPathCheckers.add( + (PKIXCertPathChecker)checker.clone()); + } } + + // other class fields are immutable to public, don't bother + // to clone the read-only fields. return copy; } catch (CloneNotSupportedException e) { /* Cannot happen */