The title speaks for itself. The language is Java.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, there is. This is however a tedious and expensive work. You need to crawl through all class files and all JAR files with help of
ClassLoader#getResources()and a shot ofjava.io.Fileand load all classes of it with help ofClass#forName()and finally check if the method is there byClass#getMethod().However, there are 3rd party API’s which can take the tedious work from hands, but it is still expensive, because loading a class would cause its
staticinitializers being executed.A cleaner way is to make use of
annotationsand annotate the methods in question and then make use of libraries which searches for classes/methods/fields based on the annotations, such as Google Reflections.On the other hand, if the entire package name or the JAR file name is known beforehand, then the work will be less tedious and expensive (no need to do stuff recursively nor to load the all of the classes of entire classpath).
Update: I remember, I ever wrote sample code to achieve something like that, you can find it here. It’s good to start with, you only need to change it a bit to check the method.