Menu

ClassViewerDesign

James Harris

Class Viewer Overall Design

Component: Class Viewer (public-API quick reference)
Status: ✅ Released 6.0.0 (maintenance / packaging refresh; no new features)
Last Updated: August 26, 2026
Author: jstevh

Class Viewer is a lightweight, stateless Java desktop tool for looking at the public surface of a class: methods, constructors, fields, superclass, and interfaces. It is not a decompiler and not an IDE. It uses reflection, a small Swing UI, and an editable XML config to jump from a listed method to JavaDocs in a browser, or to local source in a text editor.

On SourceForge since February 2004. Current packaged entry point: com.jstevh.viewer.ClassViewer.

Core Design Principles

  • Public surface only. The tool shows what java.lang.reflect exposes as public members. It does not parse bytecode, reconstruct private implementation, or rewrite source.
  • Stateless runtime. No session store, no project file, no installer. Configuration lives in ClassViewerConfig.xml beside the working directory. Restart to pick up config edits.
  • Config-driven documentation routing. Package names map to documentation groups (web JavaDocs or local files). Browser and editor paths are user-editable XML, not compiled constants.
  • Classpath is the world. The JVM classpath is the set of classes the tool can load. Run the executable JAR for a quick look; unpack and run from the command line when you need your own classes and jars on the classpath.
  • Small, readable modules. Eight Java source files compile to 26 class files. Two packages: com.jstevh.viewer and com.jstevh.tools.
  • External tools, not embedded ones. JavaDocs open in the configured browser. Local source opens in the configured editor. Class Viewer stays a viewer.

High-Level Architecture

User / CLI argument
        
        
┌───────────────────────────────────────┐
  ClassViewer                          
  Swing UI + main + launch helpers     
  VERSION = 6.0.0                      
└───────────────┬───────────────────────┘
                
        ┌───────┴────────┐
                        
┌───────────────┐  ┌─────────────────────┐
  DirManager       ClassInfo          
  + SAXDirParser    java.lang.reflect  
  reads XML        load class         
└───────┬───────┘    list members       
                    search methods     
                  └──────────┬──────────┘
ClassViewerConfig.xml         
  Local: browser, editor      
  Documentation groups   StringTools / StringList
                        method-name search
        
 Browser (JavaDocs URL)   Editor (local source)
 Runtime.exec launch      optional line-number arg

Key Design Components

Class Package Role
ClassViewer com.jstevh.viewer Main window, menus, font-size range, browser/editor launch, main
ClassInfo com.jstevh.viewer Loads a class by name; lists public fields, methods, constructors, interfaces, superclass; method search
DirManager com.jstevh.viewer Owns config load state; exposes package list, browser, editor, font preference
SAXDirParser com.jstevh.viewer SAX parse of ClassViewerConfig.xml (DefaultHandler)
MethodData com.jstevh.viewer Small interface: package, class, method name for a found method
StringList com.jstevh.tools Minimal string collection used by config and search
StringTools com.jstevh.tools searchStrings / removeStrings helpers for method search and signature cleanup

Runtime Flow (Current Implementation)

  1. Launch via java -jar ClassViewer-6.0.0.jar (or ClassViewer.bat on Windows), optionally with a class name argument such as java.lang.String.
  2. DirManager + SAXDirParser read ClassViewerConfig.xml from the directory the process was started in. Missing XML is a known failure mode: the app will not resolve packages or tools without that file beside the launch directory.
  3. User types or pastes a fully qualified class name (or uses the CLI argument). ClassInfo calls Class.forName / reflection against the current classpath.
  4. UI shows:
  5. class package and name
  6. superclass
  7. implemented interfaces
  8. public constructors
  9. public fields
  10. public methods
  11. Free-text search filters public method names through ClassInfo.srchMethods + StringTools.
  12. Selecting documentation:
  13. package is looked up in the config Documentation/Group/Names map
  14. if the group is web-backed, callBrowser opens the configured browser at the JavaDocs base URL
  15. if the group is local (<Local>Yes</Local>) and an editor is configured, the local file is opened
  16. if <acceptsLineNumber>Yes</acceptsLineNumber>, the editor is invoked with the configured line-number parameter (gedit is the documented example)

Configuration Model

ClassViewerConfig.xml is the only user-facing configuration surface. It is ordinary XML and is meant to be edited in a text editor.

<Base>
  <Local>            browser, editor, line-number flag, font preference
  <Documentation>
    <Group>          description, owner, web-or-local location, package names

Local block

  • BrowserLoc — executable used for JavaDocs (Windows 6.0.0 package: explorer.exe)
  • Editor — executable used for local source (Windows 6.0.0 package: notepad.exe)
  • acceptsLineNumber / parameter — whether the editor can be pointed at a line
  • LargerFonts — raises the default font and the allowed increase/decrease range

Documentation groups

  • Each group has a JavaDocs base URL or a local-file flag, plus a list of package prefixes.
  • Packages beginning with java historically fall back to a default docs location when not listed.
  • The 6.0.0 Windows package ships three groups: Java SDK 8.0 (Oracle web docs), Java Enterprise / Swing (Oracle web docs), and Class Viewer itself (com.jstevh.viewer, com.jstevh.tools) as local.

The JAR is platform-independent. Windows vs Linux packages differ in this XML and in the launcher script, not in the viewer classes.

Launch and Classpath Model

Two supported ways to run, unchanged in spirit since the 5.x line:

Mode How Why
Executable JAR java -jar ClassViewer-6.0.0.jar or ClassViewer.bat Fast start; good for JDK classes already on the JRE
Unpacked jar -xf ClassViewer-6.0.0.jar then run com.jstevh.viewer.ClassViewer with a real classpath Required to inspect your classes and third-party jars

No installer is used or included. The app does not write back to the XML at runtime.

UI and Interaction Surface

Kept small on purpose:

  • Class-name entry and load
  • Results pane for public members
  • Method search
  • Font size within a fixed band (default 12→10..14, or larger-font mode 13→11..17)
  • Right-click copy from the results window to the system clipboard
  • Help links consolidated under the Help menu (Weblinks menu removed in 5.1.0 and not restored)
  • Optional CLI class name so the first screen can open already populated

Font limits live as ClassViewer.MAX_FONT_SIZE / MIN_FONT_SIZE, seeded from the XML LargerFonts flag.

Design Guarantees

Feature Status How it is implemented Benefit
Public-only view ✅ Done ClassInfo via java.lang.reflect Fast, honest API picture; no decompiler drift
Method search ✅ Done srchMethods + StringTools.searchStrings Quick filter without leaving the tool
Superclass + interfaces ✅ Done ClassInfo.getSuperClassName / printInterfaces Immediate type-context
JavaDocs jump ✅ Done Package→group map + callBrowser Opens docs at the selected method when the URL scheme allows
Local source jump ✅ Done Local group + editor + optional line number Same gesture for your own code
Editable config ✅ Done ClassViewerConfig.xml + SAXDirParser No rebuild to change browser, editor, or docs roots
Stateless ✅ Done No session files; XML is input only Predictable; safe to copy the folder
Small artifact ✅ Done ~44 KB JAR; eight source files Easy to audit and ship
Java 21 package verify ✅ Done (6.0.0) OpenJDK 21 compile + executable JAR Current-runtime confidence
Java 8 runtime claim ☐ Confirm separately Source is still Java-era; 6.0.0 did not re-certify Java 8 Avoid a false compatibility promise

What 6.0.0 Changed (and Did Not)

6.0.0 is a maintenance and packaging release. Functional behavior is the existing Class Viewer tool, not a new product.

Verified in the 6.0.0 package:

  • Eight Java source files compile on OpenJDK 21
  • Build produces 26 class files and a runnable executable JAR
  • Main-Class: com.jstevh.viewer.ClassViewer
  • ClassViewerConfig.xml is well-formed and shipped beside the JAR
  • Windows zip includes launcher, licenses (COPYING, COPYING.LESSER), NOTICE, SHA256SUMS, README.md, RELEASE-NOTES.md

Intentionally out of scope for 6.0.0:

  • New features
  • Cleaning raw reflection types
  • Replacing deprecated AccessControlException and Runtime.exec(String)
  • Constructor this escape warning
  • Claiming a freshly tested Java 8 runtime

Those warnings still compile and package. They are recorded so a later cleanup pass can be honest about cost.

Package Layout (6.0.0)

com.jstevh.viewer
    ClassViewer.java      UI + process launch
    ClassInfo.java        reflection model
    DirManager.java       config façade
    SAXDirParser.java     XML parse
    MethodData.java       found-method handle

com.jstevh.tools
    StringList.java       small list
    StringTools.java      search / strip helpers

Distribution (Windows 6.0.0 folder):

  • ClassViewer-6.0.0.jar
  • ClassViewerConfig.xml
  • ClassViewer.bat
  • README.md, RELEASE-NOTES.md, NOTICE
  • COPYING, COPYING.LESSER
  • SHA256SUMS

Progress & Next Steps (as of August 26, 2026)

  • ✅ 6.0.0 packaged and published on SourceForge
  • ✅ Java 21 compile + executable JAR verified
  • ✅ Windows launcher + XML + license bundle
  • ✅ Linux package also published
  • ☐ Confirm Java 8 runtime separately before restating a legacy-runtime guarantee
  • ☐ Optional later cleanup of recorded javac -Xlint warnings (not a feature release)
  • ☐ Create [[Configuration Design]] wiki page (XML schema and package-mapping rules)
  • ☐ Create [[Launch and Classpath]] wiki page (jar vs unpacked, common failure modes)

[[Home]]
[[Configuration Design]] (planned next)


This page is part of the Class Viewer design documentation. Written against the 6.0.0 SourceForge package (trunk assembled 2026-08-26). Project: https://sourceforge.net/projects/classviewer/