Thrift
  1. Thrift
  2. THRIFT-633

Generated code has @Override annotations which won't compile using Apple's JDK 1.5

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Java - Compiler
    • Labels:
      None
    • Environment:

      Mac OS X Tiger/Leopard JDK 1.5

      Description

      Apple's JDK 1.5 does not recognize @Override annotation. Tests fail with error:

      [javac] /private/var/tmp/thrift-trunk/lib/java/gen-java/thrift/test/ComparableUnion.java:251: method does not override a method from its superclass
      [javac] @Override
      [javac] ^

      1. course.thrift
        0.8 kB
        Rajika Kumarasiri

        Activity

        Hide
        Jake Farrell added a comment -

        Rajika, what IDE are you using thats complaining about the @Override? Have you changed the default java version to be 1.6 within the IDE? Are you able to successfully compile run the generated code?

        Show
        Jake Farrell added a comment - Rajika, what IDE are you using thats complaining about the @Override? Have you changed the default java version to be 1.6 within the IDE? Are you able to successfully compile run the generated code?
        Hide
        Rajika Kumarasiri added a comment -

        IDL. Java code was generated using ./thrift --gen java course.thrift

        Show
        Rajika Kumarasiri added a comment - IDL. Java code was generated using ./thrift --gen java course.thrift
        Hide
        Rajika Kumarasiri added a comment -

        [rajika@localhost ~]$ java -version
        java version "1.6.0_17"
        Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
        Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode)

        Actual issue is, the generated java code contains @Override annotations, which my IDE complains saying "@Override is not allowed when implementing interface method" due to the @Override annotation. I'll attach the idl.

        Rajika
        Rajika

        Show
        Rajika Kumarasiri added a comment - [rajika@localhost ~] $ java -version java version "1.6.0_17" Java(TM) SE Runtime Environment (build 1.6.0_17-b04) Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode) Actual issue is, the generated java code contains @Override annotations, which my IDE complains saying "@Override is not allowed when implementing interface method" due to the @Override annotation. I'll attach the idl. Rajika Rajika
        Hide
        Jake Farrell added a comment -

        Rajika, There is a java5 flag available a generation time which will help you generate java 1.5 compatible code. Can you please attach your idl, error log and java -version output

        Show
        Jake Farrell added a comment - Rajika, There is a java5 flag available a generation time which will help you generate java 1.5 compatible code. Can you please attach your idl, error log and java -version output
        Hide
        Rajika Kumarasiri added a comment - - edited

        I got this when compiling a generated java service for a simple IDL on Linux.

        Environment : Fedora 15, Sun JDK - 1.6.0_17.

        Rajika

        Show
        Rajika Kumarasiri added a comment - - edited I got this when compiling a generated java service for a simple IDL on Linux. Environment : Fedora 15, Sun JDK - 1.6.0_17. Rajika
        Hide
        JCF added a comment -

        Toby, have you tried reproducing this against the trunk? THRIFT-1170 should have take care of this with the new java5 option.

        Show
        JCF added a comment - Toby, have you tried reproducing this against the trunk? THRIFT-1170 should have take care of this with the new java5 option.
        Hide
        Toby Thain added a comment - - edited

        The bug is certainly still there with javac 1.5.0_19 and OS X 10.4.11.

        Another problem under 1.5 is that IOException does not have the constructor used by Thrift code.

        With the annotations removed, and the IOExceptions constructed using the parameter-less constructor, the code for simonsays.thrift appears to build okay:

        1. makefile fragment, thrift 0.6.1
          gen-java/SimonSays.java : simonsays.thrift
          thrift -r --gen java $<
          sed -i.bak -e /@Override/d -e 's/IOException(te)/IOException()/' $@

        It is unfortunate that 1.5 is not supported. Perhaps it should be a separate language target?

        Show
        Toby Thain added a comment - - edited The bug is certainly still there with javac 1.5.0_19 and OS X 10.4.11. Another problem under 1.5 is that IOException does not have the constructor used by Thrift code. With the annotations removed, and the IOExceptions constructed using the parameter-less constructor, the code for simonsays.thrift appears to build okay: makefile fragment, thrift 0.6.1 gen-java/SimonSays.java : simonsays.thrift thrift -r --gen java $< sed -i.bak -e /@Override/d -e 's/IOException(te)/IOException()/' $@ It is unfortunate that 1.5 is not supported. Perhaps it should be a separate language target?
        Hide
        Mathias Herberts added a comment -

        I haven't used JDK 1.5 in a while but I'm guessing the problem is still there.

        Show
        Mathias Herberts added a comment - I haven't used JDK 1.5 in a while but I'm guessing the problem is still there.
        Hide
        Bryan Duxbury added a comment -

        Jake - the latest version of Java is 1.6, and that never shows this problem.

        Show
        Bryan Duxbury added a comment - Jake - the latest version of Java is 1.6, and that never shows this problem.
        Hide
        JCF added a comment -

        Tested on os x using latest version of java provided by apple and had no issues, Mathias are you still having issues with this?

        Show
        JCF added a comment - Tested on os x using latest version of java provided by apple and had no issues, Mathias are you still having issues with this?
        Hide
        Bryan Duxbury added a comment -

        Is this still a problem? I know a lot of things have changed in the last year.

        Show
        Bryan Duxbury added a comment - Is this still a problem? I know a lot of things have changed in the last year.

          People

          • Assignee:
            Jake Farrell
            Reporter:
            Mathias Herberts
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development