Skip to content

Invocations of inherited methods #3

@verhoofstad

Description

@verhoofstad

When loading the following java code from an Eclipse project the model.methodInvocation contains an invocation from D->p() to C->m(), as expected.

public class C
{
    public void m() {}
}

public class D extends C
{
    public void p() {
        this.m();
    }
}

rel[loc from,loc to]: {
  <|java+method:///org/D/p()|,|java+method:///org/C/m()|>
}

When compiled to a jar file the target of the invocation is suddenly resolved to D->m()

rel[loc from,loc to]: {
  <|java+method:///org/D/p()|,|java+method:///org/D/m()|>
}

This kind of behaviour is also described in a stackoverflow post, https://stackoverflow.com/questions/15172269/java-bytecode-operation-invokevirtual-does-not-keep-consistency-for-the-method so it may not be a bug, however, in both model.declarations and model.modifiers the method is still referred as C->m()

model.declarations:

rel[loc name,loc src]: {
  <|java+method:///org/C/m()|,|file:///C:/Data/File.jar/org/C.class|>,
  <|java+method:///org/D/p()|,|file:///C:/Data/File.jar/org/D.class|>,
  ...
}

model.modifiers:

rel[loc definition,Modifier modifier]: {
  <|java+method:///org/C/m()|,public()>,
  <|java+method:///org/D/p()|,public()>,
  ...
}

Same goes for model.names and model.containment.

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