Skip to content

Handle Bridge methods created by the Java compiler #553

@JonasKlauke

Description

@JonasKlauke

The java compiler will generate bridge method in specific cases.
For example, if the method uses the covariance feature of Java, the compiler will generate a bridge method which represent the correct signature. This bridge method will just call the other method.

These bridge methods are problematic for call graph generation since the signature of both methods only differ by the return type, but since the returntype is a subtype of the correct signature both methods are vallid targets and the algorithm will just choose the first method.

Maybe the covariance support of canDispatch has to be removed in the call graph generation.

Example Code:

package soot.test;
public class H {
 public Object test(){return new Object();}
}

public class G extends H{
  @Override
  public G test() {return this;}
}

Results to:

public soot.test.G test();
   descriptor: ()Lsoot/test/G;
   flags: ACC_PUBLIC
   Code:
     stack=1, locals=1, args_size=1
        0: aload_0
        1: areturn
     LineNumberTable:
       line 7: 0
     LocalVariableTable:
       Start  Length  Slot  Name   Signature
           0       2     0  this   Lsoot/test/G;

 public java.lang.Object test();
   descriptor: ()Ljava/lang/Object;
   flags: ACC_PUBLIC, ACC_BRIDGE, ACC_SYNTHETIC
   Code:
     stack=1, locals=1, args_size=1
        0: aload_0
        1: invokevirtual #2                  // Method test:()Lsoot/test/G;
        4: areturn
     LineNumberTable:
       line 3: 0
     LocalVariableTable:
       Start  Length  Slot  Name   Signature
           0       5     0  this   Lsoot/test/G;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions