How do I get all the implementation classes (and sub-interfaces) for an interface? Example: Eclipse IDE

Source: Internet
Author: User
(i) practices of the Eclipse IDE

It will parse all Java files and class files.

Tip: In Eclipse, select interface and press F4 to see all implementation classes and sub-interfaces.

For example:

(b) How do you do it yourself?

(1) If you don't know what the implementation classes are for this interface

With Java default ClassLoader there is no way to get all the implementation classes, because ClassLoader will load the class into the static zone when the program is running, that is, if your program needs to use a class, The JVM finds that the class has not been loaded by ClassLoader, it will take the initiative to load it, otherwise it will skip, and you can't know the implementation classes that are not loaded.

(2) If you know what implementation classes

That is simple, you configure an XML file, the implementation of the class's full class name in the XML file, and then write a parser, iterate each class name, directly loaded with Class.forName can be.

How do I get all the implementation classes (and sub-interfaces) for an interface? Example: Eclipse IDE

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.