Code review request: 7088502 Security libraries don't build with javac -Werror

Kurchi Hazra kurchi.subhra.hazra at oracle.com
Tue Sep 20 21:34:20 UTC 2011



On 9/19/2011 12:23 PM, Sean Mullan wrote:
> On 09/16/2011 06:34 PM, Kurchi Hazra wrote:
>> Hi Sean,
>>
>> Can you please review these changes?
>>
>> Summary: * Small changes to Java files in
>> src/share/classes/com/sun/org/apache/xml/internal/security and its
>> subpackages to remove build warnings.
>> * Small changes to relevant makefiles to prevent reintroduction of
>> removed warnings.
>>
>> webrev: http://cr.openjdk.java.net/~sherman/kurchi/7088502/webrev/
>> Bug description: 
>> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7088502
>
>
> * MessageDigestAlgorithm.java
>
> [74-5] This is preferable:
>
> static ThreadLocal<Map<String, MessageDigest>> instances=new
>     ThreadLocal<HashMap<String, MessageDigest>>() {
>     protected Map<String, MessageDigest> initialize()...
The above does not work since the compiler complains that if ThreadLocal 
is a HashMap, initialize() cannot override unless its return type is 
also HashMap. Even if I change it to
static ThreadLocal<Map<String, MessageDigest>> instances=new
     ThreadLocal<HashMap<String, MessageDigest>>() {
     protected HashMap<String, MessageDigest> initialize()...

the compiler throws an error as follows:

../../../../../../src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java:74: 
error: incompatible types
    static ThreadLocal<Map<String, MessageDigest>> instances=new
                                                             ^
   required: ThreadLocal<Map<String,MessageDigest>>
   found: <anonymous ThreadLocal<HashMap<String,MessageDigest>>>



>
>
> * Canonicalizer20010315.java
>
> [209,314] I'm curious about these changes. Instead of adding a new 
> method getSortedSetAsCollection and then suppressing the warnings for 
> that, it seems like it would be sufficient to just suppress the 
> warnings in this code, ex:
>
> @SuppressWarnings("unchecked")
> ...
>
>  ns.getUnrenderedNodes(result);


I did not put it inside the code, since the method has many lines of 
code and this would mean suppressing unchecked warnings generated 
anywhere in the method.



>
>
> * SignatureAlgorithm.java
>
> [130, 399, 434] change type to Class<? extends SignatureAlgorithmSpi>
If I make this change (and similar changes in other classes), I need to 
cast at various places, and then I need to Suppress the unchecked 
warnings. Is this preferable?
../../../../../../src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java:412: 
warning: [unchecked] unchecked cast
                          
SignatureAlgorithm._algorithmHash.put(algorithmURI, (Class <? extends 
SignatureAlgorithmSpi>)Class.forName(implementingClass));
                                                                                                                                    ^
   required: Class<? extends SignatureAlgorithmSpi>
   found:    Class<CAP#1>
   where CAP#1 is a fresh type-variable:
     CAP#1 extends Object from capture of ?


Is there a workaround?

-Kurchi




More information about the security-dev mailing list