JDK-6492692 : Some JCK test failed because of the complier warnings changes
  • Type: Bug
  • Component: security-libs
  • Sub-Component: java.security
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-11-11
  • Updated: 2012-03-22
  • Resolved: 2011-03-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b05Fixed
Related Reports
Duplicate :  
Description
Cause known for the issue, will find a proper solution. And I will run a jck full test while back to office next Monday for more issues like this. I'm worried that the compiler warnings changes may cause some similar JCK issues, and if you encounter any other problems related to the warning changes, please let me know.

Thanks,
Andrew

Brad Wetmore wrote:
> Andrew,
>
> I believe one of your compiler warning changes has broken a JCK test case.
>
> One of the JCK tests does the following (reformatted slightly), which does not use generics:
>
>         List certs = new Vector();
>         certs.add("The first certificate");
>         certs.add("The third certificate");
>         certs.add("The second certificate");
>         certs.add("The fourth certificate");
>         try {
>             cp = cf.generateCertPath( certs);
>             ref.println(
>                 "CertificateException has not been thrown" +
>                 "on attempt to generate Certificate Path from" +
>                 "a List of strings");
>             return Status.failed(
>                 "public final CertPath generateCertPath(" +
>                 "List certificates) throws CertificateException " +
>                 "Test Failed ");
>         } catch(CertificateException ce) {
>             ref.println("Expected exception "+ce);
>         }
>
> I believe this test worked before your change, but I haven't actually verified it.
>
> api/java_security/cert/CertificateFactory/
>
> Anyway, the test is now failing as seen below.  The X509CertPath code (line 97) is expecting a <? extends Certificate>, but it's receiving a set of strings and is thus failing.  The app is getting a ClassCastException runtime exception instead of a CertificateException checked exception, and thus failing on all platforms.
>
> Please look into it ASAP.  Thanks.
>
> brad
>
>
>
> -------- Original Message --------
>
> This test is failing on all platforms that are running the jck:
>
> #Test Results (version 2)
> #Thu Nov 09 20:24:26 PST 2006
> #checksum:5317c27957e86351
> #-----testdescription-----
> $file=/u/martin/jck/JCK-runtime-6/tests/api/java_security/cert/CertificateFactory/index.html
> $root=/u/martin/jck/JCK-runtime-6/tests
> executeArgs=-TestURL $testURL
> executeClass=javasoft.sqe.tests.api.java.security.cert.CertificateFactory.generateTests
> id=generate
> keywords=positive runtime
> source=generateTests.java
> title=CertificateFactory generate() methods tests
>
> #-----environment-----
> command.testExecute=com.sun.jck.lib.ExecJCKTestOtherJVMCmd LD_LIBRARY_PATH=/u/martin/jck/lib-JCK-runtime-6 DISPLAY=:7 HOME=${user.home} HOME=/u/martin/jck/home /u/martin/ws/int/control/build/solaris-sparc/j2sdk-image/bin/java -Xmx256m ${jvmtiAgentOptions} -Xfuture $jdwpAgentOptions -classpath $testSuiteRootDir/classes $JPLISAgentOpts $JPLISAgent2Opts -Djava.security.policy=$testSuiteRootDir/lib/jck.policy $testExecuteClass $testExecuteArgs
> user.home=/u/martin
>
> #-----testresult-----
> description=file:///u/martin/jck/JCK-runtime-6/tests/api/java_security/cert/CertificateFactory/index.html#generate
> end=Thu Nov 09 20:24:26 PST 2006
> environment=autobuild_runtime
> execStatus=Failed. test cases: 13; passed: 12; failed: 1; first test case failure: CertificateFactory2019
> javatestOS=SunOS 5.9 (sparc)
> javatestVersion=3.2.2
> script=com.sun.jck.lib.JCKScript
> sections=script_messages testExecute
> start=Thu Nov 09 20:24:25 PST 2006
> test=api/java_security/cert/CertificateFactory/index.html#generate
> timeoutSeconds=600
> work=/u/martin/jck/int/runtime-6/work/api/java_security/cert/CertificateFactory
>
> #section:script_messages
> ----------messages:(1/24)----------
> Executing test class...
>
> #section:testExecute
> ----------messages:(1/530)----------
> command: com.sun.jck.lib.ExecJCKTestOtherJVMCmd LD_LIBRARY_PATH=/u/martin/jck/lib-JCK-runtime-6 DISPLAY=:7 HOME=/u/martin HOME=/u/martin/jck/home /u/martin/ws/int/control/build/solaris-sparc/j2sdk-image/bin/java -Xmx256m -Xfuture -classpath /u/martin/jck/JCK-runtime-6/classes -Djava.security.policy=/u/martin/jck/JCK-runtime-6/lib/jck.policy javasoft.sqe.tests.api.java.security.cert.CertificateFactory.generateTests -TestURL file:///u/martin/jck/JCK-runtime-6/tests/api/java_security/cert/CertificateFactory/index.html#generate
> ----------out1:(40/2863)----------
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2011: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2012: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2013: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2014: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2015: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2016: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2017: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2018: Passed. test cases: 1; all passed
> java.lang.ClassCastException: java.lang.String cannot be cast to java.security.cert.X509Certificate
>     at sun.security.provider.certpath.X509CertPath.<init>(X509CertPath.java:97)
>     at sun.security.provider.X509Factory.engineGenerateCertPath(X509Factory.java:375)
>     at java.security.cert.CertificateFactory.generateCertPath(CertificateFactory.java:387)
>     at javasoft.sqe.tests.api.java.security.cert.CertificateFactory.generateTests.CertificateFactory2019(generateTests.java:509)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     at java.lang.reflect.Method.invoke(Method.java:597)
>     at javasoft.sqe.javatest.lib.MultiTest.invokeTestCase(MultiTest.java:406)
>     at javasoft.sqe.jck.lib.ProviderTest.invokeTestCase(ProviderTest.java:281)
>     at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:195)
>     at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:127)
>     at javasoft.sqe.tests.api.java.security.cert.CertificateFactory.generateTests.main(generateTests.java:210)
> CertificateFactory2019: Failed. Test case throws exception: java.lang.ClassCastException: java.lang.String cannot be cast to java.security.cert.X509Certificate
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2020: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2021: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2022: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2023: Passed. test cases: 1; all passed
> STATUS:Failed.test cases: 13; passed: 12; failed: 1; first test case failure: CertificateFactory2019
> ----------out2:(21/1754)----------
>  === public final Certificate generateCertificate(InputStream inStream) throws CertificateException ===
>  === public final Certificate generateCertificate(InputStream inStream) throws CertificateException ===
>  === public final Certificate generateCertificate(InputStream inStream) throws CertificateException ===
> Expected exception java.security.cert.CertificateException: Unable to initialize, java.io.IOException: extra data given to DerValue constructor
>  === public final Collection generateCertificates(InputStream inStream) throws CertificateException ===
>  === public final Collection generateCertificates(InputStream inStream) throws CertificateException ===
>  === public final Collection generateCertificates(InputStream inStream) throws CertificateException ===
>  === public final Collection generateCertificates(InputStream inStream) throws CertificateException ===
> Expected exception java.security.cert.CertificateException: java.io.EOFException
>  === public final CertPath generateCertPath(List certificates) throws CertificateException ===
> Number of Certificates is 1
>  === public final CertPath generateCertPath(List certificates) throws CertificateException ===
>  === public final CertPath generateCertPath(InputStream inStream) throws CertificateException ===
> Number of Certificates is 1
>  === public final CertPath generateCertPath(InputStream inStream) throws CertificateException ===
>  === public final CertPath generateCertPath(InputStream inStream, String encoding) throws CertificateException ===
> Will test for encoding PkiPath
> Number of Certificates is 1
> Will test for encoding PKCS7
> Number of Certificates is 1
>  === public final CertPath generateCertPath(InputStream inStream, String encoding) throws CertificateException ===
> result: Failed. test cases: 13; passed: 12; failed: 1; first test case failure: CertificateFactory2019
>
>
> test result: Failed. test cases: 13; passed: 12; failed: 1; first test case failure: CertificateFactory2019
>
>
>
>
> #Test Results (version 2)
> #Thu Nov 09 20:24:26 PST 2006
> #checksum:5317c27957e86351
> #-----testdescription-----
> $file=/u/martin/jck/JCK-runtime-6/tests/api/java_security/cert/CertificateFactory/index.html
> $root=/u/martin/jck/JCK-runtime-6/tests
> executeArgs=-TestURL $testURL
> executeClass=javasoft.sqe.tests.api.java.security.cert.CertificateFactory.generateTests
> id=generate
> keywords=positive runtime
> source=generateTests.java
> title=CertificateFactory generate() methods tests
>
> #-----environment-----
> command.testExecute=com.sun.jck.lib.ExecJCKTestOtherJVMCmd LD_LIBRARY_PATH=/u/martin/jck/lib-JCK-runtime-6 DISPLAY=:7 HOME=${user.home} HOME=/u/martin/jck/home /u/martin/ws/int/control/build/solaris-sparc/j2sdk-image/bin/java -Xmx256m ${jvmtiAgentOptions} -Xfuture $jdwpAgentOptions -classpath $testSuiteRootDir/classes $JPLISAgentOpts $JPLISAgent2Opts -Djava.security.policy=$testSuiteRootDir/lib/jck.policy $testExecuteClass $testExecuteArgs
> user.home=/u/martin
>
> #-----testresult-----
> description=file:///u/martin/jck/JCK-runtime-6/tests/api/java_security/cert/CertificateFactory/index.html#generate
> end=Thu Nov 09 20:24:26 PST 2006
> environment=autobuild_runtime
> execStatus=Failed. test cases: 13; passed: 12; failed: 1; first test case failure: CertificateFactory2019
> javatestOS=SunOS 5.9 (sparc)
> javatestVersion=3.2.2
> script=com.sun.jck.lib.JCKScript 
> sections=script_messages testExecute
> start=Thu Nov 09 20:24:25 PST 2006
> test=api/java_security/cert/CertificateFactory/index.html#generate
> timeoutSeconds=600
> work=/u/martin/jck/int/runtime-6/work/api/java_security/cert/CertificateFactory
>
> #section:script_messages
> ----------messages:(1/24)----------
> Executing test class...
>
> #section:testExecute
> ----------messages:(1/530)----------
> command: com.sun.jck.lib.ExecJCKTestOtherJVMCmd LD_LIBRARY_PATH=/u/martin/jck/lib-JCK-runtime-6 DISPLAY=:7 HOME=/u/martin HOME=/u/martin/jck/home /u/martin/ws/int/control/build/solaris-sparc/j2sdk-image/bin/java -Xmx256m -Xfuture -classpath /u/martin/jck/JCK-runtime-6/classes -Djava.security.policy=/u/martin/jck/JCK-runtime-6/lib/jck.policy javasoft.sqe.tests.api.java.security.cert.CertificateFactory.generateTests -TestURL file:///u/martin/jck/JCK-runtime-6/tests/api/java_security/cert/CertificateFactory/index.html#generate
> ----------out1:(40/2863)----------
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2011: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2012: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2013: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2014: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2015: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2016: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2017: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2018: Passed. test cases: 1; all passed
> java.lang.ClassCastException: java.lang.String cannot be cast to java.security.cert.X509Certificate
> 	at sun.security.provider.certpath.X509CertPath.<init>(X509CertPath.java:97)
> 	at sun.security.provider.X509Factory.engineGenerateCertPath(X509Factory.java:375)
> 	at java.security.cert.CertificateFactory.generateCertPath(CertificateFactory.java:387)
> 	at javasoft.sqe.tests.api.java.security.cert.CertificateFactory.generateTests.CertificateFactory2019(generateTests.java:509)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at javasoft.sqe.javatest.lib.MultiTest.invokeTestCase(MultiTest.java:406)
> 	at javasoft.sqe.jck.lib.ProviderTest.invokeTestCase(ProviderTest.java:281)
> 	at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:195)
> 	at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:127)
> 	at javasoft.sqe.tests.api.java.security.cert.CertificateFactory.generateTests.main(generateTests.java:210)
> CertificateFactory2019: Failed. Test case throws exception: java.lang.ClassCastException: java.lang.String cannot be cast to java.security.cert.X509Certificate
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2020: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2021: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2022: Passed. test cases: 1; all passed
> Provider SUN, algorithm CertificateFactory.X.509: Passed. OKAY
> CertificateFactory2023: Passed. test cases: 1; all passed
> STATUS:Failed.test cases: 13; passed: 12; failed: 1; first test case failure: CertificateFactory2019
> ----------out2:(21/1754)----------
>  === public final Certificate generateCertificate(InputStream inStream) throws CertificateException === 
>  === public final Certificate generateCertificate(InputStream inStream) throws CertificateException === 
>  === public final Certificate generateCertificate(InputStream inStream) throws CertificateException === 
> Expected exception java.security.cert.CertificateException: Unable to initialize, java.io.IOException: extra data given to DerValue constructor
>  === public final Collection generateCertificates(InputStream inStream) throws CertificateException === 
>  === public final Collection generateCertificates(InputStream inStream) throws CertificateException === 
>  === public final Collection generateCertificates(InputStream inStream) throws CertificateException === 
>  === public final Collection generateCertificates(InputStream inStream) throws CertificateException === 
> Expected exception java.security.cert.CertificateException: java.io.EOFException
>  === public final CertPath generateCertPath(List certificates) throws CertificateException === 
> Number of Certificates is 1
>  === public final CertPath generateCertPath(List certificates) throws CertificateException === 
>  === public final CertPath generateCertPath(InputStream inStream) throws CertificateException === 
> Number of Certificates is 1
>  === public final CertPath generateCertPath(InputStream inStream) throws CertificateException === 
>  === public final CertPath generateCertPath(InputStream inStream, String encoding) throws CertificateException === 
> Will test for en

Comments
EVALUATION Peter.Ahe gives a neatly solution that could avoid the ClassCastException, I updated the codes according his suggestion. However, I don't think the JCK test is proper on the parameter passed to the generateCertPath(), it should aware that it is maybe throw a ClassCastException if an illegal parameter assigned. Brad Wetmore wrote: > In my $.02, the 1.4.2 (pre-generics) API is very clear that the argument is expected to be a list of Certificates. It probably should have been returning a ClassCastException when a list of Strings was given, but I guess we were being nice and returning a CertificateException. > > Anyway, I would say the current behaviour is correct, and the JCK should be updated. > > You should talk to Peter.Ahe if you want an opinion from the javac side. > > This is only my opinion, so you should talk to others including the API developer (Sean) before deciding on a course of action. > > Brad > > > Andrew Fan wrote: >> Hi Brad, >> >> Max talked this issue with me, we both think the update makes the codes ugly and JCK should update the codes if possible. >> >> The java.security.cert.CertificateFactory.generateCertPath() is defined as: >> >> -------- >> /** >> * Generates a <code>CertPath</code> object and initializes it with >> * a <code>List</code> of <code>Certificate</code>s. >> * <p> >> * The certificates supplied must be of a type supported by the >> * <code>CertificateFactory</code>. They will be copied out of the supplied >> * <code>List</code> object. >> * >> * @param certificates a <code>List</code> of <code>Certificate</code>s >> * @return a <code>CertPath</code> initialized with the supplied list of >> * certificates >> * @exception CertificateException if an exception occurs >> * @since 1.4 >> */ >> public final CertPath >> generateCertPath(List<? extends Certificate> certificates) >> throws CertificateException >> { >> return(certFacSpi.engineGenerateCertPath(certificates)); >> } >> ------- >> >> In the JCK test case, the method is called as: >> CertificateFactory.generateCertPath(list<String>) >> >> The parameter is "list<? extends Certificate>", so developer should use a list of Certificate as the parameter. However, the JCK test passes a list of String to the method, which will result in a compiler warning, and in the danger of encounter runtime exception, ClassCastException. I don't think the JCK test work properly as: >> 1. The test should use a list of Certificate as parameter, as the API is declared as list<? extends Certificate>; >> 2. the ClassCastException is a runtime exception, I don't think it would be proper to handle a runtime exception in the implementation. >> >> So could we have a discussion on the issue with JCK developers? >> >> And more, no more failure found on the JCK net/security tests. >> >> Thanks, >> Andrew
14-11-2006