Source code for Exception Class and RuntimeException Class

A

ankur

Hi All,

How can I see the source code for Exception Class and RuntimeException
Class?
 
A

ankur

With the JDK (and not the JRE), to be precise.

Thanks, I have further question:

In Throwable.java I can see the signature for

public synchronized native Throwable fillInStackTrace();

where do I find its implementation ?

Ditto for this method:

private native StackTraceElement getStackTraceElement(int index);

?
 
J

Joshua Cranmer

ankur said:
In Throwable.java I can see the signature for
public synchronized native Throwable fillInStackTrace();
where do I find its implementation ?

It's native, so its source is in the source of the actual JVM.

This is the source of the bridge for JDK 7:
<http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/tip/src/share/native/java/lang/Throwable.c>

The method seems to come from here (line 402):
<http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/tip/src/share/vm/prims/jvm.cpp>

At that point, I'd say it's best to basically open stuff up in gdb (C++
debugger) to try to follow what's going on, since I've perplexed myself,
and following code through several separate hg trees is becoming an
exercise in pain.
Ditto for this method:
private native StackTraceElement getStackTraceElement(int index);

Roughly, ditto.

At this point, however, you're delving deep into the structure of the
JVM--as is the case for much of java.lang and its subpackages.
 
A

ankur

It's native, so its source is in the source of the actual JVM.

This is the source of the bridge for JDK 7:
<http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/tip/src/share/native/ja...>

The method seems to come from here (line 402):
<http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/tip/src/share/vm/pr...>

At that point, I'd say it's best to basically open stuff up in gdb (C++
debugger) to try to follow what's going on, since I've perplexed myself,
and following code through several separate hg trees is becoming an
exercise in pain.


Roughly, ditto.

At this point, however, you're delving deep into the structure of the
JVM--as is the case for much of java.lang and its subpackages.

Thanks Joshua.
 
A

Arne Vajhøj

ankur said:
In Throwable.java I can see the signature for

public synchronized native Throwable fillInStackTrace();

where do I find its implementation ?

Ditto for this method:

private native StackTraceElement getStackTraceElement(int index);

Native methods are in C code.

You can get the source for the C pieces of SUN Java as well.

But I think you should look for alternative approaches to
whatever you are trying to accomplish.

Native stacktrace code in the JVM is not something to mess
around with.

Arne
 
A

ankur

Native methods are in C code.

You can get the source for the C pieces of SUN Java as well.

But I think you should look for alternative approaches to
whatever you are trying to accomplish.

Native stacktrace code in the JVM is not something to mess
around with.

Arne

Hi Arne,

Thanks for your answer.
Where can I get the source for the C pieces of SUN Java ?
 
A

Andrew Thompson

...
How can I see the source code for Exception Class and RuntimeException
Class?

What are you trying to /achieve,/ by seeing that source?

I suspect you are looking in the wrong direction to
achieve the goal (whatever it is).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top