QDox

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

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: