|
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
|
I am trying to write in Java with JNI a class that gets the free space in my disk, I am having several problem because I don't know how to use the language C to do the interface with Java. Will it be that you have this code of Java and C and can he/she send me?
My email is Carlos_Salvador@cargill.com
Thank you
Carlos Salvador
DBA Oracle PL
Brazil - SP