changeset 4850:9bb7c3b97384

7118546: fix warnings in javax.xml.crypto, javax.script Reviewed-by: mullan
author smarks
date Thu, 08 Dec 2011 14:57:13 -0800
parents f8897baf40ea
children 77d41c0e4ffc
files src/share/classes/javax/script/ScriptException.java src/share/classes/javax/xml/crypto/NodeSetData.java src/share/classes/javax/xml/crypto/dom/DOMCryptoContext.java src/share/classes/javax/xml/crypto/dsig/Manifest.java src/share/classes/javax/xml/crypto/dsig/Reference.java src/share/classes/javax/xml/crypto/dsig/SignatureProperties.java src/share/classes/javax/xml/crypto/dsig/SignatureProperty.java src/share/classes/javax/xml/crypto/dsig/SignedInfo.java src/share/classes/javax/xml/crypto/dsig/TransformService.java src/share/classes/javax/xml/crypto/dsig/XMLObject.java src/share/classes/javax/xml/crypto/dsig/XMLSignature.java src/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfo.java src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java src/share/classes/javax/xml/crypto/dsig/keyinfo/PGPData.java src/share/classes/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java src/share/classes/javax/xml/crypto/dsig/keyinfo/X509Data.java src/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java src/share/classes/javax/xml/crypto/dsig/spec/XPathFilter2ParameterSpec.java src/share/classes/javax/xml/crypto/dsig/spec/XPathFilterParameterSpec.java src/share/classes/javax/xml/crypto/dsig/spec/XPathType.java
diffstat 21 files changed, 92 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/javax/script/ScriptException.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/script/ScriptException.java	Thu Dec 08 14:57:13 2011 -0800
@@ -36,6 +36,8 @@
  */
 public class ScriptException extends Exception {
 
+    private static final long serialVersionUID = 8265071037049225001L;
+
     private String fileName;
     private int lineNumber;
     private int columnNumber;
--- a/src/share/classes/javax/xml/crypto/NodeSetData.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/NodeSetData.java	Thu Dec 08 14:57:13 2011 -0800
@@ -52,5 +52,6 @@
      * @return an <code>Iterator</code> over the nodes in this
      *    <code>NodeSetData</code> in document order
      */
+    @SuppressWarnings("rawtypes")
     Iterator iterator();
 }
--- a/src/share/classes/javax/xml/crypto/dom/DOMCryptoContext.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dom/DOMCryptoContext.java	Thu Dec 08 14:57:13 2011 -0800
@@ -47,13 +47,13 @@
  */
 public class DOMCryptoContext implements XMLCryptoContext {
 
-    private HashMap nsMap = new HashMap();
-    private HashMap idMap = new HashMap();
-    private HashMap objMap = new HashMap();
+    private HashMap<String,String> nsMap = new HashMap<>();
+    private HashMap<String,Element> idMap = new HashMap<>();
+    private HashMap<Object,Object> objMap = new HashMap<>();
     private String baseURI;
     private KeySelector ks;
     private URIDereferencer dereferencer;
-    private HashMap propMap = new HashMap();
+    private HashMap<String,Object> propMap = new HashMap<>();
     private String defaultPrefix;
 
     /**
@@ -73,7 +73,7 @@
         if (namespaceURI == null) {
             throw new NullPointerException("namespaceURI cannot be null");
         }
-        String prefix = (String) nsMap.get(namespaceURI);
+        String prefix = nsMap.get(namespaceURI);
         return (prefix != null ? prefix : defaultPrefix);
     }
 
@@ -87,7 +87,7 @@
         if (namespaceURI == null) {
             throw new NullPointerException("namespaceURI is null");
         }
-        return (String) nsMap.put(namespaceURI, prefix);
+        return nsMap.put(namespaceURI, prefix);
     }
 
     public String getDefaultNamespacePrefix() {
@@ -170,7 +170,7 @@
         if (idValue == null) {
             throw new NullPointerException("idValue is null");
         }
-        return (Element) idMap.get(idValue);
+        return idMap.get(idValue);
     }
 
     /**
@@ -219,6 +219,7 @@
      *
      * @return a read-only iterator over the set of mappings
      */
+    @SuppressWarnings("rawtypes")
     public Iterator iterator() {
         return Collections.unmodifiableMap(idMap).entrySet().iterator();
     }
--- a/src/share/classes/javax/xml/crypto/dsig/Manifest.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/Manifest.java	Thu Dec 08 14:57:13 2011 -0800
@@ -86,5 +86,6 @@
      *
      * @return an unmodifiable list of one or more <code>Reference</code>s
      */
+    @SuppressWarnings("rawtypes")
     List getReferences();
 }
