You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by Dean Hiller <de...@xsoftware.biz> on 2005/01/13 06:36:40 UTC

getting type information from this code

Am I correct in saying the byte code will not contain information on the type for line 2 in the following code


line 1: public void someMethod() {
line 2:           DummyClass c = null;
line 3:  }

Is it correct to say that the byte code will not contain info that the variable c is of type DummyClass?  If I am incorrect, how do I get the type information?
thanks,
dean

Re: getting type information from this code

Posted by Dave Brosius <db...@qis.net>.
In the case of static finals, i believe the constant value is just folded 
into the class that uses it, and there is no reference of the class where 
the constant is defined.

----- Original Message ----- 
From: "Dean Hiller" <de...@xsoftware.biz>
To: "BCEL Users List" <bc...@jakarta.apache.org>
Sent: Thursday, January 13, 2005 2:33 PM
Subject: Re: getting type information from this code


> Sweet!!!  That is exactly what I want.  I will try to figure out the 
> methods
> I use in bcel to get that info.
>
> 2 more questions then....
> 1. Is there a way to find out if the -g option was used when looking at 
> the
> byte code?  I see there are different debug info also(lines, source, and
> vars)...I really would just like to see if all are on or not, or at least
> the vars so I can give an error saying class was not compiled with -g
> option.
> 2. If I have code like this
>
> public class Client {
> public void method() {
>    String s = SomeClass.CONSTANT;  //CONSTANT is static final
> }
> }
>
> Is there a way from the "Client" class file to tell that it depends on
> "SomeClass" class?  Is there anything in the bytecode that would tell me
> that?  I remember reading constants were compiled in though so I am 
> thinking
> this one is not possible, or am I wrong?
> thanks,
> dean
>
>
> ----- Original Message ----- 
> From: "Dave Brosius" <db...@qis.net>
> To: "BCEL Users List" <bc...@jakarta.apache.org>
> Sent: Wednesday, January 12, 2005 10:55 PM
> Subject: Re: getting type information from this code
>
>
>> No, all you know is what local variable slot the variable is found in.
> Then
>> you can look in the LocalVariableTable to find the information out
> (assuming
>> it is in the class file) [compiled with -g]
>>
>> the byte code would be something like
>>
>> aconst_null
>> astore_1
>>
>> ----- Original Message ----- 
>> From: "Dean Hiller" <de...@xsoftware.biz>
>> To: <bc...@jakarta.apache.org>
>> Sent: Thursday, January 13, 2005 12:36 AM
>> Subject: getting type information from this code
>>
>>
>> Am I correct in saying the byte code will not contain information on the
>> type for line 2 in the following code
>>
>>
>> line 1: public void someMethod() {
>> line 2:           DummyClass c = null;
>> line 3:  }
>>
>> Is it correct to say that the byte code will not contain info that the
>> variable c is of type DummyClass?  If I am incorrect, how do I get the
> type
>> information?
>> thanks,
>> dean
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: bcel-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: bcel-user-help@jakarta.apache.org
>
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org


Re: getting type information from this code

Posted by Dean Hiller <de...@xsoftware.biz>.
Sweet!!!  That is exactly what I want.  I will try to figure out the methods
I use in bcel to get that info.

2 more questions then....
1. Is there a way to find out if the -g option was used when looking at the
byte code?  I see there are different debug info also(lines, source, and
vars)...I really would just like to see if all are on or not, or at least
the vars so I can give an error saying class was not compiled with -g
option.
2. If I have code like this

public class Client {
public void method() {
    String s = SomeClass.CONSTANT;  //CONSTANT is static final
}
}

Is there a way from the "Client" class file to tell that it depends on
"SomeClass" class?  Is there anything in the bytecode that would tell me
that?  I remember reading constants were compiled in though so I am thinking
this one is not possible, or am I wrong?
thanks,
dean


----- Original Message ----- 
From: "Dave Brosius" <db...@qis.net>
To: "BCEL Users List" <bc...@jakarta.apache.org>
Sent: Wednesday, January 12, 2005 10:55 PM
Subject: Re: getting type information from this code


> No, all you know is what local variable slot the variable is found in.
Then
> you can look in the LocalVariableTable to find the information out
(assuming
> it is in the class file) [compiled with -g]
>
> the byte code would be something like
>
> aconst_null
> astore_1
>
> ----- Original Message ----- 
> From: "Dean Hiller" <de...@xsoftware.biz>
> To: <bc...@jakarta.apache.org>
> Sent: Thursday, January 13, 2005 12:36 AM
> Subject: getting type information from this code
>
>
> Am I correct in saying the byte code will not contain information on the
> type for line 2 in the following code
>
>
> line 1: public void someMethod() {
> line 2:           DummyClass c = null;
> line 3:  }
>
> Is it correct to say that the byte code will not contain info that the
> variable c is of type DummyClass?  If I am incorrect, how do I get the
type
> information?
> thanks,
> dean
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: bcel-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org


Re: getting type information from this code

Posted by Dave Brosius <db...@qis.net>.
No, all you know is what local variable slot the variable is found in. Then 
you can look in the LocalVariableTable to find the information out (assuming 
it is in the class file) [compiled with -g]

the byte code would be something like

aconst_null
astore_1

----- Original Message ----- 
From: "Dean Hiller" <de...@xsoftware.biz>
To: <bc...@jakarta.apache.org>
Sent: Thursday, January 13, 2005 12:36 AM
Subject: getting type information from this code


Am I correct in saying the byte code will not contain information on the 
type for line 2 in the following code


line 1: public void someMethod() {
line 2:           DummyClass c = null;
line 3:  }

Is it correct to say that the byte code will not contain info that the 
variable c is of type DummyClass?  If I am incorrect, how do I get the type 
information?
thanks,
dean 



---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org