javap: fully qualified names for "new" statements  
Author Message
S.Marion





PostPosted: 2006-3-3 1:00:00 Top

java-programmer, javap: fully qualified names for "new" statements Hello,

I'm using javap for my project.
Basically, what I'm interested in are the "new", "newarray" and
"anewarray" statements.
However, javap only outputs things like:
new #10; //class StringBuffer

but does not give me the fully qualified name.

Is there any way I could get to know this information?

Cheers,

Sebastien Marion
 
S.Marion





PostPosted: 2006-3-3 1:13:00 Top

java-programmer >> javap: fully qualified names for "new" statements Opologies for the previous email, I found the answer to my question.
I'm not sure there is a way to get the fully qualified name outputed by
javap.
However, when using the -verbose flag, javap outputs at the beginning of
the dump things like :
const #1 = class #2; // Runtime
const #2 = Asciz java/lang/Runtime;
const #3 = class #4; // Object
const #4 = Asciz java/lang/Object;
const #5 = Asciz securityManager;
const #6 = Asciz Ljava/lang/SecurityManager;;
const #7 = Asciz defaultProperties;
const #8 = Asciz Ljava/util/Properties;;
const #9 = Asciz current;
const #10 = Asciz Ljava/lang/Runtime;;
const #11 = Asciz libpath;
const #12 = Asciz [Ljava/lang/String;;
const #13 = Asciz exitSequence;
and so on.
This is then where I can get the fully qualified name from ;)

Cheers,
Sebastien Marion


S.Marion wrote:
> Hello,
>
> I'm using javap for my project.
> Basically, what I'm interested in are the "new", "newarray" and
> "anewarray" statements.
> However, javap only outputs things like:
> new #10; //class StringBuffer
>
> but does not give me the fully qualified name.
>
> Is there any way I could get to know this information?
>
> Cheers,
>
> Sebastien Marion
 
Roedy Green





PostPosted: 2006-3-3 9:33:00 Top

java-programmer >> javap: fully qualified names for "new" statements On Thu, 02 Mar 2006 17:13:28 +0000, "S.Marion" <email***@***.com>
wrote, quoted or indirectly quoted someone who said :

>This is then where I can get the fully qualified name from ;)

You need a more refined tool. See http://mindprod.com/jgloss/jasm.html
to look for libraries to help you examine byte code. The string you
want is in the literal pool. There will be a reference to it an a
fixed offset. Read the class library format spec at the link I gave.

the reference comes right after the access flags. Get a hex viewer to
let you look at the first few bytes and the constant pool. It is all
pretty much the way you would expect.

A string reference is simply an index into the constant pool array
which then points you to where the string itself is and how long it
is.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.