Details
-
Feature Request
-
Resolution: Done
-
Minor
-
None
-
None
Description
The implementation of org.jboss.resteasy.core.FormInjector requires that the no-arg constructor for beans it injects is public. This is used for injection of QueryParams into BeanParam objects.
This is not consistent with other areas of JAX-RS where a private no-arg constructor is accepted.
A resource defined like this would fail startup:
@GET public void searchForHappiness(@BeanParam HappinessParams searchParams) {} public static final HappinessParams { @QueryParam("duration") int duration; @QueryParam("timeUnit") String timeUnit; @QueryParam("type") String type; private HappinessParams() {} public HappinessParams(int duration, String timeUnit) {} public HappinessParams(String type) {} }
The root of the problem is here: https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/core/FormInjector.java#L30
I think this could be solved by changing the getConstructor call to getDeclaredConstructor and calling setAccessible(true) on the constructor returned. Would that be sufficient or is there other process involved in calling setAccessible?