ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  10 Reasons We Need Java 3.0
Subject:   Three more reasons for Java 3.0
Date:   2002-08-06 13:51:40
From:   rayburns
Here are my top three not listed in the article:


3. Make arrays implement the List interface, especially .iterator()
2. Value types a la C# (ie. allow Rect can be returned in registers)
1. LET US OUT OF THE BOX!!!!! When a native API needs to be called it should be easy to do so.


I've worked on several large Java applications, and each one needed a lot of JNI code to interface with the native APIs.


For example, my current project requires the use of get_fs_usage() on Linux and GetDiskFreeSpace() on Windows. It's just plain stupid that I should have to go outside the Java language and deal with external libraries and such to make these calls. In many other languages I could write:


long getDiskFreeSpace(String path)
{
int freeSpace;


if(PLATFORM_IS_UNIX)
{
fs_usage fsu = new fs_usage();
pin(fsu)
{
if(get_fs_usage(path, "", fsu)!=0)
{
throw new IOException("...");
}
return fsu.freeSpace;
}
}
else if(PLATFORM_IS_WINDOWS)
{
long freeSpace = GetDiskFreeSpace(path);
if(freeSpace == -1)
{
throw new IOException("...");
}
return freeSpace;
}
else
{
throw new IOException("Don't now how to get free space on this architecture");
}
}


private native int get_fs_usage(String path, String device, fs_usage arg) "fsutil.so";
private native long GetDiskFreeSpace(String arg) "kernel32.dll";



In Java the same thing requires pages of comparatively cryptic JNI code, extra files, extra Make steps, platform-specific compilers, platform-specific binaries, and all sorts of other ugliness.


Ray Burns


1 to 1 of 1
1 to 1 of 1