JDK-8191038 : Add type parameter to a few java.xml APIs that used raw types
  • Type: CSR
  • Component: xml
  • Sub-Component: jaxp
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 10
  • Submitted: 2017-11-09
  • Updated: 2018-04-05
  • Resolved: 2017-11-13
Related Reports
CSR :  
Relates :  
Description
Summary
-------

A few java.xml APIs contained raw types. This change adds the type parameter to
eliminate raw types.

Problem
-------

The following java.xml APIs contain method declarations with raw types:

javax/xml/namespace/NamespaceContext.java

    Iterator getPrefixes(String namespaceURI);

javax/xml/xpath/XPathFunction.java

    public Object evaluate(List args)

org/xml/sax/helpers/NamespaceSupport.java

    public Enumeration getPrefixes ()
    public Enumeration getPrefixes (String uri)
    public Enumeration getDeclaredPrefixes ()

Solution
--------

Add the type parameter to eliminate the raw types.

Specification
-------------

    src/java.xml/share/classes/javax/xml/namespace/NamespaceContext.java
    - Iterator getPrefixes(String namespaceURI);
    + Iterator<String> getPrefixes(String namespaceURI);

    src/java.xml/share/classes/javax/xml/xpath/XPathFunction.java
    - public Object evaluate(List args)
    + public Object evaluate(List<Object> args)

    src/java.xml/share/classes/org/xml/sax/helpers/NamespaceSupport.java
    - public Enumeration getPrefixes ()
    + public Enumeration<String> getPrefixes ()

    - public Enumeration getPrefixes (String uri)
    + public Enumeration<String> getPrefixes (String uri)

    - public Enumeration getDeclaredPrefixes ()
    + public Enumeration<String> getDeclaredPrefixes ()



Comments
For XPathFunction.evaluate, I suspect it is better to declare this method as List<?> rather than List<Object>. The declaration List<Object> from a type system perspective allows the list to be modified within the caller, which doesn't seem to be needed. List<Object> also means that one cannot pass, say, a List<String> as the args since List<String> is *not* a subtype of List<Object>. List<String> is a subtype of List<?> though. Changing the compatibility impact to low rather than minimum. With the note that a CSR should be filed before such a signature change, I'm voting to approve the request on the condition that the List<Object> vs List<?> issue is investigated. I've filed JDK-8191161 and assigned it to Joe Wang.
13-11-2017

This is a retroactive CSR, the changes are already in jdk/jdk.
09-11-2017