QDox
  1. QDox
  2. QDOX-80

Static initializer block before gets confused with static method

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6
    • Component/s: Parser
    • Labels:
      None
    • Number of attachments :
      0

      Description

      – From Richard Payne –

      I think have noticed a potential bug in version 1.5 (and the latest 1.6
      snapshot) while getting all methods in a particular JavaClass where by a
      JavaMethod incorrectly thinks it is declared as static.

      When there is a static initialisation block immediately before a method
      declaration, the static attribute on the JavaMethod is true. It does not
      seem to matter if the static block is empty of not. Remove the static block
      and it is listed as false.

      I am using jdk 1.4.2.

      Is this a known problem?

      I have included some example code below.

      Thanks,
      Richard Payne.

      My code to list the JavaMethods is...

      boolean searchSuperClasses = true;
      JavaMethod[] javaMethods = javaClass.getMethods(searchSuperClasses);

      for (int i = 0; i < javaMethods.length; i++) {
      JavaMethod javaMethod = javaMethods[i];
      System.out.println("javaMethod [" + i + "]:" + javaMethod
      .getName()
      + "\n\t class:" + javaMethod .getParentClass
      ().getFullyQualifiedName()
      + "\n\t static?" + javaMethod .isStatic() + "
      abstract? " + javaMethod .isAbstract());
      }

      The code that is lists method as a static method...

      static {
      ;
      }
      public ActionForward method() throws Exception {
      return null;
      }

      The code that is lists method as an instance method...

      public ActionForward method() throws Exception {
      return null;
      }

        Activity

        Joe Walnes made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Joe Walnes
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: