Customizing ikvm itself...

View: New views
4 Messages — Rating Filter:   Alert me  

Customizing ikvm itself...

by Jesse Sightler-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is there an easy way to customize some of the pieces of ikvm without
having to recompile all of it (particularly the openjdk dll)?  I have
some issues with the awt implementation that I need to work around,
including some nasty things that should never be distributed.

With ancient versions (non-strong-named) I could just recompile
IKVM.AWT.WinForms, however, now doing that yields an error like the
following:
System.IO.FileLoadException: A strongly-named assembly is required.

It seems that I can't easily recompile without strong-names, but I'd
have to recompile everything to use them.

Is there a simple way to do this?

Thanks,
Jess

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Ikvm-developers mailing list
Ikvm-developers@...
https://lists.sourceforge.net/lists/listinfo/ikvm-developers

Re: Customizing ikvm itself...

by Jeroen Frijters :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In general this is a somewhat annoying problem (when I first started strong naming the assemblies I did consider whether I should distribute the private key or not, but ultimately decided against it because some people might want to use strong names as a security feature).

However, for IKVM.AWT.WinForms specifically there is a fairly easy way to replace it. If you set the awt.toolkit system property to another assembly qualified .NET typename, that type will get loaded instead of the default one (the default one is loaded in exactly the same way, literally the only difference is that the default name is baked into the system properties initialization code.)

So, you build your own IKVM.AWT.WinForms.Custom.dll and then in you app.config you set:

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="ikvm:awt.toolkit" value="ikvm.awt.NetToolkit, IKVM.AWT.WinForms.Custom" />
  </appSettings>
</configuration>

If you strong name you IKVM.AWT.WinForms.Custom.dll, you should include the full assembly name.

Of course, if you have fixes/additions that you think might be valuable to others, please consider contributing them :-)

Regards,
Jeroen

> -----Original Message-----
> From: ikvm-developers-bounces@... [mailto:ikvm-
> developers-bounces@...] On Behalf Of Jesse Sightler
> Sent: Tuesday, May 06, 2008 21:46
> To: ikvm-developers@...
> Subject: [Ikvm-developers] Customizing ikvm itself...
>
> Is there an easy way to customize some of the pieces of ikvm without
> having to recompile all of it (particularly the openjdk dll)?  I have
> some issues with the awt implementation that I need to work around,
> including some nasty things that should never be distributed.
>
> With ancient versions (non-strong-named) I could just recompile
> IKVM.AWT.WinForms, however, now doing that yields an error like the
> following:
> System.IO.FileLoadException: A strongly-named assembly is required.
>
> It seems that I can't easily recompile without strong-names, but I'd
> have to recompile everything to use them.
>
> Is there a simple way to do this?
>
> Thanks,
> Jess
>
> -----------------------------------------------------------------------
> --
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't
> miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/
> javaone
> _______________________________________________
> Ikvm-developers mailing list
> Ikvm-developers@...
> https://lists.sourceforge.net/lists/listinfo/ikvm-developers

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Ikvm-developers mailing list
Ikvm-developers@...
https://lists.sourceforge.net/lists/listinfo/ikvm-developers

Re: Customizing ikvm itself...

by Jesse Sightler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jeroen,

Thanks for the explanation.  In the end, I was able to figure out how
to compile the whole thing myself, only to find that the real problem
was the caller was creating Arc2D.Double objects with negative values.
 Apparently in openjdk that works all the time, and in GNU ClassPath
it broke in a case where I needed it.

All of the main fixes that we put in have apparently been fixed within
IKVM since the version that we were using before.  The only remaining
issue that I saw was that NetGraphics.rotate assumes that both the
Java and the .Net platform define things using Degrees.  But the Java
API actually uses Radians... so I needed to convert them:

        public override void rotate(double theta)
        {
            Matrix transform = g.Transform;
            float thetaDegrees = (float)ConvertRadiansToDegrees(theta);
            transform.Rotate(thetaDegrees);
            g.Transform = transform;
        }

        private double ConvertRadiansToDegrees(double radians)
        {
            return (180 / Math.PI) * radians;
        }

        public override void rotate(double theta, double x, double y)
        {
            Matrix transform = g.Transform;
            transform.Translate((float)x, (float)y);
            float thetaDegrees = (float)ConvertRadiansToDegrees(theta);
            transform.Rotate(thetaDegrees);
            transform.Translate(-(float)x, -(float)y);
            g.Transform = transform;
        }

