[forge-issues] [JBoss JIRA] (FORGE-471) JavaResource handling of files with nested classes is incorrect

George Gastaldi (JIRA) jira-events at lists.jboss.org
Thu Nov 15 13:48:25 EST 2012


     [ https://issues.jboss.org/browse/FORGE-471?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

George Gastaldi updated FORGE-471:
----------------------------------

    Fix Version/s: 1.1.3.Final
                       (was: 1.1.2.Final)

    
> JavaResource handling of files with nested classes is incorrect
> ---------------------------------------------------------------
>
>                 Key: FORGE-471
>                 URL: https://issues.jboss.org/browse/FORGE-471
>             Project: Forge
>          Issue Type: Bug
>          Components: Parsers / File Manipulation, Resources API
>    Affects Versions: 1.0.6.Final
>            Reporter: Rudy De Busscher
>             Fix For: 1.1.3.Final
>
>
> In the case you have following java source file
> public class Test {
>     
>     private String mainProperty;
>     public void mainMethod() {
>         System.out.println("Hi");
>     }
>     public static final class Nested {
>         private String innerProperty;
>         public void innerMethod() {
>             System.out.println("I'm inner");
>         }
>     }
> }
> And running following statements
>         JavaResource javaResource = factory.getResourceFrom(new File"/path/to/file/Test.java")).reify(JavaResource.class);
>         System.out.println(javaResource.toString());
>         List<Resource<?>> resources = javaResource.listResources();
>         for (Resource res : resources) {
>             System.out.println(res.getFullyQualifiedName());
>         }
> You get following output
>      be.rubus.forge.deltaspike.test.projectstage.Nested
>      /path/to/file/Test.java/innerProperty::String
>      /path/to/file/Test.java/mainMethod()::void
>      /path/to/file/Test.java/innerMethod()::void
> The wrong name is due to the fact that TypeDeclarationFinderVisitor records every class type the parser finds.  In our case the 2 class names but only the last one is kept (first name is overwritten)
> The MethodFinderVisitor has a similar problem, it gets called twice and adds up the found methods.
> So there need to be a general review of the visitors to be able to handle nested or multiple classes in one java source file.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the forge-issues mailing list