Apache
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists Apache

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old July 2nd, 2008, 09:31 PM
Seba
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Possible bug or strange behavior

Hi
This is the first time I'm writing to a list, so I'm not sure whether this
should be sent to DevList or UserList. Sorry if I'm sending this to the
wrong list.
I'm using 1.7.0 version of commons-beanutils. The possible bug (or issue)
I've found is in lines 416 to 418 of class MethodUtils when I'm evaluating
an Enum's constant-specific method, which overrides an abstract one.
Those lines are the following:

415: // If the declaring class is public, we are done
416: Class clazz = method.getDeclaringClass();
417: if (Modifier.isPublic(clazz.getModifiers())) {
418: return (method);
419: }

Since every constant of the Enum is compiled as a separate anonymous class
extending the Enum, evaluating its modifiers doesn't return public, which
causes the above return to be skipped.
My question is: should the above code be modified to consider that
particular case? Because the method is actually public and it's declaring
class (the constant, actually) too.

Here I show the code for testing this behavior:


The enum:

public enum SomeEnum {
CNSTANT1 {
public String getLabel() {
return "a";
}
},
CNSTANT2 {
public String getLabel() {
return "b";
}
};
public abstract String getLabel();
}


The test class:

public class TestEnum {

public static void main(String[] args) {
SomeEnum a = SomeEnum.CNSTANT1;
Method[] methods = a.getClass().getMethods();
System.out.println(a.getClass());
for (int i = 0; i < methods.length; i++) {
Method method = methods[i];
System.out.println(method.getName() + " - " +
evaluateMethod(method));
}
}

private static boolean evaluateMethod(Method method) {
return Modifier.isPublic(method.getDeclaringClass().getMo difiers());
}

Reply With Quote
  #2  
Old July 4th, 2008, 12:01 PM
Seba
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Possible bug or strange behavior

Hi
This is the first time I'm writing to a list, so I'm not sure whether this
should be sent to DevList or UserList. Sorry if I'm sending this to the
wrong list.
I'm using 1.7.0 version of commons-beanutils. The possible bug (or issue)
I've found is in lines 416 to 418 of class MethodUtils when I'm evaluating
an Enum's constant-specific method, which overrides an abstract one.
Those lines are the following:

415: // If the declaring class is public, we are done
416: Class clazz = method.getDeclaringClass();
417: if (Modifier.isPublic(clazz.getModifiers())) {
418: return (method);
419: }

Since every constant of the Enum is compiled as a separate anonymous class
extending the Enum, evaluating its modifiers doesn't return public, which
causes the above return to be skipped.
My question is: should the above code be modified to consider that
particular case? Because the method is actually public and it's declaring
class (the constant, actually) too.

Here I show the code for testing this behavior:


The enum:

public enum SomeEnum {
CNSTANT1 {
public String getLabel() {
return "a";
}
},
CNSTANT2 {
public String getLabel() {
return "b";
}
};
public abstract String getLabel();
}


The test class:

public class TestEnum {

public static void main(String[] args) {
SomeEnum a = SomeEnum.CNSTANT1;
Method[] methods = a.getClass().getMethods();
System.out.println(a.getClass());
for (int i = 0; i < methods.length; i++) {
Method method = methods[i];
System.out.println(method.getName() + " - " +
evaluateMethod(method));
}
}

private static boolean evaluateMethod(Method method) {
return Modifier.isPublic(method.getDeclaringClass().getMo difiers());
}

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists Apache > Possible bug or strange behavior


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway