image provider

Interface Finder


Disclaimer

This essay does not describe an existing computer program, just one that should exist. This essay is about a suggested student project in Java programming. This essay gives a rough overview of how it might work. I have no source, object, specifications, file layouts or anything else useful to implementing this project. Everything I have prepared to help you is right here.

This project outline is not like the artificial, tidy little problems you are spoon-fed in school, when all the facts you need are included, nothing extraneous is mentioned, the answer is fully specified, along with hints to nudge you toward a single expected canonical solution. This project is much more like the real world of messy problems where it is up to you to fully the define the end point, or a series of ever more difficult versions of this project and research the information yourself to solve them.

Everything I have to say to help you with this project is written below. I am not prepared to help you implement it; or give you any additional materials. I have too many other projects of my own.

Though I am a programmer by profession, I don’t do people’s homework for them. That just robs them of an education.

You have my full permission to implement this project in any way you please and to keep all the profits from your endeavour.

Please do not email me about this project without reading the disclaimer above.

This project is related to the Path and Classpath tool project and Which and What Project: path and classpath analysis projects in that they involve analysing the classpath.

This project is easy in that it requires no design or user interface. It is an exercise in fiddling bits and using JDK (Java Development Kit) methods.

Let us say you have written code that will allow the user to add it own plugins, simply by implementing some interface. It would be nice to list all possible classes on the classpath that implement the interface (or extends a given class), so that you can add them to a JComboBox to let the user select which of all possible plug-in he wants to use.

How do you prepare the list?

  1. Get the classpath as a from the system properties.
  2. In Windows, split it at the semicolons with Regex.split. In Linux, split it at the colons. In general, split it at the File. pathSeparatorChar.
  3. Collect a list of all independent class files on the classpath by using File.list using a filter.
  4. Similarly, collect a list of all class files in jars and zips.
  5. Using your knowledge of the class file format, check each class file to see if it implements the desired interface of class. It if does add it to your Set. You might use BCEL (Byte Code Engineering Library). However, it will probably be faster to roll your own chase through the bytes to get just what you want, rather than turning on a full blown analyser.
  6. Return an array of fully qualified class names with dots to the caller.
Then write a variant that will search for a given particular class (not just that extends a given class) and tell you which directory on the classpath or in which jar it lives. You might even start with that easier problem, since it does not require scanning the class file binaries.

Most of what you need for a classpath search is implemented in ZipLock. See the storeClass(String className) method and the openResource(,) method it calls.

jar
jar verifier Project
JarCheck
JarLook
Java Jar Catalog Project
Path and Classpath tool project
Which and What Project: path and classpath analysis

This page is posted
on the web at:

http://mindprod.com/project/interfacefinder.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\project\interfacefinder.html
Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[3.141.202.54]
You are visitor number