-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
5.0
-
generic, sparc
-
generic, solaris_2.6
getInstance methods of Mac class throw NullPointerException if algorithm parameter is null. This behavior is not specified either in the method or in the package/class description. Here is an example:
-------------------------------------------------------
import javax.crypto.Mac;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
public class A {
public static void main(String[] args) {
try {
Mac.getInstance(null);
} catch (NoSuchAlgorithmException e) {
System.out.println("NoSuchAlgorithmException was thrown");
} catch (NullPointerException e) {
System.out.println("NPE was thrown");
}
try {
Mac.getInstance(null, "SunJCE");
} catch (NoSuchAlgorithmException e) {
System.out.println("NoSuchAlgorithmException was thrown");
} catch (NullPointerException e) {
System.out.println("NPE was thrown");
} catch (NoSuchProviderException e) {
System.out.println("NoSuchProviderException was thrown");
}
try {
Mac.getInstance(null, new Provider("A", 0.1, "C") {});
} catch (NoSuchAlgorithmException e) {
System.out.println("NoSuchAlgorithmException was thrown");
} catch (NullPointerException e) {
System.out.println("NPE was thrown");
}
}
}
-----------------------------------------------
aag@gaff:~/work/bugs/doc> javac A.java;java A
NPE was thrown
NPE was thrown
NPE was thrown
-----------------------------------------------
###@###.### 2004-12-07 15:05:20 GMT
-------------------------------------------------------
import javax.crypto.Mac;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
public class A {
public static void main(String[] args) {
try {
Mac.getInstance(null);
} catch (NoSuchAlgorithmException e) {
System.out.println("NoSuchAlgorithmException was thrown");
} catch (NullPointerException e) {
System.out.println("NPE was thrown");
}
try {
Mac.getInstance(null, "SunJCE");
} catch (NoSuchAlgorithmException e) {
System.out.println("NoSuchAlgorithmException was thrown");
} catch (NullPointerException e) {
System.out.println("NPE was thrown");
} catch (NoSuchProviderException e) {
System.out.println("NoSuchProviderException was thrown");
}
try {
Mac.getInstance(null, new Provider("A", 0.1, "C") {});
} catch (NoSuchAlgorithmException e) {
System.out.println("NoSuchAlgorithmException was thrown");
} catch (NullPointerException e) {
System.out.println("NPE was thrown");
}
}
}
-----------------------------------------------
aag@gaff:~/work/bugs/doc> javac A.java;java A
NPE was thrown
NPE was thrown
NPE was thrown
-----------------------------------------------
###@###.### 2004-12-07 15:05:20 GMT
- duplicates
-
JDK-4955099 (spec) incomplete spec for javax.crypto.Mac.getInstance(String, Provider)
-
- Closed
-