Thrift
  1. Thrift
  2. THRIFT-1465

Visibility of methods in generated java code

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.7, 0.8
    • Fix Version/s: 0.9
    • Component/s: Java - Compiler
    • Labels:
      None

      Description

      Need to resort to reflection to invoke private methods in generated java code.

      1. thrift-1465_1.patch
        3 kB
        Ashutosh Chauhan
      2. thrift-1465.patch
        4 kB
        Ashutosh Chauhan

        Issue Links

          Activity

          Hide
          Ashutosh Chauhan added a comment -

          I work on the Hive project and this problem came up there in context of HIVE-2616. I need to extend the Processor which was generated by thrift compiler on this idl http://svn.apache.org/repos/asf/hive/trunk/metastore/if/hive_metastore.thrift . In my extended Processor https://reviews.apache.org/r/2975/diff/#12 I want to access some of the methods (namely getProcessMap() and getEmptyArgs()) of the super class but can't because they are private. As a workaround I resorted to Reflection. Is it possible to change visibility of these methods ?

          Show
          Ashutosh Chauhan added a comment - I work on the Hive project and this problem came up there in context of HIVE-2616 . I need to extend the Processor which was generated by thrift compiler on this idl http://svn.apache.org/repos/asf/hive/trunk/metastore/if/hive_metastore.thrift . In my extended Processor https://reviews.apache.org/r/2975/diff/#12 I want to access some of the methods (namely getProcessMap() and getEmptyArgs()) of the super class but can't because they are private. As a workaround I resorted to Reflection. Is it possible to change visibility of these methods ?
          Hide
          Bryan Duxbury added a comment -

          I'd commit a patch that modified the visibility of these methods.

          Show
          Bryan Duxbury added a comment - I'd commit a patch that modified the visibility of these methods.
          Hide
          Ashutosh Chauhan added a comment -

          Awesome. Thanks, Bryan!

          Show
          Ashutosh Chauhan added a comment - Awesome. Thanks, Bryan!
          Hide
          Ashutosh Chauhan added a comment -

          Here is my stab at it.

          Show
          Ashutosh Chauhan added a comment - Here is my stab at it.
          Hide
          Bryan Duxbury added a comment -

          Are you sure that those protected methods need to become public? Also, I'd be more comfortable with an accessor method on TBaseProcessor that returns an immutable view of the processMap - we really don't want people to accidentally mess that map up by accessing it directly.

          Show
          Bryan Duxbury added a comment - Are you sure that those protected methods need to become public? Also, I'd be more comfortable with an accessor method on TBaseProcessor that returns an immutable view of the processMap - we really don't want people to accidentally mess that map up by accessing it directly.
          Hide
          Jake Farrell added a comment -

          +1 for your approach Bryan, completely agree

          Show
          Jake Farrell added a comment - +1 for your approach Bryan, completely agree
          Hide
          Ashutosh Chauhan added a comment -

          New patch incorporating Bryan's suggestion of returning immutable view of processMap instead of directly returning it.

          Show
          Ashutosh Chauhan added a comment - New patch incorporating Bryan's suggestion of returning immutable view of processMap instead of directly returning it.
          Hide
          Jake Farrell added a comment -

          Thanks for updating your patch, committed

          Show
          Jake Farrell added a comment - Thanks for updating your patch, committed
          Hide
          Hudson added a comment -

          Integrated in Thrift #397 (See https://builds.apache.org/job/Thrift/397/)
          Thrift-1465:Visibility of methods in generated java code
          Client: java
          Patch: Ashutosh Chauhan

          Changes visibility of processor getProcessMap() and getEmptyArgs() methods

          Show
          Hudson added a comment - Integrated in Thrift #397 (See https://builds.apache.org/job/Thrift/397/ ) Thrift-1465:Visibility of methods in generated java code Client: java Patch: Ashutosh Chauhan Changes visibility of processor getProcessMap() and getEmptyArgs() methods

            People

            • Assignee:
              Ashutosh Chauhan
              Reporter:
              Ashutosh Chauhan
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development