3 Replies Latest reply on Jan 12, 2016 5:43 PM by gastaldi

    Roaster - possible bug with JavaClassSource.implementInterface

    mrjazzy

      I have an interface

       

      public interface IPersonLookup {

        Person lookupRequest(String name, boolean enveloped);

        Person lookupRequest(int et, boolean enveloped);

      }

       

      which I want to implement using Roaster to generate the implementation;

       

      @Test

        public void test2() throws UnsupportedEncodingException, FileNotFoundException, IOException

        {

        final JavaClassSource jc = Roaster.create(JavaClassSource.class);

        jc.setPackage("uk.co.his.test.gen");

        jc.setName("PersonLookupImpl");

        //jc.addInterface(IStateModelDefLookup.class);

        jc.implementInterface(IPersonLookup.class);

       

        System.out.println(jc);

        writeClass(GeneratedSources, jc );

        }

       

      The following code is generated;

       

      package uk.co.his.test.gen;

       

      import uk.co.his.test.roaster.IPersonLookup;

      import uk.co.his.test.roaster.Person;


      public class PersonLookupImpl implements IPersonLookup {


        @Override

        public Person lookupRequest(String s) {

        return null;

        }

       

        @Override

        public Person lookupRequest() {

        return null;

        }

      }

       

      Roaster version 2.17.1.Final

      Java build 1.8.0_51-b16

       

      POM used;

       

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

        <modelVersion>4.0.0</modelVersion>

        <groupId>uk.co.his.test</groupId>

        <artifactId>RoasterTest</artifactId>

        <version>0.0.1-SNAPSHOT</version>

       

       

        <properties>

        <version.roaster>2.17.1.Final</version.roaster>

        </properties>

       

       

        <build>

        <plugins>

        <plugin>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-compiler-plugin</artifactId>

        <version>3.1</version>

        <configuration>

        <source>1.8</source>

        <target>1.8</target>

        <debug>true</debug>

        <showWarnings>true</showWarnings>

        <showDeprecation>true</showDeprecation>

        </configuration>

        </plugin>

        <plugin>

        <groupId>org.codehaus.mojo</groupId>

        <artifactId>build-helper-maven-plugin</artifactId>

        <version>1.9.1</version>

        <executions>

        <execution>

        <id>add-source</id>

        <phase>generate-sources</phase>

        <goals>

        <goal>add-source</goal>

        </goals>

        <configuration>

        <sources>

        <source>src/generated</source>

        </sources>

        </configuration>

        </execution>

        </executions>

        </plugin>

        </plugins>

        </build>

       

       

        <dependencies>

        <dependency>

        <groupId>org.jboss.forge.roaster</groupId>

        <artifactId>roaster-api</artifactId>

        <version>${version.roaster}</version>

        </dependency>

        <dependency>

        <groupId>org.jboss.forge.roaster</groupId>

        <artifactId>roaster-jdt</artifactId>

        <version>${version.roaster}</version>

        </dependency>

        <dependency>

        <groupId>junit</groupId>

        <artifactId>junit</artifactId>

        <version>4.11</version>

        </dependency>

        </dependencies>

      </project>