all groups > vj# > september 2005 >
You're in the

vj#

group:

Comments about J#'s two type systems


Comments about J#'s two type systems BGU
9/26/2005 4:54:25 PM
vj#:
Hello, I've had numerous problems in past weeks calling ADO.NET
from J#. The cause of these problems frequently stems from ADO.NET's
inability to deal with J#'s native types. My code is full of casts to such
types as

System.Byte
System.Int32

because passing

java.lang.Byte
java.lang.Integer

to ADO.NET creates exceptions. I might add that the messages from these
exceptions are seldom helpful. A recent example was "Object must implement
IConvertible."

Are C# or VB programmers also having to deal with two type systems in their
..NET Framework applications? I'd like to get input from others who have
dealt with or thought about this limitation of J# (if it is a limitation).

Thanks,
BGU

Re: Comments about J#'s two type systems David Anton
9/26/2005 7:31:03 PM

The problem is unique to J#.

The language could use more consistency. It is difficult to determin
where you should need a cast and where you shouldn't


-
David Anto
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------

Re: Comments about J#'s two type systems ~~~ .NET Ed ~~~
9/28/2005 9:33:17 PM
Hi,
I am afraid that is a common problem. In my opinion J# is a half-hearted
attempt to bring Java to .NET and while "better than nothing" I believe it
seriously need some rethinking.

[quoted text, click to view]

Re: Comments about J#'s two type systems Ujihara, Kazuya
10/7/2005 12:00:00 AM
You can use System.Int32 class in J#. See the following example code.

public class Demo
{
/** @attribute System.STAThread() */
public static void main(String[] args)
{
sub((System.Int32)100);
System.Int32 int32 = (System.Int32)100;
sub(int32);
}

public static void sub(Object o)
{
System.out.println(o instanceof System.IComparable);
System.out.println(o);
System.out.println((System.Int32)o);
int i = (int)((System.Int32)o);
System.out.println(i);
}
}

Kazuya Ujihara
http://www.ujihara.jp/


[quoted text, click to view]
Re: Comments about J#'s two type systems Bruno Jouhier
10/9/2005 12:00:00 AM

"BGU" <pri@va.te> a écrit dans le message de news:
us7DLWvwFHA.1124@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

It is not really a "limitation", rather a "design choice".

The problem is that J# tries to stick to the Java specs. And the Java specs
define java.lang.Byte/Integer/... classes that have a different API than
their .NET counterpart (System.SByte/Int32/...). So, the J# designers chose
to keep the two sets of classes separate.

Maybe they should have done things differently and "unified" the Java
classes with the .NET classes (like they did with java.lang.Object/String
and System.Object/String). This requires some tricks in the J# compiler
(like faking the Java API on these .NET APIs). IMO, this would have been
better, but everything is not obvious when we try to merge Java and .NET at
this level. For example, this would require that toString() and ToString()
behave differently on Double, because toString() formats in the invariant
culture in Java (the Java specs impose this) and ToString() formats in the
current culture in .NET (.NET specs impose this), and you have to deal with
these issues if you want to conform to the Java specs.


Bruno.


[quoted text, click to view]

AddThis Social Bookmark Button