4 Replies Latest reply on May 24, 2016 5:17 PM by hr.stoyanov

    [Errai 4]Errors and warnings from generated java code

    hr.stoyanov

      Hi,

      I am seeing some strange warnings and errors when compiling Errai code. See the attached output. It appears the code generation does not generate perfect code and javac complains with warnings. There are even errors as if Java 8 code was attempted to be compiled with a Java 7 compiler, though I only use jdk8. Interestingly enough, none of this affects the build, but it creates a lot of noise. Any solution? Thanks.

        • 1. Re: [Errai 4]Errors and warnings from generated java code
          mbarkley

          Hi Hristo,

           

          Those errors/warnings are happening while Errai attempts to generate your ServerMarshallerFactoryImpl.class file. Your application will work without that file because Errai also supports dynamic marshalling using reflection, but dynamic marshalling is only meant for development so this is worth fixing.

           

          Errai uses the javax.tools.ToolProvider to load a JavaCompiler. We don't explicitly set the source level anywhere and the default for the JDK 8 javac is 1.8 so I am not sure what is happening. Is it possible you have an old tools.jar somewhere that is being found? You can enable logging for the ToolProvider with the "sun.tools.ToolProvider" system property, which might help you figure out which javac it's loading.

          • 2. Re: [Errai 4]Errors and warnings from generated java code
            hr.stoyanov

            Max,

            1. One easy way to shut up the warnings in the generated sources is to use @SuppressWarnings("all") or any of the other variants.

            2. If you look at line #74 of the output I attached, I explicitly specify -sourceLevel 1.8, which does not help either. I do not have java 7 anywhere, so I am  puzzled why the code generation assumes that

             

            I opened an issue for that:

            [ERRAI-943] Malformed generated java sources - JBoss Issue Tracker

            • 3. Re: [Errai 4]Errors and warnings from generated java code
              mbarkley

              Hristo,

              1. The warnings only print if there is an error generating the class, so it's usually not an issue.
              2. That is setting sourceLevel 1.8 for the GWT compiler. This is a javac compilation error.

              I tried reproducing this with our tutorial by adding portable types with various combinations of default methods but I did not experience any compilation issues. Without your help creating a reproducer that you can share, there isn't much I can do.

              • 4. Re: [Errai 4]Errors and warnings from generated java code
                hr.stoyanov

                Ok, let me try to prepare code example