In actual practice, there isn't much you need to know about stub files other than knowing they need to be part of your dynamically linked library. They are used as the well known interface between Java method invocations by the interpreter to marshal parameters between Java and a C library.
Stub generation produces a noteworthy artifact. Method signatures are generated by javah -stubs. Method signatures are significant, because C functions use these signature strings to execute Java methods from within the C function (in effect calling back into Java code). See "Method Signatures" for more information.
/* Stubs for class demo/InputFile */ /* DO NOT EDIT THIS FILE - it is machine generated */ /* SYMBOL: "demo/InputFile/open()Z", demo_InputFile_open_stub, */ stack_item *demo_InputFile_open_stub(stack_item *_P_, struct execenv *_EE_) { extern long demo_InputFile_open(void *); _P_[0].i = demo_InputFile_open(_P_[0].p); return _P_ + 1; } /* SYMBOL: "demo/InputFile/close()V", demo_InputFile_close_stub, */ stack_item *demo_InputFile_close_stub(stack_item *_P_, struct execenv *_EE_) { extern void demo_InputFile_close(void *); (void) demo_InputFile_close(_P_[0].p); return _P_; } /* SYMBOL: "demo/InputFile/read([BI)I", demo_InputFile_read_stub, */ stack_item *demo_InputFile_read_stub(stack_item *_P_, struct execenv *_EE_) { extern long demo_InputFile_read(void *,void *,long); _P_[0].i = demo_InputFile_read(_P_[0].p,((_P_[1].p)), ((_P_[2]. i))); return _P_ + 1; }
/* Stubs for class demo/OutputFile */ /* DO NOT EDIT THIS FILE - it is machine generated */ /* SYMBOL: "demo/OutputFile/open()Z", demo_OutputFile_open_stub, */ stack_item *demo_OutputFile_open_stub(stack_item *_P_, struct execenv *_EE_) { extern long demo_OutputFile_open(void *); _P_[0].i = demo_OutputFile_open(_P_[0].p); return _P_ + 1; } /* SYMBOL: "demo/OutputFile/close()V", demo_OutputFile_close_stub, */ stack_item *demo_OutputFile_close_stub(stack_item *_P_, struct execenv *_EE_) { extern void demo_OutputFile_close(void *); (void) demo_OutputFile_close(_P_[0].p); return _P_; } /* SYMBOL: "demo/OutputFile/write([BI)I", demo_OutputFile_write_stub, */ stack_item *demo_OutputFile_write_stub(stack_item *_P_, struct execenv *_EE_) { extern long demo_OutputFile_write(void *,void *,long); _P_[0].i = demo_OutputFile_write(_P_[0].p,((_P_[1].p)), ((_P_[2].i))); return _P_ + 1; }
For example, from class Demo the close method has the following signature:
Demo/close()VIn the above example, simple as it is, the method signature indicates that close is a function with no parameters and has a void return type. For detailed information on method signatures, please refer to the Java virtual machine specification.
In a type signature, type names are:
I = integer
B = byte
C = char
L = classname, in the form: Lclassname;
E = enum
F = float
S = unsigned short
Z = boolean
V = void
So, as a second example,
<init>(II)Lfp/gui/MouseEvent;describes a method "<init>" which is a function that takes two integers as an argument and returns an instance of class fp/gui/MouseEvent ("<init>" is the "method name" of a constructor.)
Implementing Native Methods
Generated with CERN WebMaker