Skip to content

Commit bca8832

Browse files
flx5flx5
authored andcommitted
Remove reflection so that GraalVM native-image does not need a hint.
Signed-off-by: flx5 <1330854+flx5@users.noreply.github.com>
1 parent b7d1ff7 commit bca8832

17 files changed

+80
-85
lines changed

jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/impl/RuntimeAttributePropertyInfoImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import org.glassfish.jaxb.runtime.v2.model.runtime.RuntimeAttributePropertyInfo;
1414
import org.glassfish.jaxb.runtime.v2.model.runtime.RuntimeNonElement;
1515
import org.glassfish.jaxb.runtime.v2.model.runtime.RuntimePropertyInfo;
16+
import org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl;
17+
import org.glassfish.jaxb.runtime.v2.runtime.property.AttributeProperty;
18+
import org.glassfish.jaxb.runtime.v2.runtime.property.Property;
1619

1720
import java.lang.reflect.Field;
1821
import java.lang.reflect.Method;

jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/impl/RuntimeValuePropertyInfoImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import org.glassfish.jaxb.runtime.v2.model.runtime.RuntimeNonElement;
1414
import org.glassfish.jaxb.runtime.v2.model.runtime.RuntimePropertyInfo;
1515
import org.glassfish.jaxb.runtime.v2.model.runtime.RuntimeValuePropertyInfo;
16+
import org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl;
17+
import org.glassfish.jaxb.runtime.v2.runtime.property.Property;
18+
import org.glassfish.jaxb.runtime.v2.runtime.property.ValueProperty;
1619

1720
import java.lang.reflect.Field;
1821
import java.lang.reflect.Method;

jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/runtime/RuntimeAttributePropertyInfo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
package org.glassfish.jaxb.runtime.v2.model.runtime;
1212

1313
import org.glassfish.jaxb.core.v2.model.core.AttributePropertyInfo;
14+
import org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl;
15+
import org.glassfish.jaxb.runtime.v2.runtime.property.AttributeProperty;
16+
import org.glassfish.jaxb.runtime.v2.runtime.property.Property;
1417

1518
import java.lang.reflect.Type;
1619

@@ -21,4 +24,10 @@ public interface RuntimeAttributePropertyInfo extends AttributePropertyInfo<Type
2124
// refinement
2225
@Override
2326
RuntimeNonElement getTarget();
27+
28+
29+
@Override
30+
default Property<?> create(JAXBContextImpl grammar) {
31+
return new AttributeProperty<>(grammar, this);
32+
}
2433
}

jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/runtime/RuntimeElementPropertyInfo.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
package org.glassfish.jaxb.runtime.v2.model.runtime;
1212

1313
import org.glassfish.jaxb.core.v2.model.core.ElementPropertyInfo;
14+
import org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl;
15+
import org.glassfish.jaxb.runtime.v2.runtime.property.ArrayElementLeafProperty;
16+
import org.glassfish.jaxb.runtime.v2.runtime.property.ArrayElementNodeProperty;
17+
import org.glassfish.jaxb.runtime.v2.runtime.property.ListElementProperty;
18+
import org.glassfish.jaxb.runtime.v2.runtime.property.Property;
19+
import org.glassfish.jaxb.runtime.v2.runtime.property.PropertyFactory;
20+
import org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementLeafProperty;
21+
import org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty;
1422

1523
import java.lang.reflect.Type;
1624
import java.util.Collection;
@@ -25,4 +33,19 @@ public interface RuntimeElementPropertyInfo extends ElementPropertyInfo<Type,Cla
2533

2634
@Override
2735
List<? extends RuntimeTypeRef> getTypes();
36+
37+
@Override
38+
default Property<?> create(JAXBContextImpl grammar) {
39+
if(this.isValueList())
40+
return new ListElementProperty<>(grammar, this);
41+
42+
boolean isLeaf = PropertyFactory.isLeaf(this);
43+
boolean isCollection = this.isCollection();
44+
45+
if (isLeaf) {
46+
return isCollection ? new ArrayElementLeafProperty<>(grammar, this) : new SingleElementLeafProperty<>(grammar, this);
47+
}
48+
49+
return isCollection ? new ArrayElementNodeProperty<>(grammar, this) : new SingleElementNodeProperty<>(grammar, this);
50+
}
2851
}

jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/runtime/RuntimeMapPropertyInfo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
package org.glassfish.jaxb.runtime.v2.model.runtime;
1212

1313
import org.glassfish.jaxb.core.v2.model.core.MapPropertyInfo;
14+
import org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl;
15+
import org.glassfish.jaxb.runtime.v2.runtime.property.AttributeProperty;
16+
import org.glassfish.jaxb.runtime.v2.runtime.property.Property;
17+
import org.glassfish.jaxb.runtime.v2.runtime.property.SingleMapNodeProperty;
1418

1519
import java.lang.reflect.Type;
1620

@@ -22,4 +26,10 @@ public interface RuntimeMapPropertyInfo extends RuntimePropertyInfo, MapProperty
2226
RuntimeNonElement getKeyType();
2327
@Override
2428
RuntimeNonElement getValueType();
29+
30+
31+
@Override
32+
default Property<?> create(JAXBContextImpl grammar) {
33+
return new SingleMapNodeProperty<>(grammar, this);
34+
}
2535
}

jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/runtime/RuntimePropertyInfo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import org.glassfish.jaxb.core.v2.model.core.PropertyInfo;
1414
import org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl;
15+
import org.glassfish.jaxb.runtime.v2.runtime.property.Property;
1516
import org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor;
1617

1718
import java.lang.reflect.Type;
@@ -78,4 +79,6 @@ public interface RuntimePropertyInfo extends PropertyInfo<Type,Class> {
7879
* @return always non-null.
7980
*/
8081
Type getIndividualType();
82+
83+
Property<?> create(JAXBContextImpl grammar);
8184
}

jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/runtime/RuntimeReferencePropertyInfo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
package org.glassfish.jaxb.runtime.v2.model.runtime;
1212

1313
import org.glassfish.jaxb.core.v2.model.core.ReferencePropertyInfo;
14+
import org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl;
15+
import org.glassfish.jaxb.runtime.v2.runtime.property.ArrayReferenceNodeProperty;
16+
import org.glassfish.jaxb.runtime.v2.runtime.property.Property;
17+
import org.glassfish.jaxb.runtime.v2.runtime.property.SingleReferenceNodeProperty;
1418

1519
import java.lang.reflect.Type;
1620
import java.util.Set;
@@ -21,4 +25,10 @@
2125
public interface RuntimeReferencePropertyInfo extends ReferencePropertyInfo<Type,Class>, RuntimePropertyInfo {
2226
@Override
2327
Set<? extends RuntimeElement> getElements();
28+
29+
@Override
30+
default Property<?> create(JAXBContextImpl grammar) {
31+
boolean isCollection = this.isCollection();
32+
return isCollection ? new ArrayReferenceNodeProperty<>(grammar, this) : new SingleReferenceNodeProperty<>(grammar, this);
33+
}
2434
}

jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/runtime/RuntimeValuePropertyInfo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
package org.glassfish.jaxb.runtime.v2.model.runtime;
1212

1313
import org.glassfish.jaxb.core.v2.model.core.ValuePropertyInfo;
14+
import org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl;
15+
import org.glassfish.jaxb.runtime.v2.runtime.property.Property;
16+
import org.glassfish.jaxb.runtime.v2.runtime.property.ValueProperty;
1417

1518
import java.lang.reflect.Type;
1619

@@ -20,4 +23,9 @@
2023
public interface RuntimeValuePropertyInfo extends ValuePropertyInfo<Type,Class>,RuntimePropertyInfo,RuntimeNonElementRef {
2124
@Override
2225
RuntimeNonElement getTarget();
26+
27+
@Override
28+
default Property<?> create(JAXBContextImpl grammar) {
29+
return new ValueProperty<>(grammar, this);
30+
}
2331
}

jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/property/ArrayElementLeafProperty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*
3131
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
3232
*/
33-
final class ArrayElementLeafProperty<BeanT,ListT,ItemT> extends ArrayElementProperty<BeanT,ListT,ItemT> {
33+
public final class ArrayElementLeafProperty<BeanT,ListT,ItemT> extends ArrayElementProperty<BeanT,ListT,ItemT> {
3434

3535
private final Transducer<ItemT> xducer;
3636

jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/runtime/property/ArrayElementNodeProperty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @author Kohsuke Kawaguchi
2626
*/
27-
final class ArrayElementNodeProperty<BeanT,ListT,ItemT> extends ArrayElementProperty<BeanT,ListT,ItemT> {
27+
public final class ArrayElementNodeProperty<BeanT,ListT,ItemT> extends ArrayElementProperty<BeanT,ListT,ItemT> {
2828

2929
public ArrayElementNodeProperty(JAXBContextImpl p, RuntimeElementPropertyInfo prop) {
3030
super(p, prop);

0 commit comments

Comments
 (0)