Thanks,
Jess


On 5/7/08, Jeroen Frijters <jeroen@...> wrote:

> In general this is a somewhat annoying problem (when I first started strong naming the assemblies I did consider whether I should distribute the private key or not, but ultimately decided against it because some people might want to use strong names as a security feature).
>
>  However, for IKVM.AWT.WinForms specifically there is a fairly easy way to replace it. If you set the awt.toolkit system property to another assembly qualified .NET typename, that type will get loaded instead of the default one (the default one is loaded in exactly the same way, literally the only difference is that the default name is baked into the system properties initialization code.)
>
>  So, you build your own IKVM.AWT.WinForms.Custom.dll and then in you app.config you set:
>
>  <?xml version="1.0"?>
>  <configuration>
>   <appSettings>
>     <add key="ikvm:awt.toolkit" value="ikvm.awt.NetToolkit, IKVM.AWT.WinForms.Custom" />
>   </appSettings>
>  </configuration>
>
>  If you strong name you IKVM.AWT.WinForms.Custom.dll, you should include the full assembly name.
>
>  Of course, if you have fixes/additions that you think might be valuable to others, please consider contributing them :-)
>
>  Regards,
>  Jeroen
>
>
>  > -----Original Message-----
>  > From: ikvm-developers-bounces@... [mailto:ikvm-
>  > developers-bounces@...] On Behalf Of Jesse Sightler
>  > Sent: Tuesday, May 06, 2008 21:46
>  > To: ikvm-developers@...
>  > Subject: [Ikvm-developers] Customizing ikvm itself...
>  >
>  > Is there an easy way to customize some of the pieces of ikvm without
>  > having to recompile all of it (particularly the openjdk dll)?  I have
>  > some issues with the awt implementation that I need to work around,
>  > including some nasty things that should never be distributed.
>  >
>  > With ancient versions (non-strong-named) I could just recompile
>  > IKVM.AWT.WinForms, however, now doing that yields an error like the
>  > following:
>  > System.IO.FileLoadException: A strongly-named assembly is required.
>  >
>  > It seems that I can't easily recompile without strong-names, but I'd
>  > have to recompile everything to use them.
>  >
>  > Is there a simple way to do this?
>  >
>  > Thanks,
>  > Jess
>  >
>
> > -----------------------------------------------------------------------
>  > --
>  > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't
>  > miss this year's exciting event. There's still time to save $100.
>  > Use priority code J8TL2D2.
>  > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/
>  > javaone
>  > _______________________________________________
>  > Ikvm-developers mailing list
>  > Ikvm-developers@...
>  > https://lists.sourceforge.net/lists/listinfo/ikvm-developers
>
>  -------------------------------------------------------------------------
>  This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>  Don't miss this year's exciting event. There's still time to save $100.
>  Use priority code J8TL2D2.
>  http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>  _______________________________________________
>  Ikvm-developers mailing list
>  Ikvm-developers@...
>  https://lists.sourceforge.net/lists/listinfo/ikvm-developers
>

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Ikvm-developers mailing list
Ikvm-developers@...
https://lists.sourceforge.net/lists/listinfo/ikvm-developers

Re: Customizing ikvm itself...

by Jeroen Frijters :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, I will incorporate the rad/deg fix.

Regards,
Jeroen

