RFR: 7148497: javax.management.MBeanAttributeInfo.hashCode throws NullPointerException (original) (raw)

Dmitry Samersoff Dmitry.Samersoff at oracle.com
Wed Apr 11 23🔞39 PDT 2012


Frederic,

I'm second to Staffan.

Looks good to me but would prefer to have it refactored, e.g. create a method equalOrNull();

-Dmitry

On 2012-04-10 18:33, Staffan Larsen wrote:

Looks good! (Although I wish there was a better way to write code like this).

/Staffan On 10 apr 2012, at 15:50, Frederic Parain wrote:

Greetings,

This is a request for review for CR 7148497: javax.management.MBeanAttributeInfo.hashCode throws NullPointerException http://bugs.sun.com/bugdatabase/viewbug.do?bugid=7148497 Even if the initial CR only refers to MBeanAttributeInfo.hashCode(), the problem is not limited to the MBeanAttributeInfo.hashCode(), but is common to all javax.management.MBean*Info classes: MBeanAttributeInfo, MBeanConstructorInfo, MBeanFeatureInfo, MBeanInfo, MBeanNotificationInfo, MBeanOperationInfo and MBeanParameterInfo. The root cause of the problem is that these classes can be instantiated with some null fields (mainly, but not limited to, the name and type fields), and these fields are dereferenced unconditionally in some methods. Unconditional dereferencing is used in the hashCode method but also in the equals() method. The proposed fix improves implementation of equals() and hashCode() method to handle cases where some fields are null without throwing a NPE. Webrev: http://cr.openjdk.java.net/~fparain/7148497/webrev.00/ Thanks, Fred -- Frederic Parain - Oracle Grenoble Engineering Center - France Phone: +33 4 76 18 81 17 Email: Frederic.Parain at oracle.com

-- Dmitry Samersoff Java Hotspot development team, SPB04



More information about the serviceability-dev mailing list