2 Replies Latest reply on Oct 18, 2012 3:46 AM by athalay

    Is it possible to override the default JavaParserImpl.java in a plugin?

    athalay

      Hi!

       

      I want to set the supertype of a java class to a ParameterizedType, but the default implementation only supports SimpleType.

      I want to create a plugin and use MyJavaClassImpl wich inherits from the original and supports generics.

      How can i do this?

       

      I tried to set a dependency to the original java api implementation, but i got the following warning :

      "***WARNING*** Plugin has a dependency on internal Forge API [org.jboss.forge:forge-parser-java:jar::1.1.1.Final] - this is not allowed and may cause failures."

       

      My implementation of JavaParserProvider inherits from JavaParserImpl and overrides the "public JavaSource parse(final String data)" function to return a MyJavaClassImpl instead of JavaClassImp.

      When i try to create a new instance of MyJavaParserImp i got the following exception :

       

      java.lang.ClassNotFoundException: org.eclipse.jdt.core.dom.ASTVisitor from [Module "com.wcs.forge.persistence.wcsplugins:1.0.0-SNAPSHOT-da286062-16ed-4245-aabf-d2e0b1ead9ae" from local module loader @40f6dcc7 (roots: /home/athalay/apps/forge/modules,/home/athalay/.forge/plugins,/home/athalay/apps/forge)]

              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

       

      Is there any way to override it from a plugin or i have to change the implementation in the forge source itself?

       

      Thanks

        • 1. Re: Is it possible to override the default JavaParserImpl.java in a plugin?
          lincolnthree

          Hey there Athalay,

           

          We have someone currently working on this issue for the next version, to be released November 15th. He's almost done, perhaps you'd like to get in touch with him? If you email forge-dev@lists.jboss.org or hang out in the #forge IRC channel, I can put the two of you in touch. It would be good to compare what each of you has done so that we can get this fixed as quickly and as completely as possible in the Forge core APIs.

           

          As far as answering your questions:

           

          1. You cannot include forge implementations in plugins - this is disallowed. In order to do this, you would need to copy all of the source files into your plugin project (or create a new maven dependency with a different groupId,) and include the corresponding Eclipse JDT dependencies in your POM file as well. This is a known limitation of Forge 1.x that we are resolving in Forge 2.x.

           

          I hope this is helpful,

          ~Lincoln

          • 2. Re: Is it possible to override the default JavaParserImpl.java in a plugin?
            athalay

            Hi,

             

            My version only supports the use case of our current project, so i don't think i could help.

            I'll be waiting patiently .

             

            Thanks for the fast reply