Fwd: Properties in .NET

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

Parent Message unknown Fwd: Properties in .NET

by Antoine Malliarakis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello all,

We're currently using your API (well the 0.40.0.1 version) to share our java model with .NET software (I know, that's the point of your API...) and we've come to try to use our java classes directly into DataSource objects.
The thing is DataSource bindings in .NET seem to use the .NET "Property" principle only and in the IKVM process the only annotation I found was the "ikvm.lang.Property" one.

BUT this annotation has a slight restriction which prevent me from using it : it only applies to fields and uses the attached fields visibility to define the visibility of the generated .NET property (well if the field is private the property shall be private).

Would there be a way to be able to define the visibility of the generated property (which would avoid me having to define public fields in my classes) ?

Thanks for your help & patience

Best Regards

Antoine Malliarakis



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ikvm-developers mailing list
Ikvm-developers@...
https://lists.sourceforge.net/lists/listinfo/ikvm-developers

Re: Fwd: Properties in .NET

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It's not clear to me: are you prepared to design your Java classes to present an interface optimized for .NET users? Or do you want to use your Java classes "as is"?
 
In my situation, I found it best to write a C# wrapper around the Java interface in order to create an interface that looks like it was designed for .NET. It's then no problem to implement properties that are backed by Java getters and setters.
 
Michael Kay
Saxonica


From: Antoine Malliarakis [mailto:antoine.malliarakis@...]
Sent: 29 October 2009 11:10
To: ikvm-developers@...
Subject: [Ikvm-developers] Fwd: Properties in .NET


Hello all,

We're currently using your API (well the 0.40.0.1 version) to share our java model with .NET software (I know, that's the point of your API...) and we've come to try to use our java classes directly into DataSource objects.
The thing is DataSource bindings in .NET seem to use the .NET "Property" principle only and in the IKVM process the only annotation I found was the "ikvm.lang.Property" one.

BUT this annotation has a slight restriction which prevent me from using it : it only applies to fields and uses the attached fields visibility to define the visibility of the generated .NET property (well if the field is private the property shall be private).

Would there be a way to be able to define the visibility of the generated property (which would avoid me having to define public fields in my classes) ?

Thanks for your help & patience

Best Regards

Antoine Malliarakis



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ikvm-developers mailing list
Ikvm-developers@...
https://lists.sourceforge.net/lists/listinfo/ikvm-developers

Re: Fwd: Properties in .NET

by Jeroen Frijters :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Antoine,

You're not really defining a public field. The field is only a placeholder for the property. You still need a real field to store the value.

BTW, another option is to map your get/set methods to a propery with an xml file. Suppose you have this class:

public class test
{
  public int getFoo() { return 42; }
  public void setFoo(int value) { }
}

Then you can use this file map.xml:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<assembly>
<class name="test">
<property name="Foo" sig="()I">
<getter name="getFoo" sig="()I" />
<setter name="setFoo" sig="(I)V" />
</property>
</class>
</assembly>
</root>

With "ikvmc -remap:map.xml test.class" this will add the Foo property to the test class.

Regards,
Jeroen

> -----Original Message-----
> From: Antoine Malliarakis [mailto:antoine.malliarakis@...]
> Sent: Thursday, October 29, 2009 12:10 PM
> To: ikvm-developers@...
> Subject: [Ikvm-developers] Fwd: Properties in .NET
>
>
> Hello all,
>
> We're currently using your API (well the 0.40.0.1 version) to share our
> java model with .NET software (I know, that's the point of your API...)
> and we've come to try to use our java classes directly into DataSource
> objects.
> The thing is DataSource bindings in .NET seem to use the .NET
> "Property" principle only and in the IKVM process the only annotation I
> found was the "ikvm.lang.Property" one.
>
> BUT this annotation has a slight restriction which prevent me from
> using it : it only applies to fields and uses the attached fields
> visibility to define the visibility of the generated .NET property
> (well if the field is private the property shall be private).
>
> Would there be a way to be able to define the visibility of the
> generated property (which would avoid me having to define public fields
> in my classes) ?
>
> Thanks for your help & patience
>
> Best Regards
>
> Antoine Malliarakis
>
>


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ikvm-developers mailing list
Ikvm-developers@...
https://lists.sourceforge.net/lists/listinfo/ikvm-developers

Re: Fwd: Properties in .NET

by Antoine Malliarakis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Jeroen (& Michael & all the others as well),

I believe the xml file solution would perfectly suit my needs.

In fact to tell you the truth the java classes are supposed to be handled both in Java only & in .NET environment so the design ".NET" only would not really be an option.

But the mapping process seems perfect so I'm on it now.

Thanks for your quick replies.

Best regards

Antoine

2009/10/29 Jeroen Frijters <jeroen@...>
Hello Antoine,

You're not really defining a public field. The field is only a placeholder for the property. You still need a real field to store the value.

BTW, another option is to map your get/set methods to a propery with an xml file. Suppose you have this class:

public class test
{
 public int getFoo() { return 42; }
 public void setFoo(int value) { }
}

Then you can use this file map.xml:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<assembly>
<class name="test">
<property name="Foo" sig="()I">
<getter name="getFoo" sig="()I" />
<setter name="setFoo" sig="(I)V" />
</property>
</class>
</assembly>
</root>

With "ikvmc -remap:map.xml test.class" this will add the Foo property to the test class.

Regards,
Jeroen

> -----Original Message-----
> From: Antoine Malliarakis [mailto:antoine.malliarakis@...]
> Sent: Thursday, October 29, 2009 12:10 PM
> To: ikvm-developers@...
> Subject: [Ikvm-developers] Fwd: Properties in .NET
>
>
> Hello all,
>
> We're currently using your API (well the 0.40.0.1 version) to share our
> java model with .NET software (I know, that's the point of your API...)
> and we've come to try to use our java classes directly into DataSource
> objects.
> The thing is DataSource bindings in .NET seem to use the .NET
> "Property" principle only and in the IKVM process the only annotation I
> found was the "ikvm.lang.Property" one.
>
> BUT this annotation has a slight restriction which prevent me from
> using it : it only applies to fields and uses the attached fields
> visibility to define the visibility of the generated .NET property
> (well if the field is private the property shall be private).
>
> Would there be a way to be able to define the visibility of the
> generated property (which would avoid me having to define public fields
> in my classes) ?
>
> Thanks for your help & patience
>
> Best Regards
>
> Antoine Malliarakis
>
>



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ikvm-developers mailing list
Ikvm-developers@...
https://lists.sourceforge.net/lists/listinfo/ikvm-developers