--- a/src/share/classes/javax/xml/crypto/dsig/Reference.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/Reference.java	Thu Dec 08 14:57:13 2011 -0800
@@ -85,6 +85,7 @@
      * @return an unmodifiable list of <code>Transform</code>s
      *    (may be empty but never <code>null</code>)
      */
+    @SuppressWarnings("rawtypes")
     List getTransforms();
 
     /**
--- a/src/share/classes/javax/xml/crypto/dsig/SignatureProperties.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/SignatureProperties.java	Thu Dec 08 14:57:13 2011 -0800
@@ -87,5 +87,6 @@
      * @return an unmodifiable list of one or more
      *    <code>SignatureProperty</code>s
      */
+    @SuppressWarnings("rawtypes")
     List getProperties();
 }
--- a/src/share/classes/javax/xml/crypto/dsig/SignatureProperty.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/SignatureProperty.java	Thu Dec 08 14:57:13 2011 -0800
@@ -91,5 +91,6 @@
      *
      * @return an unmodifiable list of one or more <code>XMLStructure</code>s
      */
+    @SuppressWarnings("rawtypes")
     List getContent();
 }
--- a/src/share/classes/javax/xml/crypto/dsig/SignedInfo.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/SignedInfo.java	Thu Dec 08 14:57:13 2011 -0800
@@ -80,6 +80,7 @@
      *
      * @return an unmodifiable list of one or more {@link Reference}s
      */
+    @SuppressWarnings("rawtypes")
     List getReferences();
 
     /**
--- a/src/share/classes/javax/xml/crypto/dsig/TransformService.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/TransformService.java	Thu Dec 08 14:57:13 2011 -0800
@@ -157,9 +157,9 @@
         if (mechanismType.equals("DOM")) {
             dom = true;
         }
-        List services = GetInstance.getServices("TransformService", algorithm);
-        for (Iterator t = services.iterator(); t.hasNext(); ) {
-            Service s = (Service)t.next();
+        List<Service> services = GetInstance.getServices("TransformService", algorithm);
+        for (Iterator<Service> t = services.iterator(); t.hasNext(); ) {
+            Service s = t.next();
             String value = s.getAttribute("MechanismType");
             if ((value == null && dom) ||
                 (value != null && value.equals(mechanismType))) {
@@ -277,7 +277,7 @@
                  + " mechanism not available");
     }
 
-    private static class MechanismMapEntry implements Map.Entry {
+    private static class MechanismMapEntry implements Map.Entry<String,String> {
         private final String mechanism;
         private final String algorithm;
         private final String key;
@@ -290,19 +290,19 @@
             if (!(o instanceof Map.Entry)) {
                 return false;
             }
-            Map.Entry e = (Map.Entry) o;
+            Map.Entry<?,?> e = (Map.Entry<?,?>) o;
             return (getKey()==null ?
                     e.getKey()==null : getKey().equals(e.getKey())) &&
                    (getValue()==null ?
                     e.getValue()==null : getValue().equals(e.getValue()));
         }
-        public Object getKey() {
+        public String getKey() {
             return key;
         }
-        public Object getValue() {
+        public String getValue() {
             return mechanism;
         }
-        public Object setValue(Object value) {
+        public String setValue(String value) {
             throw new UnsupportedOperationException();
         }
         public int hashCode() {
--- a/src/share/classes/javax/xml/crypto/dsig/XMLObject.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/XMLObject.java	Thu Dec 08 14:57:13 2011 -0800
@@ -100,6 +100,7 @@
      * @return an unmodifiable list of <code>XMLStructure</code>s (may be empty
      *    but never <code>null</code>)
      */
