Skip to content

Commit 3df4216

Browse files
committed
Add missing JAXB hints and tests
1 parent 760a625 commit 3df4216

File tree

10 files changed

+186
-34
lines changed

10 files changed

+186
-34
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[
2-
"reflect-config.json"
2+
"reflect-config.json",
3+
"resource-config.json"
34
]

metadata/org.glassfish.jaxb/jaxb-runtime/3.0.2/reflect-config.json

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,68 @@
2323
"typeReachable": "org.glassfish.jaxb.runtime.v2.model.impl.Utils$1"
2424
}
2525
},
26+
{
27+
"name": "org.glassfish.jaxb.runtime.v2.runtime.property.ArrayElementLeafProperty",
28+
"queryAllPublicConstructors": true,
29+
"condition": {
30+
"typeReachable": "org.glassfish.jaxb.runtime.v2.runtime.property.PropertyFactory"
31+
}
32+
},
33+
{
34+
"name": "org.glassfish.jaxb.runtime.v2.runtime.property.ArrayElementNodeProperty",
35+
"queryAllPublicConstructors": true,
36+
"condition": {
37+
"typeReachable": "org.glassfish.jaxb.runtime.v2.runtime.property.PropertyFactory"
38+
}
39+
},
40+
{
41+
"name": "org.glassfish.jaxb.runtime.v2.runtime.property.ArrayReferenceNodeProperty",
42+
"queryAllPublicConstructors": true,
43+
"condition": {
44+
"typeReachable": "org.glassfish.jaxb.runtime.v2.runtime.property.PropertyFactory"
45+
}
46+
},
47+
{
48+
"name": "org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementLeafProperty",
49+
"condition": {
50+
"typeReachable": "org.glassfish.jaxb.runtime.v2.runtime.property.PropertyFactory"
51+
},
52+
"queryAllPublicConstructors": true,
53+
"methods": [
54+
{
55+
"name": "<init>",
56+
"parameterTypes": [
57+
"org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl",
58+
"org.glassfish.jaxb.runtime.v2.model.runtime.RuntimeElementPropertyInfo"
59+
]
60+
}
61+
]
62+
},
63+
{
64+
"name": "org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty",
65+
"queryAllPublicConstructors": true,
66+
"condition": {
67+
"typeReachable": "org.glassfish.jaxb.runtime.v2.runtime.property.PropertyFactory"
68+
}
69+
},
70+
{
71+
"name": "org.glassfish.jaxb.runtime.v2.runtime.property.SingleMapNodeProperty",
72+
"queryAllPublicConstructors": true,
73+
"condition": {
74+
"typeReachable": "org.glassfish.jaxb.runtime.v2.runtime.property.PropertyFactory"
75+
}
76+
},
77+
{
78+
"name": "org.glassfish.jaxb.runtime.v2.runtime.property.SingleReferenceNodeProperty",
79+
"queryAllPublicConstructors": true,
80+
"condition": {
81+
"typeReachable": "org.glassfish.jaxb.runtime.v2.runtime.property.PropertyFactory"
82+
}
83+
},
2684
{
2785
"name": "org.glassfish.jaxb.runtime.v2.ContextFactory",
2886
"condition": {
29-
"typeReachable": "jakarta.xml.bind.JAXBContext"
87+
"typeReachable": "jakarta.xml.bind.ContextFinder"
3088
},
3189
"methods": [
3290
{
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"bundles": [
3+
{
4+
"name": "org.glassfish.jaxb.runtime.v2.model.impl.Messages"
5+
}
6+
]
7+
}

tests/src/org.glassfish.jaxb/jaxb-runtime/3.0.2/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ graalvmNative {
2626
buildArgs.add('--no-fallback')
2727
}
2828
}
29+
agent {
30+
defaultMode = "conditional"
31+
modes {
32+
conditional {
33+
userCodeFilterPath = "user-code-filter.json"
34+
}
35+
}
36+
}
2937
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
7+
package glassfish;
8+
9+
import java.util.Objects;
10+
11+
import jakarta.xml.bind.annotation.XmlRootElement;
12+
13+
@XmlRootElement
14+
public class Foo {
15+
16+
private String message;
17+
18+
public Foo() {
19+
}
20+
21+
public Foo(String message) {
22+
this.message = message;
23+
}
24+
25+
public String getMessage() {
26+
return message;
27+
}
28+
29+
public void setMessage(String message) {
30+
this.message = message;
31+
}
32+
33+
@Override
34+
public boolean equals(Object o) {
35+
if (this == o) {
36+
return true;
37+
}
38+
if (o == null || getClass() != o.getClass()) {
39+
return false;
40+
}
41+
Foo foo = (Foo) o;
42+
return Objects.equals(message, foo.message);
43+
}
44+
45+
@Override
46+
public int hashCode() {
47+
return Objects.hash(message);
48+
}
49+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
7+
package glassfish;
8+
9+
10+
import java.io.StringReader;
11+
import java.io.StringWriter;
12+
13+
import jakarta.xml.bind.JAXBContext;
14+
import jakarta.xml.bind.JAXBException;
15+
import jakarta.xml.bind.Marshaller;
16+
import jakarta.xml.bind.Unmarshaller;
17+
import org.assertj.core.api.Assertions;
18+
import org.junit.jupiter.api.Test;
19+
20+
public class JaxbTest {
21+
22+
@Test
23+
void marshal() throws JAXBException {
24+
JAXBContext context = JAXBContext.newInstance(Foo.class);
25+
Marshaller marshaller = context.createMarshaller();
26+
Foo foo = new Foo();
27+
foo.setMessage("hello");
28+
StringWriter stringWriter = new StringWriter();
29+
marshaller.marshal(foo, stringWriter);
30+
Assertions.assertThat(stringWriter.toString())
31+
.isEqualTo("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><foo><message>hello</message></foo>");
32+
}
33+
34+
@Test
35+
void unmarshal() throws JAXBException {
36+
JAXBContext context = JAXBContext.newInstance(Foo.class);
37+
Unmarshaller unmarshaller = context.createUnmarshaller();
38+
StringReader reader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><foo><message>hello</message></foo>");
39+
Foo foo = (Foo) unmarshaller.unmarshal(reader);
40+
Assertions.assertThat(foo).isEqualTo(new Foo("hello"));
41+
}
42+
43+
}

tests/src/org.glassfish.jaxb/jaxb-runtime/3.0.2/src/test/java/org/glassfish/jaxb/Foo.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/src/org.glassfish.jaxb/jaxb-runtime/3.0.2/src/test/java/org/glassfish/jaxb/JaxbTest.java

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"name": "glassfish.Foo",
4+
"allDeclaredConstructors": true,
5+
"allDeclaredMethods": true,
6+
"allDeclaredFields": true
7+
}
8+
]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"rules": [
3+
{
4+
"excludeClasses": "**"
5+
},
6+
{
7+
"includeClasses": "org.glassfish.jaxb.**"
8+
}
9+
]
10+
}

0 commit comments

Comments
 (0)