|
Authored by: greed on Thursday, April 19 2012 @ 10:08 PM EDT |
For those that do want to know, the Java API to access the Solaris dlopen/dlsym
API is through JNI: "Java Native Interface". The
java.lang.System.loadLibrary(String file) calls into the "dlopen" (or
moral equivalent) routine to load the specified shared object file.
Then, any method with the "native" qualifier will be cause
"dlsym" to be invoked, arguments marshalled, and the native binary
invoked. On return from the native code, results are put back into the format
needed for JVM bytecode and bytecode execution resumes.
Actually, most of he work on "understanding" Java objects is actually
done in the native binary code. Pointers, for the most part, get passed into
the native code. Then there are helper subroutines in the JVM native binary
code that help translate Java objects and types into formats more suitable for C
(or C++ or Objective C or assembly).
That's the best way to do that sort of thing: you don't want to spend time
turning a Java array into a C array if it turns out you aren't going to bother
reading anything out of it, or you only need one item, or whatever.
You can call back into Java from native code too: if you have an object pointer,
you can ask the Java environment to invoke methods on it.
There will be other things in the implementation to help it actually run
fast--the last thing you'd want is your native code interface to be slow. (You
either use it to access system routines--file or network I/O--or for speed; say
to take advantage of vector math instructions, or GPGPU features.)
(The dlopen/dlsym, actually the ld.so API, was written for Linux based on the
Sun docs... oh oh. The Linux one has some advantages with respect to multiple
versions of symbols, but only serious system library builders--like the GLIBC
folks, or the compiler folks--use that feature. Especially since it isn't
portable.)
[ Reply to This | Parent | # ]
|
|
Authored by: Anonymous on Friday, April 20 2012 @ 01:12 PM EDT |
The names definitely are part of the API. Compiling Java code does not remove
those names; they are present in the bytecode (and even JITted binary code) and
can be accessed at runtime via reflection.
If you rename a package, class,
method or even parameter name, what you now have is a different API (even
if the code that implements it is exactly the same).
This is also one reason
why the names should not be protected by copyright law: to achieve compatibility
with an existing API, you must use the exact same package, class, method
and parameter names used in the API.
Google wrote their own implementations
of the methods, but they "copied" the public API specification pieces from Sun's
java APIs in order to have some source-code compatibility between Sun's Java
platform and their new Android platform (both so that programmers could take
pieces of programs written for Sun's Java platform, and easily adapt or use
those pieces on Google's Android program, and so that programmers could write
new code for Android leveraging their existing knowledge of the Java APIs). To
achieve this compatibility, there was literally only ONE name they could choose
for each package, class, method and parameter mentioned in the Java API
specifications. Its a functional requirement in order to achieve compatibility.
Therefore, it should not be protected by copyright law.
IANAL. [ Reply to This | Parent | # ]
|
|
|
|
|