jdk/src/share/classes/java/security/cert/PKIXParameters.java
changeset 4807 2521b7dcf505
parent 2 90ce3da70b43
child 5506 202f599c92aa
equal deleted inserted replaced
4682:2aebbe5c08a7 4807:2521b7dcf505
     1 /*
     1 /*
     2  * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
     2  * Copyright 2000-2009 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Sun designates this
     7  * published by the Free Software Foundation.  Sun designates this
   661      *
   661      *
   662      * @return a copy of this <code>PKIXParameters</code> object
   662      * @return a copy of this <code>PKIXParameters</code> object
   663      */
   663      */
   664     public Object clone() {
   664     public Object clone() {
   665         try {
   665         try {
   666             Object copy = super.clone();
   666             PKIXParameters copy = (PKIXParameters)super.clone();
   667             // Must clone these because addCertStore, et al. modify them
   667 
       
   668             // must clone these because addCertStore, et al. modify them
   668             if (certStores != null) {
   669             if (certStores != null) {
   669                 certStores = new ArrayList<CertStore>(certStores);
   670                 copy.certStores = new ArrayList<CertStore>(certStores);
   670             }
   671             }
   671             if (certPathCheckers != null) {
   672             if (certPathCheckers != null) {
   672                 certPathCheckers =
   673                 copy.certPathCheckers =
   673                         new ArrayList<PKIXCertPathChecker>(certPathCheckers);
   674                     new ArrayList<PKIXCertPathChecker>(certPathCheckers.size());
       
   675                 for (PKIXCertPathChecker checker : certPathCheckers) {
       
   676                     copy.certPathCheckers.add(
       
   677                                     (PKIXCertPathChecker)checker.clone());
       
   678                 }
   674             }
   679             }
       
   680 
       
   681             // other class fields are immutable to public, don't bother
       
   682             // to clone the read-only fields.
   675             return copy;
   683             return copy;
   676         } catch (CloneNotSupportedException e) {
   684         } catch (CloneNotSupportedException e) {
   677             /* Cannot happen */
   685             /* Cannot happen */
   678             throw new InternalError(e.toString());
   686             throw new InternalError(e.toString());
   679         }
   687         }