We might learn something about native methods from the Java Native
Interface (JNI). The JNI suggests that each class must manage its own
native methods. If there were a "list of native methods" field inside each
class, native methods could be closely associated with a class. When an
invoke..() opcode method detects a native attribute, it can get a native
method from the class. On the other hand, when an invoke..() opcode method
detects a native method, it can verify the existance of a native attribute.
When a class is garbage collected, all links to its native methods are
discarded.

decaf maintains a centralized, vm-wide list of native methods. Its native
methods are registered once for all classes. Should decaf could maintain a
(short) list of native methods for each a class? This would be populated
many times, each time a class is resolved.

decaf also uniquely identifies a native method by name rather than name and
signature. Anyway, it is rare for a native method to have more than one
signature within the Java standard class libraries.

JNI is incomplete. It has no C/C++ methods to set and get individual native
methods. Instead of a C structure like JNINativeMethod, I would like to see
a NativeMethod class in C++.

class NativeMethod {
  public:
    NativeMethod(
        const char *name,
        const char *signature,
        const void *fnPtr );

    const char *getName() const;
    const char *getSignature() const;
    const void *fnPtr() const;
    // *A! invoke();
  :
};


_______________________________________________
Kernel maillist  -  [EMAIL PROTECTED]
http://jos.org/mailman/listinfo/kernel

Reply via email to