Details
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
Field | Original Value | New Value |
---|---|---|
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |