https://github.com/soabase/asm-mirror-descriptor
Addition to OW2 ASM library to support generating descriptors and signatures from TypeMirrors/Elements
https://github.com/soabase/asm-mirror-descriptor
annotation-processing annotation-processor asm java
Last synced: 3 months ago
JSON representation
Addition to OW2 ASM library to support generating descriptors and signatures from TypeMirrors/Elements
- Host: GitHub
- URL: https://github.com/soabase/asm-mirror-descriptor
- Owner: soabase
- License: apache-2.0
- Created: 2019-03-21T19:02:26.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-22T14:54:40.000Z (about 7 years ago)
- Last Synced: 2025-07-05T20:21:32.540Z (9 months ago)
- Topics: annotation-processing, annotation-processor, asm, java
- Language: Java
- Size: 110 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/soabase/asm-mirror-descriptor)
[](http://search.maven.org/#search%7Cga%7C1%7Casm-mirror-descriptor)
# ASM Mirror Descriptor
Addition to [OW2 ASM library](https://asm.ow2.io) to support generating descriptors and signatures from TypeMirrors/Elements.
## Background
The ASM library has classes that can process Java class files through a Visitor style API allowing users to examine or modify
any part of a class. The ASM Mirror project adds comparable classes to do the same with [TypeMirror](https://docs.oracle.com/javase/8/docs/api/javax/lang/model/type/TypeMirror.html)
and [Element](https://docs.oracle.com/javase/8/docs/api/javax/lang/model/element/Element.html) instances used during [Annotation
Processing](https://docs.oracle.com/javase/7/docs/api/javax/annotation/processing/Processor.html).
## Corresponding Classes
| ASM Class | ASM Mirror Class | Description |
| --------- | ---------------- | ----------- |
| ClassReader | MirrorClassReader | A parser to make a ClassVisitor visit a TypeMirror/Element instance. |
| Type | MirrorType | A Java field or method type. |
## Additional Classes
The Java spec requires "signatures" for generic descriptors. The ASM library has some internal utilities for generating these.
The ASM mirror library provides `SignatureMirrorType` to generate generic signatures from TypeMirrors/Elements.
## Usage
Usage is the same as for the ASM library except you pass in a TypeMirror element from an annotation processor instead of a class file. ASM Mirror calls a standard ASM [ClassVistor](https://asm.ow2.io/javadoc/org/objectweb/asm/ClassVisitor.html) E.g.
```java
MirrorClassReader reader = new MirrorClassReader(processingEnv, element);
reader.accept(myClassVisitor); // standard ASM ClassVisitor
```