Index: src/java/javax/jdo/JDOHelper.java =================================================================== --- src/java/javax/jdo/JDOHelper.java (revision 488371) +++ src/java/javax/jdo/JDOHelper.java (working copy) @@ -86,6 +86,27 @@ } ); + /** The singleton instance of JDOHelper. + * @since 2.1 + */ + private static JDOHelper instance = new JDOHelper(); + + /** + * Return the singleton instance of JDOHelper. This instance is + * thread-safe. + * @since 2.1 + * @return the thread-safe singleton JDOHelper + */ + public static JDOHelper getInstance() { + return instance; + } + + /** Some applications might prefer to use instance + * methods instead of static methods. + * @since 2.1 + */ + public JDOHelper() {} + /** The stateless instance used for handling non-binary-compatible * implementations of getPersistenceManager. */ Index: test/java/javax/jdo/JDOHelperTest.java =================================================================== --- test/java/javax/jdo/JDOHelperTest.java (revision 488371) +++ test/java/javax/jdo/JDOHelperTest.java (working copy) @@ -45,6 +45,64 @@ BatchTestRunner.run(JDOHelperTest.class); } + /** The purpose of this test is simply to call some of the + * methods on a constructed instance of JDOHelper and verify that + * they do not throw exceptions. It is not a functional test. + * @since 2.1 + */ + public void testConstructor() { + JDOHelper helper = new JDOHelper(); + assertNull("getObjectId(null) returned non-null", + helper.getObjectId(null)); + assertNull("getPersistenceManager(null) returned non-null", + helper.getPersistenceManager(null)); + assertNull("getTransactionalObjectId(null) returned non-null", + helper.getTransactionalObjectId(null)); + assertNull("getVersion(null) returned non-null", + helper.getVersion(null)); + assertFalse("isDeleted(null) returned non-null", + helper.isDeleted(null)); + assertFalse("isDetached(null) returned non-null", + helper.isDetached(null)); + assertFalse("isDirty(null) returned non-null", + helper.isDirty(null)); + assertFalse("isNew(null) returned non-null", + helper.isNew(null)); + assertFalse("isPersistent(null) returned non-null", + helper.isPersistent(null)); + assertFalse("isTransactional(null) returned non-null", + helper.isTransactional(null)); + } + + /** The purpose of this test is simply to call some of the + * methods on the static instance of JDOHelper and verify that + * they do not throw exceptions. It is not a functional test. + * @since 2.1 + */ + public void testGetInstance() { + JDOHelper helper = JDOHelper.getInstance(); + assertNull("getObjectId(null) returned non-null", + helper.getObjectId(null)); + assertNull("getPersistenceManager(null) returned non-null", + helper.getPersistenceManager(null)); + assertNull("getTransactionalObjectId(null) returned non-null", + helper.getTransactionalObjectId(null)); + assertNull("getVersion(null) returned non-null", + helper.getVersion(null)); + assertFalse("isDeleted(null) returned non-null", + helper.isDeleted(null)); + assertFalse("isDetached(null) returned non-null", + helper.isDetached(null)); + assertFalse("isDirty(null) returned non-null", + helper.isDirty(null)); + assertFalse("isNew(null) returned non-null", + helper.isNew(null)); + assertFalse("isPersistent(null) returned non-null", + helper.isPersistent(null)); + assertFalse("isTransactional(null) returned non-null", + helper.isTransactional(null)); + } + /** */ public void testGetPM() { PCPoint p = new PCPoint(1, new Integer(1));