1 2 Previous Next 15 Replies Latest reply on May 27, 2013 7:02 AM by nva

    Trouble compiling class with generics in 2.3.0.CR1

    mdhirsch30345

      I have a class that compiles fine with Errai 2.1.0, but will not build with 2.3.0.CR1.  When I build it with 2.3.0 I get these errors:

       

               [ERROR] Errors in 'generated://203AF005B6B57DF1BE3A46C024E2E66D/org/jboss/errai/ioc/client/BootstrapperImpl.java'

                  [WARN] Line 4452: Referencing deprecated method 'com.google.gwt.user.client.ui.Composite.setWidget'

                  [ERROR] Line 851: T cannot be resolved to a type

                  See snapshot: /tmp/org.jboss.errai.ioc.client.BootstrapperImpl2084728906436240268.java

       

      Lines 849-856 are:

        private final CreationalCallback<HistoryStack> inj2285_HistoryStack_creational = new CreationalCallback<HistoryStack>() {

          public HistoryStack getInstance(final CreationalContext context) {

            final ArrayList<T> var40 = inj2286_ArrayList_creational.getInstance(context);

            final HistoryStack inj351_HistoryStack = new HistoryStack(var40);

            context.addBean(context.getBeanReference(HistoryStack.class, QualifierUtil.DEFAULT_QUALIFIERS), inj351_HistoryStack);

            return inj351_HistoryStack;

          }

        };

       

      This seems to be generated from this java code:

       

      public class HistoryStack<T> {

                ArrayList<T> historyList;

                int historyIndex = -1;

       

       

                @Inject

                public HistoryStack(ArrayList<T> historyList) {

                          this.historyList = historyList;

                }

       

        /// API removed

      }

       

      This class works well in 2.1.0, so something appears to have happened since then in Errai.

       

      Michael

        • 1. Re: Trouble compiling class with generics in 2.3.0.CR1
          jfuerth

          Thanks for this report, Michael.

           

          Unfortunately, this does appear to be a regression in Errai IOC. Thanks for catching it before 2.3.0.Final -- we'll add a similar class to our test suite and try to get a fix out ASAP (it will appear first on 2.3.0-SNAPSHOT).

           

          I've created ERRAI-529 in JIRA to track this issue.

           

          -Jonathan

          1 of 1 people found this helpful
          • 2. Re: Trouble compiling class with generics in 2.3.0.CR1
            mdhirsch30345

            Thanks for filing the JIRA issue, Jonathan.  It's nice to know it is in the queue.

             

            Michael

            • 3. Re: Trouble compiling class with generics in 2.3.0.CR1
              csa

              Hi Micheal,

               

              This should be fixed now in the latest 2.3.0-SNAPSHOTs. It would be great if you could give it a try.

               

              Thanks,

              Christian

              • 4. Re: Trouble compiling class with generics in 2.3.0.CR1
                mdhirsch30345

                Ooh!  Shiny!  Can't wait to try it.

                 

                I looked around, but can't find a 2.3.0-SNAPSHOT in downloadable form.  If I were using maven I could just change my pointer, but we are still just using ant.

                 

                Is there a zip file that I can use?  Or tar.gz?  I could have sworn that I'd found one before, but I can't now.  Or maybe I am dreaming.

                 

                Thanks,

                 

                Michael

                • 5. Re: Trouble compiling class with generics in 2.3.0.CR1
                  csa

                  Hi,

                   

                  I attached a distribution zip for the latest 2.3.0-SNAPSHOTs to this message. We have that zip available for the latest stable build but our CI build is already focused on the 3.0 branch which is why you can't find it for 2.3.0.

                   

                  Thanks,

                  Christian

                  • 6. Re: Trouble compiling class with generics in 2.3.0.CR1
                    mdhirsch30345

                    Hi Christian,

                     

                    I'm sorry for taking so long, but we had a big release to get out the door and I've had no time the last few weekes.

                     

                    Any way, it is out now, so I compiled against the snapshot and the compile issue is gone.  My app also works well and the selenium tests are succeeding, so I have no more issues to report.

                     

                    Thanks for the quick fix.

                     

                    Michael

                    • 7. Re: Trouble compiling class with generics in 2.3.0.CR1
                      nva

                      I'm still getting the compile error on generics with 2.3.0.Final. My last known working version with generics in portable classes is 2.1.1.Final.

                       

                      [INFO]    [ERROR] Errors in '/tmp/com.nvcode-dtt/target/.generated/org/jboss/errai/marshalling/client/api/MarshallerFactoryImpl.java'
                      [INFO]       [ERROR] Line 4104:  T cannot be resolved to a type

                       

                      Cheers,

                       

                      V.

                      • 8. Re: Trouble compiling class with generics in 2.3.0.CR1
                        jfuerth

                        Hi Valentin,

                         

                        Looks like we missed a case.

                         

                        Can you provide the code from the @Portable type that causes this problem? We'll try to get this fixed in the 3.0 branch.

                         

                        -Jonathan

                        • 9. Re: Trouble compiling class with generics in 2.3.0.CR1
                          nva

                          Hi Jonathan,

                           

                          sample code:

                           

                          @Portable
                          public class TestDTO<T> {

                            
                              private Long n;
                              private List<T> data;


                              public TestDTO(@MapsTo("n") Long nrItems,
                                                     @MapsTo("data") List<T> data) {

                           

                                  this.n = nrItems;
                                  this.data = data;
                              }

                           

                              public Long getNrItems() {

                           

                                  return n;
                              }

                           

                              public List<T> getData() {

                           

                                  return data;
                              }
                          }

                           

                          Cheers,

                           

                          V.

                          • 10. Re: Trouble compiling class with generics in 2.3.0.CR1
                            jfuerth

                            Hi Valentin,

                             

                            I tried adding this class to our test suite on the master branch (working towards Errai 3.0), and it works. There is already a very similar case which has been around for over a year (and was definitely included in the test suite we ran as part of the Errai 2.3.0 releases):

                             

                            https://github.com/errai/errai/blob/master/errai-bus/src/test/java/org/jboss/errai/bus/client/tests/support/GenericEntity.java

                             

                            As you can see, this type has a parameter <T> which is referenced in its property "list" of type List<T>.

                             

                            Are you sure the type parameter is causing the failure? Can you post the generated MarshallerFactoryImpl.java which exhibits this problem? It should be left in the .errai directory after the failed build.

                             

                            -Jonathan

                            • 11. Re: Trouble compiling class with generics in 2.3.0.CR1
                              nva

                              Hi Jonathan,

                               

                              sorry for the late respone. The case looks just like my code. Running a higher version of Errai 2 fails with this message: 'T cannot be resolved to a type' and there is only one portable class that contains generics in our implementation.

                               

                              I'm having a problem compiling with Errai 2.3.0.Final at the moment, it looks like there's an unmet GWT 2.5 dependency. Under Errai 2.2.0.Final I get this error:

                               

                              [INFO] 82. ERROR in /tmp/valentin/errai/e360f0d7cacf4d2bc0ae22a2a61972cf63dadce1/errai.marshalling/gen/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl.java (at line 4790)
                              [INFO]  final List<T> c1 = java_util_List.demarshall(obj.get("data"), a1);
                              [INFO]             ^
                              [INFO] T cannot be resolved to a type

                               

                              Corresponding MarshallerFactoryImpl: http://pastebin.com/M5ajCZ1N

                              Corresponding ServerMarshallerFactoryImpl: http://pastebin.com/MWYzsJfw

                               

                              I need look into the Errai 2.3.0 compilation problem. I'm sure it worked before. We're still on GWT 2.4, unfortunately (other dependencies prevented the move so far).

                               

                              Errai 2.1.1.Final compiles and works perfectly.

                               

                              Many thanks!

                               

                              Cheers,

                               

                              V.

                              • 12. Re: Trouble compiling class with generics in 2.3.0.CR1
                                nva

                                Resolved the GWT 2.5 dependencies, am using GWT 2.5.1 and Errai 2.3.0.Final. The compiler stops with the generics error:

                                 

                                [INFO] 82. ERROR in /tmp/valentin/errai/25efe9683d3f8af0af2940a4376bcf89ad8/errai.marshalling/gen/org/jboss/errai/marshalling/server/impl/ServerMarshallingFactoryImpl.java (at line 4237)
                                [INFO]  final List<T> c1 = java_util_List.demarshall(obj.get("data"), a1);
                                [INFO]             ^
                                [INFO] T cannot be resolved to a type

                                 

                                (Same portable class as in my earlier post.)

                                 

                                Corresponding ServerMarshallerFactoryImpl: http://pastebin.com/hkve64AP

                                 

                                Please let me know what else you need, I'm very keen on getting to the bottom of this problem.

                                 

                                Cheers,

                                 

                                V.

                                • 13. Re: Trouble compiling class with generics in 2.3.0.CR1
                                  csa

                                  Hi Valentin,

                                   

                                  We fixed this problem now and published new 2.3.1-SNAPSHOTs. Can you try with the latest snapshots? We plan to release 2.3.1.Final tomorrow afternoon.

                                   

                                  Thanks,

                                  Christian

                                  • 14. Re: Trouble compiling class with generics in 2.3.0.CR1
                                    nva

                                    Hello Christian,

                                     

                                    thanks! It looks like it's working, the marshallers have been generated without any problems. I still have other, GWT 2.5 and GWTP related compiler errors and couldn't build my project yet. However, it's definitely gone much further on 2.3.1-SNAPSHOT than on 2.3.0.Final yesterday. Will report back as soon as I have a fully working build. I think the time zones work to our advantage.

                                     

                                    Cheers,

                                     

                                    V.

                                    1 2 Previous Next