+    @SuppressWarnings("rawtypes")
     List getContent();
 
     /**
--- a/src/share/classes/javax/xml/crypto/dsig/XMLSignature.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/XMLSignature.java	Thu Dec 08 14:57:13 2011 -0800
@@ -136,6 +136,7 @@
      * @return an unmodifiable list of <code>XMLObject</code>s (may be empty
      *    but never <code>null</code>)
      */
+    @SuppressWarnings("rawtypes")
     List getObjects();
 
     /**
--- a/src/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java	Thu Dec 08 14:57:13 2011 -0800
@@ -365,6 +365,7 @@
      * @throws ClassCastException if any of the <code>objects</code> are not of
      *    type <code>XMLObject</code>
      */
+    @SuppressWarnings("rawtypes")
     public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki,
         List objects, String id, String signatureValueId);
 
@@ -398,6 +399,7 @@
      *    compliant
      * @throws NullPointerException if <code>dm</code> is <code>null</code>
      */
+    @SuppressWarnings("rawtypes")
     public abstract Reference newReference(String uri, DigestMethod dm,
         List transforms, String type, String id);
 
@@ -428,6 +430,7 @@
      * @throws NullPointerException if <code>dm</code> or
      *    <code>digestValue</code> is <code>null</code>
      */
+    @SuppressWarnings("rawtypes")
     public abstract Reference newReference(String uri, DigestMethod dm,
         List transforms, String type, String id, byte[] digestValue);
 
@@ -470,6 +473,7 @@
      *    <code>appliedTransforms</code> or <code>result</code> is
      *    <code>null</code>
      */
+    @SuppressWarnings("rawtypes")
     public abstract Reference newReference(String uri, DigestMethod dm,
         List appliedTransforms, Data result, List transforms, String type,
         String id);
@@ -489,6 +493,7 @@
      * @throws NullPointerException if any of the parameters
      *    are <code>null</code>
      */
+    @SuppressWarnings("rawtypes")
     public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
         SignatureMethod sm, List references);
 
@@ -507,6 +512,7 @@
      * @throws NullPointerException if <code>cm</code>, <code>sm</code>, or
      *    <code>references</code> are <code>null</code>
      */
+    @SuppressWarnings("rawtypes")
     public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
         SignatureMethod sm, List references, String id);
 
@@ -524,6 +530,7 @@
      * @throws ClassCastException if <code>content</code> contains any
      *    entries that are not of type {@link XMLStructure}
      */
+    @SuppressWarnings("rawtypes")
     public abstract XMLObject newXMLObject(List content, String id,
         String mimeType, String encoding);
 
@@ -540,6 +547,7 @@
      * @throws ClassCastException if <code>references</code> contains any
      *    entries that are not of type {@link Reference}
      */
+    @SuppressWarnings("rawtypes")
     public abstract Manifest newManifest(List references);
 
     /**
@@ -556,6 +564,7 @@
      * @throws ClassCastException if <code>references</code> contains any
      *    entries that are not of type {@link Reference}
      */
+    @SuppressWarnings("rawtypes")
     public abstract Manifest newManifest(List references, String id);
 
     /**
@@ -574,6 +583,7 @@
      * @throws ClassCastException if <code>content</code> contains any
      *    entries that are not of type {@link XMLStructure}
      */
