Qdox
QDox - full extractor of Java class/interface/method definitions (including annotations, parameters, param names)
Install / Use
/learn @paul-hammant/QdoxREADME
QDox
Status
2026: Teams relying on QDox should probably migrate to JavaParser, or Spoon, Rewrite, or Roaster which all have active development still. We're not going to make further changes to QDox nor respond to new issues or PRs.
QDox was a high speed, small footprint parser for fully extracting class/interface/method definitions (including annotations, parameters, param names). It is designed to be used by active code generators or documentation tools.
Not so relevant anymore, but it also processes JavaDoc @tags
Migration from Codehaus
This project used to be on Codehaus, in Subversion. The trunk of that has been git-svn-cloned to here. Maven repos have the sources jars for released versions of Qdox. The old issues from codehaus are hosted statically on a GH-pages repo
Download
Maven's central repo holds versions of QDox
Available assets: binary jar | sources jar | javadoc jar | project tar.bz2 | project tar.gz | project zip
In A Nutshell
A custom-built parser has been built using JFlex and BYacc/J. These have been chosen because of their proven performance, and they require no external libraries at runtime.
The parser skims the source files only looking for things of interest such as class/interface definitions, import statements, JavaDoc and member declarations. The parser ignores things such as actual method implementations to avoid overhead (while in method blocks, curly brace counting suffices).
The end result of the parser is a very simple document model containing enough information to be useful.
Frequently Asked Questions
General
What's the object type of an interface?
The JavaClass method is used to represent both classes and interfaces. The isInterface() method allows you to distinguish between the two.
When using a class, the getSuperClass() return which class is extended. If this has not been defined in the input source code, java.lang.Object is returned. When using an interface, this method ALWAYS returns null.
When using a class, the getImplements() returns an array of the interfaces implemented by the class. If none are implemented, an empty array is returned. When using an interface, this returns an array of interfaces the current interface EXTENDS.
Can I have full control over the classloader?
I some cases QDox is used to generate classes for another project with it's own dependencies. This could result in class-collision. By default the JavadocBuilder will contain the classloader(s) of the current project, but by defining your own classLibrary you can have the required control.
/* new ClassLibrary() will give you an empty classLoader
* Big chance you want at least the system classloader.
*/
ClassLibraryBuilder libraryBuilder = new SortedClassLibraryBuilder(); //or OrderedClassLibraryBuilder()
libraryBuilder.addClassLoader( ClassLoader.getSystemClassLoader() );
JavaProjectBuilder builder = new JavaProjectBuilder( libraryBuilder );
I'm getting an ArrayIndexOutOfBoundsException: 500. What to do?
During the parsing of java files the Parser needs to remember states, which are kept in a stack. Due to recursive calls the stack can become very large. By default the size of this this stack is 500 and it can only be set during compile-time of QDox. Normally 500 per sourcefile will do, but in very, very rare cases this might be too little. The only way to increase this number is by rebuilding it. Download the sources and build it like mvn install -Dqdox.javaparser.stack=750 if you want to change it to 750.
What is using QDox
Project Description How QDox is Used AspectWerkz AspectWerkz is an Aspect Oriented Programming (AOP) toolkit for Java that modifies byte-code to weave in interceptors and mixins. Attributes can be used to associate interceptors and mixins with a specific class.
Avalon Phoenix
Phoenix was a micro-kernel designed and implemented on top of the Avalon framework. It provided a number of facilities to manage the environment of Server Applications. Apache cancelled the Avalon project 2004 'MetaGenerate' is part of the Phoenix toolset and picks up @phoenix prefixed JavaDoc tags to make XML manifests for the components that will be laced together in more XML to make a complete server application.
Cocoon
Apache Cocoon is an XML publishing framework that raises the usage of XML and XSLT technologies for server applications to a new level. Designed for performance and scalability around pipelined SAX processing, Cocoon offers a flexible environment based on a separation of concerns between content, logic, and style. The QDox Block reads in Java source files and fires out SAX events enabling processing by standard XML tools (such as XSLT).
Commons Attribute
Jakarta Commons Attributes provides an API to runtime metadata attributes. Attributes are specified as doclet tags and then compiled into the classpath where they can be accessed at runtime (without requiring the source). The aim is to provide a framework similar to .NET attributes. QDox is used to extract the JavaDoc tags from the source files.
GWT-maven-plugin
The gwt-maven-plugin provides support for GWT projects, including running the GWT developer tools (the compiler, shell and i18n generation) and performing support operations to help developers make GWT fit more closely in with their standard JEE web application development (debugging, managing the embedded server, running noserver, merging web.xml, generating I18N interfaces, generating Async GWT-RPC interfaces, and more) and environment (Eclipse IDE). QDox is used to generate the Async GWT-RPC interfaces based on their Service-classes.
Ivory
Ivory provides easy integration between your exiting Java classes, Avalon services, and Axis. It allows easy deployment of soap services with none of the WSDD configuration that Axis normally mandates. Attributes are used to provide additional hints to Ivory about Java classes that cannot be determined via reflection.
maven-javadoc-plugin
The Javadoc Plugin uses the Javadoc tool to generate javadocs for the specified project. When developers write code, they could forget to create (or update) the Javadoc comments. The <fix> and <test-fix> goals are interactive goals to fix the actual Javadoc comments.
Maven 2 & 3
Maven is a software project management and comprehension tool. QDox is used for extraction of Javadoc tags from source files to generate plugin descriptors
Mock Maker
Mock Maker is a tool for automatically generating mock objects from custom classes to aid in testing the untestable. This supports the practises of Test Driven Development and eXtreme Programming. Mock Maker scans the source repository for any class/interface marked with the @mock JavaDoc tag and automatically creates the Mock Object for this that matches the class definition.
Nanning
Nanning is an Aspect Oriented Programming (AOP) toolkit for Java that does not require a custom compiler. It uses dynamic proxies to weave in interceptors and mixins at runtime. QDox is used to allow aspects to be applied to classes by specifiying meta-data in doclet tags.
Paranamer
Paranamer a mechamism for accessing the parameter names of methods of Java classes compiled into jars. QDox is used to parse the source and generate the parameter names list.
Spring ME
A version of Spring that not only has a very small runtime footprint (none), but also is capable of running on small handheld devices, since it does not rely on reflection.
vDoclet
vDoclet is a framework for code-generation using Velocity templates, based on annotated Java source-code. vDoclet uses QDox to produce input-data for it's templates.
Voruta
Voruta is a data access framework for embedding SQL statements in Java methods using custom JavaDoc tags and dynamic code generation at runtime. QDox is used to parse metadata and CGLib to generate implementation at runtime.
XDoclet2
XDoclet2 is a framework for code-generation using Velocity or Jelly templates, based on annotated Java source-code. It is a rewrite of XDoclet.
XDoclet2 uses QDox to produce input-data for it's templates, as well as QDox' APITestCase to validate the generated sources.
QDox Usage
Entry Point
JavaProjectBuilder is the entry point to QDox. It is responsible for parsing source code, resolving imports and storing the data.
To create it, all you need to do is call the default constructor.
JavaProjectBuilder builder = new JavaProjectBuilder();
Reading Source Files
Java source code can then be added to the JavaProjectBuilder. Source can either be read one file at a time (using a java.io.Reader) or an entire source tree can be added recursively.
// Reading a single source file.
builder.addSource(new FileReader("MyFile.java"));
// Reading from another kind of input stream.
builder.addSource(new StringReader("package test; public class Hello {}"));
// Adding all .java files in a source tree (recursively).
builder.addSourceTree(new File("mysrcdir"));
Resolving Class Names
In order to resolve classes that have been imported using a wildcard (e.g. import java.util.*;), the ClassLibrary must be aware of other classes used in the project.
ClassLibrary has 4 ways to resolve classes:
- By looking at other sources that have been added.
- By searching through the supplied sourceFolders
- By looking in the current classpath (including the standard JRE classes).
- By looking at additional ClassLoaders specified at runtime.
All sources and sourcetrees added to the JavaProjectBuilder will be parsed. This is often much more than required. To increase efficiency use the ClassLibrary t
Related Skills
node-connect
338.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
338.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.6kCommit, push, and open a PR
