Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8233016

Specify the exceptions that can be thrown by the javax.crypto.Cipher constructor

    Details

      Description

      When using a protected constructor
      javax.crypto.Cipher​(CipherSpi, Provider, String)
      and running a standalone sample implementation an NPE could be thrown which is not specified anyhow.

      Exception in thread "main" java.lang.NullPointerException
      at java.base/javax.crypto.Cipher.<init>(Cipher.java:279)
      at TestCipherSpi$MyCipher.<init>(TestCipherSpi.java:23)
      at TestCipherSpi.main(TestCipherSpi.java:28)

      ===================
      ....
          static class MyCipher extends Cipher {
              protected MyCipher(javax.crypto.CipherSpi cipherSpi, Provider provider, String transformation) {
                  super(cipherSpi, provider, transformation);
              }
          }
          
          public static void main(String[] args) throws Exception {
              Cipher cipher = new MyCipher(mockedCipherSpi, new Provider("a", "b", "c") {
                  @Override
                  public Provider configure(String configArg) {
                      return super.configure(configArg);
                  }
              }, "abc");
          }
          
          static CipherSpi mockedCipherSpi = new CipherSpi() {
         ...
      ===================


      Please see the attached full code sample to reproduce the problem.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                valeriep Valerie Peng
                Reporter:
                dbessono Dmitry Bessonov
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: