Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SE21: ignore properties of sequence collections in comparision #85

Merged
merged 1 commit into from Jan 8, 2024

Conversation

lukasj
Copy link
Contributor

@lukasj lukasj commented Jan 3, 2024

SE 21 introduced SequencedCollections with getFirst & getLast methods and the problem is, that the TCK currently treats them as regular properties - they are being returned by java.beans.Introspector, so the framework tries to find corresponding first and last fields and because they are not there, testing fails with BeansError/NoSuchElementException

Full stacktrace
#section:execute
----------messages:(1/1035)----------
command: javasoft.sqe.javatest.lib.ExecStdTestOtherJVMCmd CLASSPATH=/home/g/oracle/jaxb-tck/xml-binding-tck/classes:/home/g/oracle/jaxb-tck/checker.jar:/home/g/oracle/jaxb-tck/jaxb-ri/mod/jakarta.xml.bind-api.jar:/home/g/oracle/jaxb-tck/jaxb-ri/mod/jaxb-impl.jar:/home/g/oracle/jaxb-tck/jaxb-ri/mod/jaxb-jxc.jar:/home/g/oracle/jaxb-tck/jaxb-ri/mod/jakarta.activation-api.jar:/home/g/oracle/jaxb-tck/xml-binding-tck/lib/javatest.jar:/home/g/oracle/jaxb-tck/xml-binding-tck/lib/jtlegacy.jar:/home/g/oracle/jaxb-tck/batch-multiJVM/work/classes:/home/g/oracle/jaxb-tck/batch-multiJVM/work/classes/additional/addb122 /home/g/oracle/jaxb-tck/jdk-21.0.1/bin/java -Djava.security.policy=/home/g/oracle/jaxb-tck/xml-binding-tck/lib/tck.policy javasoft.sqe.tests.api.jakarta.xml.bind.JAXBTest -TestURL file:/home/g/oracle/jaxb-tck/xml-binding-tck/tests/xml_schema/msData/additional/jaxb/addB122.html#addB122.v -package javasoft.sqe.tests.additional.addb122 -out :ref -document ../addB122.xml -pcontent addb122-addB122.jbx -schema ../addB122.xsd
----------out1:(35/2376)----------
marshal: Passed. OK
unmarshal: Passed. OK
java.lang.RuntimeException: Beans error.
	at com.sun.jaxb_tck.lib.persistence.Comparator.compareBeansAsTrees(Comparator.java:269)
	at com.sun.jaxb_tck.lib.persistence.Comparator.compareBeans(Comparator.java:192)
	at javasoft.sqe.tests.api.jakarta.xml.bind.JAXBTest.compareContent(JAXBTest.java:285)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at javasoft.sqe.javatest.lib.MultiTest.invokeTestCase(MultiTest.java:409)
	at javasoft.sqe.jck.lib.MultiTestExt.invokeTestCase(MultiTestExt.java:246)
	at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:205)
	at javasoft.sqe.tests.api.jakarta.xml.bind.JAXBTest.main(JAXBTest.java:50)
Caused by: java.lang.RuntimeException: Beans error.
	at com.sun.jaxb_tck.lib.persistence.Comparator.compareBeansAsTrees(Comparator.java:269)
	at com.sun.jaxb_tck.lib.persistence.Comparator.compareBeans(Comparator.java:192)
	at com.sun.jaxb_tck.lib.persistence.Comparator$ComparableObject.compareTo(Comparator.java:62)
	at com.sun.jaxb_tck.lib.persistence.Comparator.compareBeansAsTrees(Comparator.java:250)
	... 8 more
Caused by: java.lang.RuntimeException: Beans error.
	at com.sun.jaxb_tck.lib.persistence.Comparator.compareBeansAsTrees(Comparator.java:269)
	at com.sun.jaxb_tck.lib.persistence.Comparator.compareBeans(Comparator.java:192)
	at com.sun.jaxb_tck.lib.persistence.Comparator$ComparableObject.compareTo(Comparator.java:62)
	at com.sun.jaxb_tck.lib.persistence.Comparator.compareBeansAsTrees(Comparator.java:250)
	... 11 more
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at com.sun.jaxb_tck.lib.persistence.Comparator.compareBeansAsTrees(Comparator.java:240)
	... 14 more
Caused by: java.util.NoSuchElementException
	at java.base/java.util.ArrayList.getFirst(ArrayList.java:439)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	... 16 more
compareContent: Failed. Test case throws exception: java.lang.RuntimeException: Beans error.
STATUS:Failed.test cases: 3; passed: 2; failed: 1; first test case failure: compareContent

This fixes the comparator to explicitly ignore first and last fields in comparisons involving SequencedCollections in a way it is usable on older JDKs as well

Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
@gurunrao
Copy link
Contributor

gurunrao commented Jan 8, 2024

The tests failing with JDK 21 passes with the PR fix, LGTM.

@gurunrao gurunrao merged commit d1ce754 into jakartaee:master Jan 8, 2024
2 checks passed
@lukasj lukasj deleted the cols branch January 8, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants