line number of the source code in the thrown exception

A

Ahmed Moustafa

Why does it sometimes show the line number of the source code in the
thrown exception and sometimes does not?
Thanks in advance,
Ahmed
 
A

Ahmed Moustafa

Why does it sometimes show the line number of the source code in the
for native methods it would not have the same mechanism to figure the
line number out from the address. Does that explain it all?

I am asking about exceptions I throw.
 
A

Alex Bendig

Some code showing your throwing and handling of exceptions would be helpful.

Regards,
Alex
 
A

Ahmed Moustafa

Some code showing your throwing and handling of exceptions would be helpful.

Say,

<code>
public void methodX() thorns XException {
try {
Some code that will throw an exception...
} catch (Exception e) {
throw new XException ( "Error: " + e.getMessage() );
}
 
J

J

Why does it sometimes show the line number of the source code in the
thrown exception and sometimes does not?
Thanks in advance,
Ahmed

I think if you have debugging turn OFF, then line numbers will not show up.

J
 
B

brougham3

Ahmed Moustafa said:
Why does it sometimes show the line number of the source code in the
thrown exception and sometimes does not?
Thanks in advance,
Ahmed

When you are using javac to compile, what option are you using for -g?
 
S

Sudsy

Ahmed said:
Why does it sometimes show the line number of the source code in the
thrown exception and sometimes does not?
Thanks in advance,
Ahmed

I've found that the JIT discards the debug informtion (such as line
numbers) and you'll just see (IIRC) "compiled code". I turn the JIT
off during debugging. How you do that depends on your environment.
 
A

Ahmed Moustafa

Why does it sometimes show the line number of the source code in the
When you are using javac to compile, what option are you using for -g?

I am not using -g with javac. I am compiling with WSAD, maybe I need to
check the settings.
 
J

Jon A. Cruz

Sudsy said:
I've found that the JIT discards the debug informtion (such as line
numbers) and you'll just see (IIRC) "compiled code". I turn the JIT
off during debugging. How you do that depends on your environment.


I've only seen that with older JITs, not newer ones.
 
J

Jon Skeet

Sudsy said:
I've found that the JIT discards the debug informtion (such as line
numbers) and you'll just see (IIRC) "compiled code".

That hasn't been the case since HotSpot was introduced a *long* time
ago.
 
T

Tor Iver Wilhelmsen

Ahmed Moustafa said:
Why does it sometimes show the line number of the source code in the
thrown exception and sometimes does not?

It only does for classes with line number debug info present.
 

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,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top