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

CtType#getAllMethods contract seems not respected #1618

Closed
surli opened this issue Oct 19, 2017 · 5 comments
Closed

CtType#getAllMethods contract seems not respected #1618

surli opened this issue Oct 19, 2017 · 5 comments

Comments

@surli
Copy link
Collaborator

surli commented Oct 19, 2017

Looking on CtType#getAllMethods we have the following comment (see:

* Up to 5.2: The recursion stops when the super-type/super-interface is not in the model,
)

Up to 5.2: The recursion stops when the super-type/super-interface is not in the model,
which means that no method of library super-classes, or of Object are present.

However when looking on the test CtTypeInformationTest#testGetSuperclass we explicitely try to obtain methods from Object
See:

So either the contract is wrongly defined, or the implementation is wrong.

@monperrus
Copy link
Collaborator

monperrus commented Oct 19, 2017 via email

@surli
Copy link
Collaborator Author

surli commented Oct 19, 2017

Ok, and do we agree that for a given class and its associated CtClass we should have the following contract:

MyClass.class.getMethods().length == MyCtClass.getAllMethods().size() ?

See: https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getMethods()

@monperrus
Copy link
Collaborator

monperrus commented Oct 19, 2017 via email

@surli
Copy link
Collaborator Author

surli commented Oct 19, 2017

No, because we have the methods of objects

Actually getMethods() also return Object method. The main difference is getMethods() of Java only return public methods, and do not duplicate overriden method even when they don't have exactly the same signature (like with generics)

@surli
Copy link
Collaborator Author

surli commented Oct 26, 2017

Fixed in #1644

@surli surli closed this as completed Oct 26, 2017
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

No branches or pull requests

2 participants