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

support for multi-argument constructors #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mr14huashao
Copy link

add newInstance0() to support for multi-argument constructors
usage:

Constructor constructor = SomeClass.class.getConstructor(String.class);
ConstructorAccess<SomeClass> access = ConstructorAccess.get(SomeClass.class, constructor);
assertEquals(new SomeClass("coo), access.newInstance0("coo"));

bytecode:

public Object newInstance0(Object[] var1) {
    return new SomeClass((String)var1[0]);
}

Performance comparison of access.newInstance("coo") and constructor.newInstance("coo")

@NathanSweet
Copy link
Member

The name newInstance0 isn't great. It's not clear what the difference is between all the new instance methods?

@Mr14huashao
Copy link
Author

how about the name newInstanceWithParam(Object... args), or rename newInstance(Object enclosingInstance) to newInstanceInner(Object enclosingInstance), but the latter may have compatibility issues.

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

Successfully merging this pull request may close these issues.

None yet

2 participants