@@ -2539,7 +2539,7 @@ interface Dispatcher {
25392539 * @param type The type to represent.
25402540 * @return A suitable annotation reader.
25412541 */
2542- AnnotationReader resolveSuperClass (Class <?> type );
2542+ AnnotationReader resolveSuperClassType (Class <?> type );
25432543
25442544 /**
25452545 * Resolves a loaded type's interface type's type annotations.
@@ -2548,15 +2548,15 @@ interface Dispatcher {
25482548 * @param index The index of the interface.
25492549 * @return A suitable annotation reader.
25502550 */
2551- AnnotationReader resolveInterface (Class <?> type , int index );
2551+ AnnotationReader resolveInterfaceType (Class <?> type , int index );
25522552
25532553 /**
25542554 * Resolves a loaded field's type's type annotations.
25552555 *
25562556 * @param field The field to represent.
25572557 * @return A suitable annotation reader.
25582558 */
2559- AnnotationReader resolve (Field field );
2559+ AnnotationReader resolveFieldType (Field field );
25602560
25612561 /**
25622562 * Resolves a loaded method's return type's type annotations.
@@ -2593,6 +2593,14 @@ interface Dispatcher {
25932593 */
25942594 Generic resolveReceiverType (AccessibleObject executable );
25952595
2596+ /**
2597+ * Resolves the annotated type as generic type description.
2598+ *
2599+ * @param annotatedType The loaded annotated type.
2600+ * @return A description of the supplied annotated type.
2601+ */
2602+ Generic resolve (AnnotatedElement annotatedType );
2603+
25962604 /**
25972605 * A dispatcher for {@link AnnotationReader}s on a legacy VM that does not support type annotations.
25982606 */
@@ -2609,17 +2617,17 @@ public AnnotationReader resolveTypeVariable(TypeVariable<?> typeVariable) {
26092617 }
26102618
26112619 @ Override
2612- public AnnotationReader resolveSuperClass (Class <?> type ) {
2620+ public AnnotationReader resolveSuperClassType (Class <?> type ) {
26132621 return NoOp .INSTANCE ;
26142622 }
26152623
26162624 @ Override
2617- public AnnotationReader resolveInterface (Class <?> type , int index ) {
2625+ public AnnotationReader resolveInterfaceType (Class <?> type , int index ) {
26182626 return NoOp .INSTANCE ;
26192627 }
26202628
26212629 @ Override
2622- public AnnotationReader resolve (Field field ) {
2630+ public AnnotationReader resolveFieldType (Field field ) {
26232631 return NoOp .INSTANCE ;
26242632 }
26252633
@@ -2643,6 +2651,11 @@ public Generic resolveReceiverType(AccessibleObject executable) {
26432651 return UNDEFINED ;
26442652 }
26452653
2654+ @ Override
2655+ public Generic resolve (AnnotatedElement annotatedType ) {
2656+ throw new IllegalStateException ("Loaded annotated type cannot be represented on this VM" );
2657+ }
2658+
26462659 @ Override
26472660 public String toString () {
26482661 return "TypeDescription.Generic.AnnotationReader.Dispatcher.ForLegacyVm." + name ();
@@ -2753,17 +2766,17 @@ public AnnotationReader resolveTypeVariable(TypeVariable<?> typeVariable) {
27532766 }
27542767
27552768 @ Override
2756- public AnnotationReader resolveSuperClass (Class <?> type ) {
2769+ public AnnotationReader resolveSuperClassType (Class <?> type ) {
27572770 return new AnnotatedSuperClass (type );
27582771 }
27592772
27602773 @ Override
2761- public AnnotationReader resolveInterface (Class <?> type , int index ) {
2774+ public AnnotationReader resolveInterfaceType (Class <?> type , int index ) {
27622775 return new AnnotatedInterfaceType (type , index );
27632776 }
27642777
27652778 @ Override
2766- public AnnotationReader resolve (Field field ) {
2779+ public AnnotationReader resolveFieldType (Field field ) {
27672780 return new AnnotatedFieldType (field );
27682781 }
27692782
@@ -2785,14 +2798,24 @@ public AnnotationReader resolveExceptionType(AccessibleObject executable, int in
27852798 @ Override
27862799 public Generic resolveReceiverType (AccessibleObject executable ) {
27872800 try {
2788- AnnotatedElement annotatedReceiver = (AnnotatedElement ) getAnnotatedReceiverType .invoke (executable );
2789- return annotatedReceiver == null
2790- ? UNDEFINED
2791- : Sort .describe ((java .lang .reflect .Type ) getType .invoke (annotatedReceiver ), new Resolved (annotatedReceiver ));
2801+ return resolve ((AnnotatedElement ) getAnnotatedReceiverType .invoke (executable ));
2802+ } catch (IllegalAccessException exception ) {
2803+ throw new IllegalStateException ("Cannot access java.lang.reflect.Executable#getAnnotatedReceiverType" , exception );
27922804 } catch (InvocationTargetException exception ) {
2793- throw new IllegalStateException ("Could not access receiver type" , exception );
2805+ throw new IllegalStateException ("Error invoking java.lang.reflect.Executable#getAnnotatedReceiverType" , exception .getCause ());
2806+ }
2807+ }
2808+
2809+ @ Override
2810+ public Generic resolve (AnnotatedElement annotatedType ) {
2811+ try {
2812+ return annotatedType == null
2813+ ? UNDEFINED
2814+ : Sort .describe ((java .lang .reflect .Type ) getType .invoke (annotatedType ), new Resolved (annotatedType ));
27942815 } catch (IllegalAccessException exception ) {
2795- throw new IllegalStateException ("Error when accessing receiver type" , exception .getCause ());
2816+ throw new IllegalStateException ("Cannot access java.lang.reflect.AnnotatedType#getType" , exception );
2817+ } catch (InvocationTargetException exception ) {
2818+ throw new IllegalStateException ("Error invoking java.lang.reflect.AnnotatedType#getType" , exception .getCause ());
27962819 }
27972820 }
27982821
@@ -5857,7 +5880,7 @@ public TypeDescription asErasure() {
58575880
58585881 @ Override
58595882 protected AnnotationReader getAnnotationReader () {
5860- return AnnotationReader .DISPATCHER .resolveSuperClass (type );
5883+ return AnnotationReader .DISPATCHER .resolveSuperClassType (type );
58615884 }
58625885 }
58635886
@@ -5892,7 +5915,7 @@ public TypeDescription asErasure() {
58925915
58935916 @ Override
58945917 protected AnnotationReader getAnnotationReader () {
5895- return AnnotationReader .DISPATCHER .resolve (field );
5918+ return AnnotationReader .DISPATCHER .resolveFieldType (field );
58965919 }
58975920 }
58985921
0 commit comments