From d1dca37cf36fb7ddb3bf3f32bcc4d0dc42b95c5a Mon Sep 17 00:00:00 2001 From: clay_shooter Date: Fri, 26 Jul 2013 00:36:12 +0000 Subject: [PATCH] 117 NullPointerException injacob-1.17-M2 --- docs/BuildingJacobFromSource.html | 2 ++ docs/ReleaseNotes.html | 4 +++ src/com/jacob/com/Variant.java | 8 ++++- unittest/com/jacob/com/VariantTest.java | 48 +++++++++++++++++++------ 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/docs/BuildingJacobFromSource.html b/docs/BuildingJacobFromSource.html index 505d90e..efa0c8c 100644 --- a/docs/BuildingJacobFromSource.html +++ b/docs/BuildingJacobFromSource.html @@ -67,6 +67,8 @@ Microsoft Visual C++ 8.0 supports 64 bit builds. so no additional tools are requ

Build Process

The build process is based on ANT. You can run ANT from inside of eclipse or from the command line. +Running from inside eclipse means you don't have any installation, pathing or configuration to do. +You can just open the xml and then "run as ant" on the selected target in the "outline" pane. The ant process is driven off of a configuration file named compilation_tools.properties that describes the locations of the JDK and Microsoft C++ tools. The build.xml file in the root directory contains examples of the contents diff --git a/docs/ReleaseNotes.html b/docs/ReleaseNotes.html index 97d08ed..fee5651 100644 --- a/docs/ReleaseNotes.html +++ b/docs/ReleaseNotes.html @@ -30,6 +30,10 @@ 111 (new numbers) (M3)m_pDispatch is not 0 if not attached + + 117 (new numbers) + (M4) NullPointerException injacob-1.17-M2 +     diff --git a/src/com/jacob/com/Variant.java b/src/com/jacob/com/Variant.java index 6d6280a..ba4bc1c 100644 --- a/src/com/jacob/com/Variant.java +++ b/src/com/jacob/com/Variant.java @@ -2161,6 +2161,8 @@ public class Variant extends JacobObject { *
  • "null" if VariantEmpty, *
  • "null" if VariantError *
  • "null" if VariantNull + *
  • "null" if Variant type didn't convert. This can happen for date + * conversions where the returned value was 0. *
  • the value if we know how to describe one of that type *
  • three question marks if can't convert * @@ -2186,7 +2188,11 @@ public class Variant extends JacobObject { try { Object foo = toJavaObject(); // rely on java objects to do the right thing - return foo.toString(); + if (foo == null) { + return "null"; + } else { + return foo.toString(); + } } catch (NotImplementedException nie) { // some types do not generate a good description yet return "Description not available for type: " + getvt(); diff --git a/unittest/com/jacob/com/VariantTest.java b/unittest/com/jacob/com/VariantTest.java index 4012c1a..6dcedec 100644 --- a/unittest/com/jacob/com/VariantTest.java +++ b/unittest/com/jacob/com/VariantTest.java @@ -253,6 +253,32 @@ public class VariantTest extends BaseTestCase { } } + /** + * Exercise ToString special cases + */ + public void testToStringEmptyValues() { + Variant v; + // create an empty variant + v = new Variant(); + // check date per + v.changeType(Variant.VariantDate); + assertEquals("null", v.toString()); + v.putDate(new Date()); + assertNotNull(v.toString()); + assertFalse("null".equals(v.toString())); + + v.changeType(Variant.VariantInt); + v.putInt(1); + + assertEquals("1", v.toString()); + v.changeType(Variant.VariantEmpty); + assertEquals("null", v.toString()); + v.changeType(Variant.VariantNull); + assertEquals("null", v.toString()); + v.changeType(Variant.VariantError); + assertEquals("null", v.toString()); + } + /** * Verify that booleans can be released. Part of the suite that checks all * types. @@ -465,12 +491,12 @@ public class VariantTest extends BaseTestCase { new BigDecimal(i), v.getDecimal()); v.changeType(Variant.VariantFloat); // now see if a float conversion would work - assertEquals("conversion to float failed " + i, new Float(i), v - .getFloat()); + assertEquals("conversion to float failed " + i, new Float(i), + v.getFloat()); // now convert it back to decimal for reassignment v.changeType(Variant.VariantDecimal); - assertTrue("Failed conversion of type back to Decimal " + i, v - .getvt() == Variant.VariantDecimal); + assertTrue("Failed conversion of type back to Decimal " + i, + v.getvt() == Variant.VariantDecimal); } } @@ -545,9 +571,10 @@ public class VariantTest extends BaseTestCase { .unscaledValue().toString(16) + " scale=: " + modifiedDecimal.scale()); System.out.println("integer piece after rounding with scale 30 is " - + VariantUtilities.roundToMSDecimal( - modifiedDecimal.setScale(30)).unscaledValue().toString( - 16) + " scale=: " + modifiedDecimal.scale()); + + VariantUtilities + .roundToMSDecimal(modifiedDecimal.setScale(30)) + .unscaledValue().toString(16) + " scale=: " + + modifiedDecimal.scale()); try { testVariant.putDecimal(VariantUtilities .roundToMSDecimal(modifiedDecimal.setScale(30))); @@ -568,9 +595,10 @@ public class VariantTest extends BaseTestCase { .unscaledValue().toString(16) + " scale=: " + modifiedDecimal.scale()); System.out.println("integer piece after rounding with scale 30 is " - + VariantUtilities.roundToMSDecimal( - modifiedDecimal.setScale(30)).unscaledValue().toString( - 16) + " scale=: " + modifiedDecimal.scale()); + + VariantUtilities + .roundToMSDecimal(modifiedDecimal.setScale(30)) + .unscaledValue().toString(16) + " scale=: " + + modifiedDecimal.scale()); testVariant.putDecimal(VariantUtilities .roundToMSDecimal(modifiedDecimal.setScale(30))); System.out.println("");