+    @SuppressWarnings("rawtypes")
     public abstract SignatureProperty newSignatureProperty
         (List content, String target, String id);
 
@@ -592,6 +602,7 @@
      * @throws ClassCastException if <code>properties</code> contains any
      *    entries that are not of type {@link SignatureProperty}
      */
+    @SuppressWarnings("rawtypes")
     public abstract SignatureProperties newSignatureProperties
         (List properties, String id);
 
--- a/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfo.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfo.java	Thu Dec 08 14:57:13 2011 -0800
@@ -94,6 +94,7 @@
      *    in this <code>KeyInfo</code>. Never returns <code>null</code> or an
      *    empty list.
      */
+    @SuppressWarnings("rawtypes")
     List getContent();
 
     /**
--- a/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java	Thu Dec 08 14:57:13 2011 -0800
@@ -305,6 +305,7 @@
      * @throws ClassCastException if <code>content</code> contains any entries
      *    that are not of type {@link XMLStructure}
      */
+    @SuppressWarnings("rawtypes")
     public abstract KeyInfo newKeyInfo(List content);
 
     /**
@@ -324,6 +325,7 @@
      * @throws ClassCastException if <code>content</code> contains any entries
      *    that are not of type {@link XMLStructure}
      */
+    @SuppressWarnings("rawtypes")
     public abstract KeyInfo newKeyInfo(List content, String id);
 
     /**
@@ -385,6 +387,7 @@
      * @throws ClassCastException if <code>other</code> contains any
      *    entries that are not of type {@link XMLStructure}
      */
+    @SuppressWarnings("rawtypes")
     public abstract PGPData newPGPData(byte[] keyId, byte[] keyPacket,
         List other);
 
@@ -408,6 +411,7 @@
      * @throws ClassCastException if <code>other</code> contains any
      *    entries that are not of type {@link XMLStructure}
      */
+    @SuppressWarnings("rawtypes")
     public abstract PGPData newPGPData(byte[] keyPacket, List other);
 
     /**
@@ -439,6 +443,7 @@
      * @throws ClassCastException if <code>transforms</code> contains any
      *    entries that are not of type {@link Transform}
      */
+    @SuppressWarnings("rawtypes")
     public abstract RetrievalMethod newRetrievalMethod(String uri, String type,
         List transforms);
 
@@ -464,6 +469,7 @@
      * @throws ClassCastException if <code>content</code> contains any entries
      *    that are not of one of the valid types mentioned above
      */
+    @SuppressWarnings("rawtypes")
     public abstract X509Data newX509Data(List content);
 
     /**
--- a/src/share/classes/javax/xml/crypto/dsig/keyinfo/PGPData.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/keyinfo/PGPData.java	Thu Dec 08 14:57:13 2011 -0800
@@ -112,5 +112,6 @@
      * @return an unmodifiable list of <code>XMLStructure</code>s (may be
      *    empty, but never <code>null</code>)
      */
+    @SuppressWarnings("rawtypes")
     List getExternalElements();
 }
--- a/src/share/classes/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java	Thu Dec 08 14:57:13 2011 -0800
@@ -80,6 +80,7 @@
      * @return an unmodifiable list of <code>Transform</code> objects (may be
      *    empty but never <code>null</code>).
      */
+    @SuppressWarnings("rawtypes")
     List getTransforms();
 
     /**
--- a/src/share/classes/javax/xml/crypto/dsig/keyinfo/X509Data.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/keyinfo/X509Data.java	Thu Dec 08 14:57:13 2011 -0800
@@ -109,5 +109,6 @@
      * @return an unmodifiable list of the content in this <code>X509Data</code>
      *    (never <code>null</code> or empty)
      */
+    @SuppressWarnings("rawtypes")
     List getContent();
 }
--- a/src/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java	Thu Dec 08 14:57:13 2011 -0800
@@ -59,7 +59,7 @@
  */
 public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
 