> -----Original Message-----
> From: Jesse Sightler [mailto:jsight@...]
> Sent: Wednesday, May 07, 2008 18:58
> To: Jeroen Frijters
> Cc: ikvm-developers@...
> Subject: Re: [Ikvm-developers] Customizing ikvm itself...
>
> Hi Jeroen,
>
> Thanks for the explanation.  In the end, I was able to figure out how
> to compile the whole thing myself, only to find that the real problem
> was the caller was creating Arc2D.Double objects with negative values.
>  Apparently in openjdk that works all the time, and in GNU ClassPath it
> broke in a case where I needed it.
>
> All of the main fixes that we put in have apparently been fixed within
> IKVM since the version that we were using before.  The only remaining
> issue that I saw was that NetGraphics.rotate assumes that both the Java
> and the .Net platform define things using Degrees.  But the Java API
> actually uses Radians... so I needed to convert them:
>
>         public override void rotate(double theta)
>         {
>             Matrix transform = g.Transform;
>             float thetaDegrees = (float)ConvertRadiansToDegrees(theta);
>             transform.Rotate(thetaDegrees);
>             g.Transform = transform;
>         }
>
>         private double ConvertRadiansToDegrees(double radians)
>         {
>             return (180 / Math.PI) * radians;
>         }
>
>         public override void rotate(double theta, double x, double y)
>         {
>             Matrix transform = g.Transform;
>             transform.Translate((float)x, (float)y);
>             float thetaDegrees = (float)ConvertRadiansToDegrees(theta);
>             transform.Rotate(thetaDegrees);
>             transform.Translate(-(float)x, -(float)y);
>             g.Transform = transform;
>         }
>
> Thanks,
> Jess
>
>
> On 5/7/08, Jeroen Frijters <jeroen@...> wrote:
> > In general this is a somewhat annoying problem (when I first started
> strong naming the assemblies I did consider whether I should distribute
> the private key or not, but ultimately decided against it because some
> people might want to use strong names as a security feature).
> >
> >  However, for IKVM.AWT.WinForms specifically there is a fairly easy
> > way to replace it. If you set the awt.toolkit system property to
> > another assembly qualified .NET typename, that type will get loaded
> > instead of the default one (the default one is loaded in exactly the
> > same way, literally the only difference is that the default name is
> > baked into the system properties initialization code.)
> >
> >  So, you build your own IKVM.AWT.WinForms.Custom.dll and then in you
> app.config you set:
> >
> >  <?xml version="1.0"?>
> >  <configuration>
> >   <appSettings>
> >     <add key="ikvm:awt.toolkit" value="ikvm.awt.NetToolkit,
> IKVM.AWT.WinForms.Custom" />
> >   </appSettings>
> >  </configuration>
> >
> >  If you strong name you IKVM.AWT.WinForms.Custom.dll, you should
> include the full assembly name.
> >
> >  Of course, if you have fixes/additions that you think might be
> > valuable to others, please consider contributing them :-)
> >
> >  Regards,
> >  Jeroen
> >
> >
> >  > -----Original Message-----
> >  > From: ikvm-developers-bounces@... [mailto:ikvm-
> > > developers-bounces@...] On Behalf Of Jesse
> > Sightler  > Sent: Tuesday, May 06, 2008 21:46  > To:
> > ikvm-developers@...
> >  > Subject: [Ikvm-developers] Customizing ikvm itself...
> >  >
> >  > Is there an easy way to customize some of the pieces of ikvm
> > without  > having to recompile all of it (particularly the openjdk
> > dll)?  I have  > some issues with the awt implementation that I need
> > to work around,  > including some nasty things that should never be
> distributed.
> >  >
> >  > With ancient versions (non-strong-named) I could just recompile  >
> > IKVM.AWT.WinForms, however, now doing that yields an error like the
> >
> > following:
> >  > System.IO.FileLoadException: A strongly-named assembly is
> required.
> >  >
> >  > It seems that I can't easily recompile without strong-names, but
> > I'd  > have to recompile everything to use them.
> >  >
> >  > Is there a simple way to do this?
> >  >
> >  > Thanks,
> >  > Jess
> >  >
> >
> > > -------------------------------------------------------------------
> -
> > > ---
> >  > --
> >  > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> > Don't  > miss this year's exciting event. There's still time to save
> $100.
> >  > Use priority code J8TL2D2.
> >  >
> >
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com
> > /
> >  > javaone
> >  > _______________________________________________
> >  > Ikvm-developers mailing list
> >  > Ikvm-developers@...
> >  > https://lists.sourceforge.net/lists/listinfo/ikvm-developers
> >
> >
> > ---------------------------------------------------------------------
> -
> > ---  This SF.net email is sponsored by the 2008 JavaOne(SM)
> Conference
> > Don't miss this year's exciting event. There's still time to save
> $100.
> >  Use priority code J8TL2D2.
> >
> >
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com
> > /javaone  _______________________________________________
> >  Ikvm-developers mailing list
> >  Ikvm-developers@...
> >  https://lists.sourceforge.net/lists/listinfo/ikvm-developers
> >

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Ikvm-developers mailing list
Ikvm-developers@...
https://lists.sourceforge.net/lists/listinfo/ikvm-developers
LightInTheBox - Buy quality products at wholesale price