This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
ClassMate is a zero-dependency Java library for accurately introspecting type information, including reliable resolution of generic type declarations for both classes ("types") and members (fields, methods and constructors). It exists to work around the shortcomings of java.lang.reflect.Type.
Use the Maven wrapper (./mvnw), not mvn.
./mvnw clean verify # full build + tests
./mvnw test # tests only
./mvnw test -Dtest=TestClassName # single test class
./mvnw test -Dtest=TestClassName#methodName # single test method
./mvnw clean package -DskipTests # build without tests- JaCoCo coverage report is generated in the
testphase:target/site/jacoco/index.html. - Surefire excludes
**/failing/*.java; put known-failing reproduction tests in acom.fasterxml.classmate.failingtest package (none exist currently). - Build targets Java 8 (
version.jdk=1.8); no language features newer than Java 8 insrc/main. CI (.github/workflows/main.yml) runs on Java 8, 17, 21 and 25. - Parent POM is
com.fasterxml:oss-parent. Release notes live inVERSION.txt.
- JPMS
module-infois hand-maintained insrc/moditect/module-info.javaand injected into the jar by the moditect plugin atpackage. Adding a new package requires updating it. - OSGi metadata (in
pom.xml) treatscom.fasterxml.classmate.utilas private, while JPMS exports it — keep both in mind when moving classes between packages.
TypeResolver.resolve(...)→ResolvedType(full generic info for a class, including supertypes andTypeBindings)MemberResolver.resolve(ResolvedType, AnnotationConfiguration, AnnotationOverrides)→ResolvedTypeWithMembersResolvedTypeWithMembersexposes resolved fields, member/static methods and constructors with fully bound generic types.
TypeResolver is stateful (caches resolved types), thread-safe, and meant to be shared. MemberResolver holds only configuration (filters, whether to include Object members, etc.) and is cheap to create.
com.fasterxml.classmate— public API (TypeResolver,MemberResolver,ResolvedType,TypeBindings,GenericType<T>super-type token, annotation configuration/overrides ("mix-ins"),Filter).types—ResolvedTypeimplementations: object/interface/array/primitive types, plusResolvedRecursiveTypeandTypePlaceHolderfor self-referential definitions likeEnum<E extends Enum<E>>.members—Raw*(unresolved) vs.Resolved*(generic-bound) members;HierarchicTyperepresents a type in the flattened hierarchy used during member resolution.util— caching and resolution helpers.ResolvedTypeCacheis abstract with two implementations:LRUTypeCache(default, synchronized, viaResolvedTypeCache.lruCache(200)) andConcurrentTypeCache(clears all entries when full).ClassStacktracks the in-progress resolution stack to detect recursion.
- Fields: from the type and all supertypes, minus fields masked by a same-named subclass field.
- Member methods: from the type and supertypes, minus overridden ones; interface methods are dropped when a class provides the implementation. Annotations from overridden methods are merged according to
AnnotationInclusion. - Constructors and static methods: only from the resolved type itself.
java.lang.Objectmembers are excluded by default (configurable onMemberResolver).- Only
RetentionPolicy.RUNTIMEannotations are visible.
- Unbound type parameters resolve to their bounds (often
Object), not to raw types. TypeResolver.resolve(Class baseType, Class... typeParams)andresolve(GenericType<T>)are the main ways to obtain parameterized types.
Tests mirror the main package layout under src/test/java/com/fasterxml/classmate/. TestReadme.java contains runnable versions of the README usage examples — keep it in sync when changing README examples.