Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only wrap the method name if the method doesn't come from the same declaring class #391

Merged
merged 1 commit into from May 12, 2022

Conversation

derklaro
Copy link
Contributor

@derklaro derklaro commented Sep 7, 2021

So... I ran into an issue with inner classes again... This time the compiler renames valid method calls when a method is private. The test setup looks like this:

  private static Test1234 test1234(@Name("test") String a) {
    return new Test1234(a);
  }

When generating an invoker which is an inner class of the Test class the compiler will generate this:

public class Test$Invoker_22957570510500 implements InstanceMaker {
    private final Type[] type;

    Test$Invoker_22957570510500(Type[] var1) {
      this.type = var1;
    }

    public Object getInstance(InjectionContext var1) {
      return Test.access$1(/*code to get the string instance*/);
    }
}

but the invocation would work perfectly fine as the caller is an inner class of the Test class and allowed to call the method in that way. After the change the compiler generates this method:

  public class Test$Invoker_22957570510500 implements InstanceMaker {
      private final Type[] type;

      Test$Invoker_22957570510500(Type[] var1) {
        this.type = var1;
      }

      public Object getInstance(InjectionContext var1) {
        return Test.test1234(/*code to get the string instance*/);
      }
}

which is exactly what i was expecting to get and which works perfectly fine. This change was tested against jvm versions HotSpot 1.8.0_241-b07, HotSpot 11.0.6+8-LTS and HotSpot 18-ea+12-613

@chibash chibash merged commit 716b102 into jboss-javassist:master May 12, 2022
@chibash
Copy link
Member

chibash commented May 12, 2022

This PR was rejected because it does not pass a test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants