Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-678

forge-parser-java: JavaClassImpl with generic super type produces wrong code

XMLWordPrintable

      forge doesn't support correctly generics.
      some use case, improperly parsed:

      JavaClass c1 = JavaParser.parse(JavaClass.class, "package it.coopservice.test; public class Bar<T> {}");
      JavaClass javaClass = JavaParser.create(JavaClass.class);
      javaClass.setName("TBarTest");
      javaClass.setSuperType(c1);
      javaClass.setPackage("it.coopservice.test");
      javaClass.addImport("it.coopservice.test.Bar");

      produces:

      public class TBarTest extends Bar{}

      and this:
      JavaClass c0 = JavaParser.parse(JavaClass.class, "package it.coopservice.test; public class Foo {}");
      JavaClass c1 = JavaParser.parse(JavaClass.class, "package it.coopservice.test; public class Bar<Foo> {}");
      JavaClass javaClass = JavaParser.create(JavaClass.class);
      javaClass.setName("FooBarDirectTest");
      javaClass.setPackage("it.coopservice.test");
      javaClass.addImport("it.coopservice.test.Bar");
      javaClass.addImport("it.coopservice.test.Foo");
      javaClass.setSuperType("Bar<Foo>");

      produces:
      java.lang.IllegalArgumentException

      my complete test code and output:
      https://gist.github.com/3746475

              fiorenzino@gmail.com fiorenzo pizza (Inactive)
              fiorenzino@gmail.com fiorenzo pizza (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: