Accessing the FixedRateCoupons and IborCoupons of a Swap from Java

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing the FixedRateCoupons and IborCoupons of a Swap from Java

Henner Heck

Hello all,

after evaluating a VanillaSwap i have access to
the contents of the legs in form of CashFlows.
Actually the fixed leg consists of FixedRateCoupons
and the floating leg consists of IborCoupons,
which both inherit from CashFlow.
I want to gain access to the functions available
in addition to CashFlow.
In C++ one would apply a
"boost::dynamic_pointer_cast<FixedRateCoupon>"
or
"boost::dynamic_pointer_cast<IborCoupon>"
to the CashFlows. Casting the Java object doesn't work,
and trying to abuse the Swig pointer of the CashFlow to
create e.g. an IborCoupon with
"IborCoupon ic = new IborCoupon(CashFlow.getCPtr(cashflow), true);"
actually works, but at some point the whole JVM crashes
with a fatal error:
"# The crash happened outside the Java Virtual Machine in native code."
I suspect that my dual use of the pointer out of Java leads to problems
when collecting the garbage.

Could someone point me in the right direction?


Best regards,
Henner Heck

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the FixedRateCoupons and IborCoupons of a Swap from Java

Henner Heck

FYI,

i solved the problem by adding a static function
which performs the cast to IborCoupon and FixedRateCoupon
and also the cashflows.i of the SWIG files. I also added all
the public functions from these classes and their parents
to the SWIG file to be able to use them from Java.

Is it possible and desired to add such changes to the official QuantLib?

Best regards,
Henner heck




>
> Hello all,
>
> after evaluating a VanillaSwap i have access to
> the contents of the legs in form of CashFlows.
> Actually the fixed leg consists of FixedRateCoupons
> and the floating leg consists of IborCoupons,
> which both inherit from CashFlow.
> I want to gain access to the functions available
> in addition to CashFlow.
> In C++ one would apply a
> "boost::dynamic_pointer_cast<FixedRateCoupon>"
> or
> "boost::dynamic_pointer_cast<IborCoupon>"
> to the CashFlows. Casting the Java object doesn't work,
> and trying to abuse the Swig pointer of the CashFlow to
> create e.g. an IborCoupon with
> "IborCoupon ic = new IborCoupon(CashFlow.getCPtr(cashflow), true);"
> actually works, but at some point the whole JVM crashes
> with a fatal error:
> "# The crash happened outside the Java Virtual Machine in native code."
> I suspect that my dual use of the pointer out of Java leads to problems
> when collecting the garbage.
>
> Could someone point me in the right direction?
>
>
> Best regards,
> Henner Heck

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the FixedRateCoupons and IborCoupons of a Swap from Java

Luigi Ballabio
On Fri, 2010-11-26 at 17:30 +0100, Henner Heck wrote:
> i solved the problem by adding a static function
> which performs the cast to IborCoupon and FixedRateCoupon
> and also the cashflows.i of the SWIG files. I also added all
> the public functions from these classes and their parents
> to the SWIG file to be able to use them from Java.
>
> Is it possible and desired to add such changes to the official QuantLib?

Sure.

Thanks,
        Luigi

--

If I do not want others to quote me, I do not speak.
-- Phil Wayne



------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users