[forge-issues] [JBoss JIRA] (ROASTER-62) Roaster - adds java.lang.xxx imports which is automatic in Java
Claus Ibsen (JIRA)
issues at jboss.org
Tue Feb 17 06:32:48 EST 2015
Claus Ibsen created ROASTER-62:
----------------------------------
Summary: Roaster - adds java.lang.xxx imports which is automatic in Java
Key: ROASTER-62
URL: https://issues.jboss.org/browse/ROASTER-62
Project: Roaster
Issue Type: Bug
Environment: Using Forge 2.14.0 so I use the Roaster that is shipped
Reporter: Claus Ibsen
Priority: Minor
I have this code that creates a Apache Camel class for building routes.
{code}
// need to parse to be able to extends another class
String top = String.format("public class %s extends RouteBuilder {}", name.getValue());
final JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, top);
if (targetPackage.getValue() != null) {
javaClass.setPackage(targetPackage.getValue());
}
javaClass.addImport("org.apache.camel.builder.RouteBuilder");
javaClass.addMethod()
.setPublic()
.setReturnTypeVoid()
.setName("configure")
.setBody("from(\"timer:foo\").to(\"log:foo\");")
.addThrows(Exception.class);
facet.saveJavaSource(javaClass);
{code}
Notice that the configure method has a throws java.lang.Exception.
The generated source code has import java.lang.Exception which is automatic in java, and all java.lang is auto imported and not to be defined.
The generated code
{code}
davsclaus:/opt/forge-distribution-2.14.0.Final/mydemo/$ cat src/main/java/com/foo/Bar.java
package com.foo;
import org.apache.camel.builder.RouteBuilder;
import java.lang.Exception;
public class Bar extends RouteBuilder
{
public void configure() throws Exception
{
from("timer:foo").to("log:foo");
}
}davsclaus:/opt/forge-distribution-2.14.0.Final/mydemo/$ mvn clean install
{code}
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)
More information about the forge-issues
mailing list