Reflecting on private static method
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Reflecting on private static method

  1. #1
    Join Date
    Nov 2006
    Posts
    357

    Reflecting on private static method

    Hey,

    First of all this is not some normal action I would want to do, however this fringe case involves alot of legacy code I cannot touch, and unit tests that need to be written for newer stuff.

    Anyway I have a class and i can get access to all fields and methods through reflection, except private/protected static ones. So is there any way to get access to a private static method through reflection?

  2. #2
    Join Date
    Apr 2007
    Posts
    442

    Re: Reflecting on private static method

    As I recall anything is accessible through reflection, such a horrendous practise, check that tutorial for examples.

    http://tutorials.jenkov.com/java-reflection/fields.html

  3. #3
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: Reflecting on private static method

    The Class classes getDeclaredMethods() returns all methods of this class including private methods but does not return inherited methods.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center