Where is the entry point of java calls
Karen Kinnear
Karen.Kinnear at Sun.COM
Wed Mar 4 11:32:34 PST 2009
Colin,
Let's start with reading the bytecodes. You have a .class file.
Run javap -c Main > Main.jasm to get the bytecodes from Main.class
- now you can view the translated generated bytecodes using your
favorite editor (read, not modify)
In the sample I looked at, in which there was a
private native Class myNative(args)
in the bytecodes for the caller, there was the instruction:
invokespecial #83; // Method myNative:(...signature for args)
#83 refers to the constant pool entry #83
See java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html
Look in section 4.1 for details on the class file format.
2. Method invocation should use one of: invokevirtual/special/static/
interface
so find that bytecode in your generated code. You can put a breakpoint
in
the interpreter you are debugging - for when it checks for a native
method call.
good luck,
Karen
On Mar 4, 2009, at 1:36 PM, Colin(Du Li) wrote:
>
> Hi, Karen,
>
> Thanks for your prompt reply!
> What I wanna do is to trap all the java method call, and pick out
> the native
> calls (JNI). I still have two questions.
> 1. How can I read the generated bytecodes. When I use Vi to open
> a .class
> file, it's not very readable.
> 2. Does every method call for another java method can be trapped at
> invoke_virtual/special/static in bytecodeInterpreter.cpp?
>
> Thanks again.
>
> Colin.
>
> Karen Kinnear wrote:
>>
>> Colin,
>>
>> We don't use javaCalls for calls from one java method to another.
>> I believe you are writing an interpreter (or modifying the C++
>> interpreter)?
>> So you want to look at the code you generated - which will invoke
>> java methods directly. See the bytecodes for invoke_virtual/special/
>> interface.
>>
>> hope this helps,
>> Karen
>>
>> On Mar 4, 2009, at 12:53 PM, Colin(Du Li) wrote:
>>
>>>
>>> Hi, guys.
>>> Could anyone help me ? Or do I need express my question more
>>> clearly?
>>> I really need help for this question.
>>> Thanks a lot!
>>>
>>> Colin
>>>
>>> Colin(Du Li) wrote:
>>>>
>>>> Hello,
>>>> My question is where is the entry point of java calls in hotspot.
>>>> If I have a simple application as follow:
>>>>
>>>> public class HelloWorld{
>>>> public static void main(String[] args){
>>>> hello2();
>>>> }
>>>> public static void hello2(){
>>>> System.out.println("hello 2.");
>>>> }
>>>> }
>>>>
>>>> If I observe at javaCalls:call_helper(), I can only see method
>>>> HelloWorld.main(), I cannot see method HelloWorld.hello2(). Why?
>>>> and How
>>>> can I find the entry point of method HelloWorld.hello2()?
>>>>
>>>> Thanks a lot!
>>>>
>>>> Colin
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Where-is-the-entry-point-of-java-calls-tp22298233p22335492.html
>>> Sent from the OpenJDK Hotspot Virtual Machine mailing list archive
>>> at Nabble.com.
>>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Where-is-the-entry-point-of-java-calls-tp22298233p22336385.html
> Sent from the OpenJDK Hotspot Virtual Machine mailing list archive
> at Nabble.com.
>
More information about the hotspot-dev
mailing list