SF 1699965 toString() which uses toJavaObject() now works for Dispatch objects
This commit is contained in:
@@ -34,6 +34,10 @@
|
|||||||
<td width="13%" valign="top">1699946 </td>
|
<td width="13%" valign="top">1699946 </td>
|
||||||
<td width="87%" valign="top">(pre-release 5) Unrecognized event callback id leaves thread attached to VM when ComFailException is thrown.</td>
|
<td width="87%" valign="top">(pre-release 5) Unrecognized event callback id leaves thread attached to VM when ComFailException is thrown.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td width="13%" valign="top">1699965 </td>
|
||||||
|
<td width="87%" valign="top">(pre-release 5) toJavaObject() fails for Dispatch because getDispatchRef() called instead of getDispatch().</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="13%" valign="top"> </td>
|
<td width="13%" valign="top"> </td>
|
||||||
<td width="87%" valign="top"> </td>
|
<td width="87%" valign="top"> </td>
|
||||||
|
|||||||
@@ -525,7 +525,10 @@ public class Variant extends JacobObject {
|
|||||||
/**
|
/**
|
||||||
* @return the content of this variant as a Dispatch object (after possible conversion)
|
* @return the content of this variant as a Dispatch object (after possible conversion)
|
||||||
*/
|
*/
|
||||||
public Dispatch toDispatch(){ return toVariantDispatch(); }
|
public Dispatch toDispatch(){
|
||||||
|
// now make the native call
|
||||||
|
return toVariantDispatch();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* native method used by toDispatch()
|
* native method used by toDispatch()
|
||||||
@@ -698,15 +701,19 @@ public class Variant extends JacobObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* same as {@link #toDispatch()}
|
* cover for {@link #toDispatch()}
|
||||||
* This is different than the other get methods.
|
* This method now matches other getXXX() methods. It throws an IllegalStateException
|
||||||
* It calls toDispatch which will do type conversion.
|
* if the object is not of type VariantDispatch
|
||||||
* Most getXXX() methods will return null if the data is not of
|
* @return this object as a dispatch
|
||||||
* the requested type
|
* @throws IllegalStateException if wrong variant type
|
||||||
* @return this object as a dispatch (Why isn't this typed as type Dispatch?)
|
|
||||||
*/
|
*/
|
||||||
public Dispatch getDispatch() {
|
public Dispatch getDispatch() {
|
||||||
|
if ((this.getvt() & VariantDispatch) == VariantDispatch) {
|
||||||
return toDispatch();
|
return toDispatch();
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"getDispatch() only legal on Variants of type VariantDispatch, not "+this.getvt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1282,14 +1289,14 @@ public class Variant extends JacobObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatch and dispatchRef are treated the same
|
* Dispatch and dispatchRef are treated the same
|
||||||
* This is just a cover for getDispatch() with a flag check
|
* This is just a cover for toDispatch() with a flag check
|
||||||
* @return the results of getDispatch()
|
* @return the results of toDispatch()
|
||||||
* @throws IllegalStateException if variant is not of the requested type
|
* @throws IllegalStateException if variant is not of the requested type
|
||||||
*/
|
*/
|
||||||
public Dispatch getDispatchRef() {
|
public Dispatch getDispatchRef() {
|
||||||
if ((this.getvt() & VariantDispatch) == VariantDispatch &&
|
if ((this.getvt() & VariantDispatch) == VariantDispatch &&
|
||||||
(this.getvt() & VariantByref) == VariantByref) {
|
(this.getvt() & VariantByref) == VariantByref) {
|
||||||
return getDispatch();
|
return toDispatch();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"getDispatchRef() only legal on byRef Variants of type VariantDispatch, not "+this.getvt());
|
"getDispatchRef() only legal on byRef Variants of type VariantDispatch, not "+this.getvt());
|
||||||
@@ -1686,7 +1693,10 @@ public class Variant extends JacobObject {
|
|||||||
result = this.getStringRef();
|
result = this.getStringRef();
|
||||||
break;
|
break;
|
||||||
case Variant.VariantDispatch : //9
|
case Variant.VariantDispatch : //9
|
||||||
result = this.getDispatchRef();
|
result = this.getDispatch();
|
||||||
|
break;
|
||||||
|
case Variant.VariantDispatch | Variant.VariantByref: //9
|
||||||
|
result = this.getDispatchRef(); // Can dispatches even be byRef?
|
||||||
break;
|
break;
|
||||||
case Variant.VariantError : //10
|
case Variant.VariantError : //10
|
||||||
result = new NotImplementedException("toJavaObject() Not implemented for VariantError");
|
result = new NotImplementedException("toJavaObject() Not implemented for VariantError");
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ class VariantTest {
|
|||||||
testJig.testObjectIsAConstant();
|
testJig.testObjectIsAConstant();
|
||||||
testJig.testSomeChangeVT();
|
testJig.testSomeChangeVT();
|
||||||
testJig.testByRefToJavaObject();
|
testJig.testByRefToJavaObject();
|
||||||
|
testJig.testDispatchToJavaObject();
|
||||||
|
System.out.println("Starting last test");
|
||||||
testJig.testManyThreadedInit();
|
testJig.testManyThreadedInit();
|
||||||
System.out.println("Testing Complete");
|
System.out.println("Testing Complete");
|
||||||
|
|
||||||
@@ -106,6 +108,18 @@ class VariantTest {
|
|||||||
// need to do currency also
|
// need to do currency also
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 4/2007 bug report toObject on dispatch tries to call getDispatchRef
|
||||||
|
* instead of getDispatch so toString() on dispatch blows up.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void testDispatchToJavaObject(){
|
||||||
|
Variant v2 = new Variant();
|
||||||
|
v2.putNothing();
|
||||||
|
// this test fails even though the exact same code below works fine
|
||||||
|
//v2.toJavaObject();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* see what happens when we conver to by ref
|
* see what happens when we conver to by ref
|
||||||
*
|
*
|
||||||
@@ -237,7 +251,7 @@ class VariantTest {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void testSafeReleaseConstant(){
|
private void testSafeReleaseConstant(){
|
||||||
System.out.println("Using Static constant Variant - should never throw access violation");
|
//System.out.println("Using Static constant Variant - should never throw access violation");
|
||||||
Variant.VT_TRUE.safeRelease();
|
Variant.VT_TRUE.safeRelease();
|
||||||
if (Variant.VT_TRUE.getBoolean() != true){
|
if (Variant.VT_TRUE.getBoolean() != true){
|
||||||
System.out.println("VT_TRUE has been broken by SafeRelease()");
|
System.out.println("VT_TRUE has been broken by SafeRelease()");
|
||||||
@@ -387,7 +401,10 @@ class VariantTest {
|
|||||||
if (!v2.isNull()){
|
if (!v2.isNull()){
|
||||||
System.out.println("putNothing is supposed to cause isNull() to return true");
|
System.out.println("putNothing is supposed to cause isNull() to return true");
|
||||||
}
|
}
|
||||||
|
// this line blows up in the test above
|
||||||
|
if (v2.toJavaObject() == null){
|
||||||
|
System.out.println("putNothing() followed by toJavaObject() should return a Dispatch");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user