[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Spark's class analysis
This depends on the option settings.
If on-fly-cg is false, a class hierarchy analysis is used to build a
call graph before Spark starts. This means that it looks at the declared
type of o, which is C, and assumes that o could be any subtype of C
(namely A, B, C), and therefore the call could go to any of the three
m() methods.
If on-fly-cg is true, Spark uses the points-to information it computes
to build the call graph as it runs. In this case, after seeing the
statements o = new B(); and o = new A();, it knows that o could have
type A or B, and the call could therefore go to either A.m() or B.m().
Ondrej
On Wed, Jul 16, 2003 at 11:09:45AM +0200, Christophe Massol wrote:
> Hello,
>
> Does Spark perform a Class analysis to know the possibles methods to call in
> this exemple : (o.m() )
>
>
> public class Test{
> C o;
>
> public Test(String bool){
> if(bool.equals("true")){
> o = new B();
> }
> else{
> o = new A();
> }
> o.m();
> }
>
> public static void main(String[] argv){
> new Test(argv[0]);
> }
>
> public Object[] get(){
> return new Object[3];
> }
>
> }
> class C {
> public void m(){
> }
> }
>
> class B extends C {
> public void m(){
> }
> }
> class A extends C {
> public void m(){
> }
> }
> --
>
> Cordialement,
>
> Massol Christophe
> ---------------------------------------------------------------
> Stagiaire Projet OASIS
> [049238 7558]
>
> Etudiant en maîtrise MIAGE à l'université de Nice
>
> Tel: 06 12 53 72 44
> Adresse: 217 bd de la madeleine
> 06000 Nice
>