|
16 | 16 | import org.hibernate.models.spi.AnnotationDescriptor;
|
17 | 17 | import org.hibernate.models.spi.ClassDetails;
|
18 | 18 | import org.hibernate.models.spi.ClassDetailsRegistry;
|
| 19 | +import org.hibernate.models.spi.ClassLoading; |
19 | 20 | import org.hibernate.models.spi.FieldDetails;
|
20 | 21 | import org.hibernate.models.spi.MethodDetails;
|
21 | 22 | import org.hibernate.models.spi.MutableClassDetails;
|
22 | 23 | import org.hibernate.models.spi.MutableMemberDetails;
|
23 | 24 | import org.hibernate.models.spi.RecordComponentDetails;
|
| 25 | +import org.hibernate.models.spi.SourceModelContext; |
24 | 26 | import org.hibernate.models.spi.TypeDetails;
|
25 | 27 |
|
26 | 28 | import net.bytebuddy.description.annotation.AnnotationSource;
|
|
31 | 33 | /**
|
32 | 34 | * @author Steve Ebersole
|
33 | 35 | */
|
34 |
| -public class MethodDetailsImpl extends AbstractAnnotationTarget implements MethodDetails, MutableMemberDetails { |
| 36 | +public class MethodDetailsImpl |
| 37 | + extends AbstractAnnotationTarget |
| 38 | + implements MethodDetails, MutableMemberDetails { |
35 | 39 | private final MethodDescription methodDescription;
|
36 | 40 | private final MethodKind methodKind;
|
37 | 41 | private final TypeDetails type;
|
@@ -137,44 +141,21 @@ public int getModifiers() {
|
137 | 141 | @Override
|
138 | 142 | public Method toJavaMember() {
|
139 | 143 | if ( underlyingMethod == null ) {
|
140 |
| - underlyingMethod = resolveJavaMember(); |
| 144 | + underlyingMethod = toJavaMember( |
| 145 | + declaringType.toJavaClass(), |
| 146 | + getModelContext().getClassLoading(), |
| 147 | + getModelContext() |
| 148 | + ); |
141 | 149 | }
|
142 | 150 | return underlyingMethod;
|
143 | 151 | }
|
144 | 152 |
|
145 | 153 | @Override
|
146 |
| - public MethodDetails asMethodDetails() { |
147 |
| - return this; |
148 |
| - } |
149 |
| - |
150 |
| - @Override |
151 |
| - public MutableMemberDetails asMemberDetails() { |
152 |
| - return this; |
153 |
| - } |
154 |
| - |
155 |
| - @Override |
156 |
| - public FieldDetails asFieldDetails() { |
157 |
| - throw new IllegalCastException( "MethodDetails cannot be cast as FieldDetails" ); |
158 |
| - } |
159 |
| - |
160 |
| - @Override |
161 |
| - public RecordComponentDetails asRecordComponentDetails() { |
162 |
| - throw new IllegalCastException( "MethodDetails cannot be cast as FieldDetails" ); |
163 |
| - } |
164 |
| - |
165 |
| - @Override |
166 |
| - public MutableClassDetails asClassDetails() { |
167 |
| - throw new IllegalCastException( "MethodDetails cannot be cast as FieldDetails" ); |
168 |
| - } |
169 |
| - |
170 |
| - @Override |
171 |
| - public <A extends Annotation> AnnotationDescriptor<A> asAnnotationDescriptor() { |
172 |
| - throw new IllegalCastException( "MethodDetails cannot be cast as AnnotationDescriptor" ); |
173 |
| - } |
174 |
| - |
175 |
| - private Method resolveJavaMember() { |
176 |
| - final Class<?> declaringTypeClass = declaringType.toJavaClass(); |
177 |
| - methods: for ( Method method : declaringTypeClass.getDeclaredMethods() ) { |
| 154 | + public Method toJavaMember( |
| 155 | + Class<?> declaringJavaClass, |
| 156 | + ClassLoading classLoading, |
| 157 | + SourceModelContext modelContext) { |
| 158 | + methods: for ( Method method : declaringJavaClass.getDeclaredMethods() ) { |
178 | 159 | if ( !method.getName().equals( getName() ) ) {
|
179 | 160 | continue;
|
180 | 161 | }
|
@@ -204,6 +185,36 @@ private Method resolveJavaMember() {
|
204 | 185 | );
|
205 | 186 | }
|
206 | 187 |
|
| 188 | + @Override |
| 189 | + public MethodDetails asMethodDetails() { |
| 190 | + return this; |
| 191 | + } |
| 192 | + |
| 193 | + @Override |
| 194 | + public MutableMemberDetails asMemberDetails() { |
| 195 | + return this; |
| 196 | + } |
| 197 | + |
| 198 | + @Override |
| 199 | + public FieldDetails asFieldDetails() { |
| 200 | + throw new IllegalCastException( "MethodDetails cannot be cast as FieldDetails" ); |
| 201 | + } |
| 202 | + |
| 203 | + @Override |
| 204 | + public RecordComponentDetails asRecordComponentDetails() { |
| 205 | + throw new IllegalCastException( "MethodDetails cannot be cast as FieldDetails" ); |
| 206 | + } |
| 207 | + |
| 208 | + @Override |
| 209 | + public MutableClassDetails asClassDetails() { |
| 210 | + throw new IllegalCastException( "MethodDetails cannot be cast as FieldDetails" ); |
| 211 | + } |
| 212 | + |
| 213 | + @Override |
| 214 | + public <A extends Annotation> AnnotationDescriptor<A> asAnnotationDescriptor() { |
| 215 | + throw new IllegalCastException( "MethodDetails cannot be cast as AnnotationDescriptor" ); |
| 216 | + } |
| 217 | + |
207 | 218 | @Override
|
208 | 219 | public String toString() {
|
209 | 220 | return String.format(
|
|
0 commit comments