# java-classmate
**Repository Path**: mirrors_FasterXML/java-classmate
## Basic Information
- **Project Name**: java-classmate
- **Description**: Library for introspecting generic type information of types, member/static methods, fields. Especially useful for POJO/Bean introspection.
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-08-08
- **Last Updated**: 2026-05-02
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## Overview
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).
Project is licensed under [Apache 2](http://www.apache.org/licenses/LICENSE-2.0.txt).
## Status
| Type | Status |
| ---- | ------ |
| Build (CI) | [](https://github.com/FasterXML/java-classmate/actions/workflows/main.yml) |
| Artifact | [](https://maven-badges.herokuapp.com/maven-central/com.fasterxml/classmate/) |
| OSS Sponsorship | [](https://tidelift.com/subscription/pkg/maven-com-fasterxml-classmate?utm_source=maven-com-fasterxml-classmate&utm_medium=referral&utm_campaign=readme) |
| JavaDocs | [](http://www.javadoc.io/doc/com.fasterxml/classmate) |
| Code coverage (master) | [](https://codecov.io/github/FasterXML/java-classmate?branch=master) |
| OpenSSF Score | [](https://securityscorecards.dev/viewer/?uri=github.com/FasterXML/java-classmate) |
## Support
### Community support
Classmate is supported by the community via the mailing list: [java-classmate-user](https://groups.google.com/forum/#!forum/java-classmate-users)
### Enterprise support
Available as part of the Tidelift Subscription.
The maintainers of `classmate` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/maven-com-fasterxml-classmate?utm_source=maven-com-fasterxml-classmate&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
## Contributing
Contributions are welcome (of course!); we require a simple one-page CLA to help simplify distribution
(corporate users want to know how contributions are handled), one per contributor. Feel free to submit
Pull Requests and we will get you through this formality.
One special case is that for reporting possible security issues ("vulnerabilities"), we recommend filing a
[Tidelift security contact](https://tidelift.com/security) (NOTE: you do NOT have to be a subscriber to do this).
## Documentation
[Project wiki](/../../wiki) has Javadocs.
External links that may help include:
* [Resolving Generic Types with Classmate](http://www.cowtowncoder.com/blog/archives/2012/04/entry_471.html) (some simple usage examples)
* [Problem with java.lang.reflect.Type](http://www.cowtowncoder.com/blog/archives/2010/12/entry_436.html) (explanation of issues ClassMate was written to solve)
-----
## Compatibility
#### JDK baseline
ClassMate versions up to 1.6 require Java 6 to run.
ClassMate versions 1.7 and above require Java 8 to run
#### JPMS compatibility
ClassMate versions 1.5 and above contain `module-info.class` information to work with JPMS.
Module name to use is `com.fasterxml.classmate`.
## Usage
### Maven dependency
To use ClassMate via Maven, include following dependency:
```xml
com.fasterxmlclassmate1.7.3
```
### Non-Maven
Downloads available from [Project wiki](../../wiki).
### Resolving Class type information
Main class used for fully resolving type information for classes is `com.fasterxml.classmate.TypeResolver`.
TypeResolver does simple caching for resolved supertypes (since many subtypes resolve to smaller set of supertypes, typically). Since all access to shared data is synchronized, a single `TypeResolver` instance is typically shared for a single system (as a plain old static singleton): there are no benefits to instantiating more instances.
Its main resolution methods are:
* `resolve(Class cls)`: given a plain old class, will use generic type information that super type declarations (extends, implements) may have.
* `resolve(GenericType)`: given a subtype of `GenericType` (which uses ["Super-type Token" pattern](http://gafter.blogspot.com/2006/12/super-type-tokens.html)), fully resolve type information
* `resolve(Class> baseType, Class> typeParameter1, ... , Class> typeParameter2)`: given base type (like `List.class`) and zero or more type parameters (either as `Class` es to resolve, or as `ResolvedType` s), resolves type information
Result in all these cases is an instance of `ResolvedType`, which you can think of as generic type information containing replacement for `java.lang.Class`. It is also the starting point for resolving member (constructor, field, method) information.
### Resolving Type parameters for a class
While finding type parameters for specific class is relatively easy (using `getTypeParameters`), what you more commonly need to know is type parameters for a type implemented or extended.
Specifically, consider case of:
public class StringIntMap extends HashMap { }
where you would want to know `key` and `value` types of your Map sub-type.
The first step is the same:
ResolvedType type = typeResolver.resolve(StringIntMap.class);
and to find parameter bindings for `java.util.Map`, you will use:
List mapParams = type.typeParametersFor(Map.class);
ResolvedType keyType = mapParams.get(0);
ResolvedType valueType = mapParams.get(1);
Note: if types were left unspecified (like, say, `public class MyMap extends Map`), you will always get resolved types based on bounds: in this case, it would be equivalent to parameterization of `Map