]
George Gastaldi closed ROASTER-70.
----------------------------------
Fix Version/s: 2.17.0.Final
(was: 2.x Future)
Assignee: George Gastaldi
Resolution: Done
setReturnType(Response.class) doesn't import Response
-----------------------------------------------------
Key: ROASTER-70
URL:
https://issues.jboss.org/browse/ROASTER-70
Project: Roaster
Issue Type: Bug
Components: API
Affects Versions: 2.13.2.Final
Reporter: Antonio Goncalves
Assignee: George Gastaldi
Fix For: 2.17.0.Final
If you take the following code :
{code}
public static void main(String[] args) {
final JavaClassSource javaClassSource = Roaster.create(JavaClassSource.class);
javaClassSource.setPackage("org.agoncal.myproj").setName("MyEndpoint").addAnnotation(Path.class).setStringValue("/mypath");
MethodSource<?> doGet =
javaClassSource.addMethod().setPublic().setName("method").setReturnType("javax.ws.rs.core.Response");
doGet.setBody("return null;");
System.out.println(javaClassSource);
}
{code}
It will generate the following code, which compile because it imports
{{javax.ws.rs.core.Response}}.
{code}
package org.agoncal.myproj;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
@Path("/mypath")
public class MyEndpoint {
public Response method() {
return null;
}
}
{code}
But if you change {{setReturnType("javax.ws.rs.core.Response")}} with
{{setReturnType(Response.class)}}, {{Response}} is not imported, therefore, the code
doesn't compile