Language change: Class method to get pointer to method

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P5
    • None
    • Affects Version/s: 6
    • Component/s: specification
    • x86
    • windows_vista

      A DESCRIPTION OF THE REQUEST :
      It would be very useful if Java supported a method in Class that allowed one to get a pointer to a method without using a String for the name:

        Class<X> cls = X.class;
        Method meth = cls.getMethod(getColor);

      This could then be compile-time checked to see that the method 'getColor' actually exists for the class X.

      The example that I have is as follows: my application uses 'DataAccessor' objects to contain things stored in the database. A Person object might have methods 'getFirstName', 'getLastName', 'getPhone', etc.

      I have a SortTable class that can display collections of DataAccessors given a List<String> of method names. I would like the compiler to tell me that I misspelled 'getFristName', instead of waiting until runtime to give me a NoSuchMethodException.

      JUSTIFICATION :
      See above

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      See above

            Assignee:
            Alex Buckley
            Reporter:
            Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: