Index: trunk/modules/crypto/src/main/java/javax/crypto/Cipher.java =================================================================== --- trunk/modules/crypto/src/main/java/javax/crypto/Cipher.java (revision 431486) +++ trunk/modules/crypto/src/main/java/javax/crypto/Cipher.java (working copy) @@ -125,7 +125,10 @@ */ protected Cipher(CipherSpi cipherSpi, Provider provider, String transformation) { - this.provider = provider; + if (cipherSpi == null || provider == null) { + throw new NullPointerException(); + } + this.provider = provider; this.transformation = transformation; this.spiImpl = cipherSpi; } Index: trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java =================================================================== --- trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java (revision 431486) +++ trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java (working copy) @@ -29,6 +29,7 @@ import java.util.Arrays; import javax.crypto.Cipher; +import javax.crypto.CipherSpi; import javax.crypto.KeyGenerator; import javax.crypto.SecretKeyFactory; import javax.crypto.ShortBufferException; @@ -36,6 +37,7 @@ import javax.crypto.spec.IvParameterSpec; import tests.support.resource.Support_Resources; +import org.apache.harmony.crypto.tests.support.MyCipher; public class CipherTest extends junit.framework.TestCase { @@ -433,5 +435,39 @@ } catch (NoSuchAlgorithmException e) { } } - + /** + * @tests javax.crypto.Cipher#Cipher(CipherSpi cipherSpi, Provider provider, String transformation) + */ + public void test_Ctor() throws Exception { + // regression test for Harmony-1184 + try { + new testCipher(null, null, "s"); + fail("NullPointerException expected"); + } catch (NullPointerException e) { + //expected + } + try { + new testCipher(new MyCipher(), null, "s"); + fail("NullPointerException expected for 'null' provider"); + } catch (NullPointerException e) { + //expected + } + try { + new testCipher(null, new testProvider(), "s"); + fail("NullPointerException expected for 'null' cipherSpi"); + } catch (NullPointerException e) { + //expected + } + } + class testCipher extends Cipher { + testCipher(CipherSpi c, Provider p, String s){ + super(c, p, s); + } + } + class testProvider extends Provider { + testProvider(){ + super("qwerty", 1.0, "qwerty"); + } + } + }