-    private List preList;
+    private List<String> preList;
 
     /**
      * Indicates the default namespace ("#default").
@@ -71,7 +71,7 @@
      * list.
      */
     public ExcC14NParameterSpec() {
-        preList = Collections.EMPTY_LIST;
+        preList = Collections.emptyList();
     }
 
     /**
@@ -86,17 +86,22 @@
      * @throws ClassCastException if any of the entries in the list are not
      *    of type <code>String</code>
      */
+    @SuppressWarnings("rawtypes")
     public ExcC14NParameterSpec(List prefixList) {
         if (prefixList == null) {
             throw new NullPointerException("prefixList cannot be null");
         }
-        this.preList = new ArrayList(prefixList);
-        for (int i = 0, size = preList.size(); i < size; i++) {
-            if (!(preList.get(i) instanceof String)) {
+        List<?> copy = new ArrayList<>((List<?>)prefixList);
+        for (int i = 0, size = copy.size(); i < size; i++) {
+            if (!(copy.get(i) instanceof String)) {
                 throw new ClassCastException("not a String");
             }
         }
-        preList = Collections.unmodifiableList(preList);
+
+        @SuppressWarnings("unchecked")
+        List<String> temp = (List<String>)copy;
+
+        preList = Collections.unmodifiableList(temp);
     }
 
     /**
@@ -109,6 +114,7 @@
      * @return the inclusive namespace prefix list (may be empty but never
      *    <code>null</code>)
      */
+    @SuppressWarnings("rawtypes")
     public List getPrefixList() {
         return preList;
     }
--- a/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilter2ParameterSpec.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilter2ParameterSpec.java	Thu Dec 08 14:57:13 2011 -0800
@@ -46,7 +46,7 @@
  */
 public final class XPathFilter2ParameterSpec implements TransformParameterSpec {
 
-    private final List xPathList;
+    private final List<XPathType> xPathList;
 
     /**
      * Creates an <code>XPathFilter2ParameterSpec</code>.
@@ -59,11 +59,12 @@
      * @throws NullPointerException if <code>xPathList</code> is
      *    <code>null</code>
      */
+    @SuppressWarnings("rawtypes")
     public XPathFilter2ParameterSpec(List xPathList) {
         if (xPathList == null) {
             throw new NullPointerException("xPathList cannot be null");
         }
-        List xPathListCopy = new ArrayList(xPathList);
+        List<?> xPathListCopy = new ArrayList<>((List<?>)xPathList);
         if (xPathListCopy.isEmpty()) {
             throw new IllegalArgumentException("xPathList cannot be empty");
         }
@@ -74,7 +75,11 @@
                     ("xPathList["+i+"] is not a valid type");
             }
         }
-        this.xPathList = Collections.unmodifiableList(xPathListCopy);
+
+        @SuppressWarnings("unchecked")
+        List<XPathType> temp = (List<XPathType>)xPathListCopy;
+
+        this.xPathList = Collections.unmodifiableList(temp);
     }
 
     /**
@@ -86,6 +91,7 @@
      * @return a <code>List</code> of <code>XPathType</code> objects
      *    (never <code>null</code> or empty)
      */
+    @SuppressWarnings("rawtypes")
     public List getXPathList() {
         return xPathList;
     }
--- a/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilterParameterSpec.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilterParameterSpec.java	Thu Dec 08 14:57:13 2011 -0800
@@ -52,7 +52,7 @@
 public final class XPathFilterParameterSpec implements TransformParameterSpec {
 
     private String xPath;
-    private Map nsMap;
+    private Map<String,String> nsMap;
 
     /**
      * Creates an <code>XPathFilterParameterSpec</code> with the specified
@@ -66,7 +66,7 @@
             throw new NullPointerException();
         }
         this.xPath = xPath;
-        this.nsMap = Collections.EMPTY_MAP;
+        this.nsMap = Collections.emptyMap();
     }
 
     /**
@@ -83,21 +83,26 @@
      * @throws ClassCastException if any of the map's keys or entries are not
      *    of type <code>String</code>
      */
+    @SuppressWarnings("rawtypes")
     public XPathFilterParameterSpec(String xPath, Map namespaceMap) {
         if (xPath == null || namespaceMap == null) {
             throw new NullPointerException();
         }
         this.xPath = xPath;
-        nsMap = new HashMap(namespaceMap);
-        Iterator entries = nsMap.entrySet().iterator();
+        Map<?,?> copy = new HashMap<>((Map<?,?>)namespaceMap);
+        Iterator<? extends Map.Entry<?,?>> entries = copy.entrySet().iterator();
         while (entries.hasNext()) {
-            Map.Entry me = (Map.Entry) entries.next();
+            Map.Entry<?,?> me = entries.next();
             if (!(me.getKey() instanceof String) ||
                 !(me.getValue() instanceof String)) {
                 throw new ClassCastException("not a String");
             }
         }
-        nsMap = Collections.unmodifiableMap(nsMap);
+
+        @SuppressWarnings("unchecked")
+        Map<String,String> temp = (Map<String,String>)copy;
+
+        nsMap = Collections.unmodifiableMap(temp);
     }
 
     /**
@@ -120,6 +125,7 @@
      * @return a <code>Map</code> of namespace prefixes to namespace URIs (may
      *    be empty, but never <code>null</code>)
      */
+    @SuppressWarnings("rawtypes")
     public Map getNamespaceMap() {
         return nsMap;
     }
--- a/src/share/classes/javax/xml/crypto/dsig/spec/XPathType.java	Thu Dec 08 13:48:54 2011 -0500
+++ b/src/share/classes/javax/xml/crypto/dsig/spec/XPathType.java	Thu Dec 08 14:57:13 2011 -0800
@@ -106,7 +106,7 @@
 
     private final String expression;
     private final Filter filter;
-    private Map nsMap;
+    private Map<String,String> nsMap;
 
     /**
      * Creates an <code>XPathType</code> instance with the specified XPath
@@ -127,7 +127,7 @@
         }
         this.expression = expression;
         this.filter = filter;
-        this.nsMap = Collections.EMPTY_MAP;
+        this.nsMap = Collections.emptyMap();
     }
 
     /**
@@ -147,21 +147,26 @@
      * @throws ClassCastException if any of the map's keys or entries are
      *    not of type <code>String</code>
      */
+    @SuppressWarnings("rawtypes")
     public XPathType(String expression, Filter filter, Map namespaceMap) {
         this(expression, filter);
         if (namespaceMap == null) {
             throw new NullPointerException("namespaceMap cannot be null");
         }
-        nsMap = new HashMap(namespaceMap);
-        Iterator entries = nsMap.entrySet().iterator();
+        Map<?,?> copy = new HashMap<>((Map<?,?>)namespaceMap);
+        Iterator<? extends Map.Entry<?,?>> entries = copy.entrySet().iterator();
         while (entries.hasNext()) {
-            Map.Entry me = (Map.Entry) entries.next();
+            Map.Entry<?,?> me = entries.next();
             if (!(me.getKey() instanceof String) ||
                 !(me.getValue() instanceof String)) {
                 throw new ClassCastException("not a String");
             }
         }
-        nsMap = Collections.unmodifiableMap(nsMap);
+
+        @SuppressWarnings("unchecked")
+        Map<String,String> temp = (Map<String,String>)copy;
+
+        nsMap = Collections.unmodifiableMap(temp);
     }
 
     /**
@@ -193,6 +198,7 @@
      * @return a <code>Map</code> of namespace prefixes to namespace URIs
      *    (may be empty, but never <code>null</code>)
      */
+    @SuppressWarnings("rawtypes")
     public Map getNamespaceMap() {
         return nsMap;
     }