Skip to content

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.

2 participants