3434import java .util .function .Consumer ;
3535import java .util .stream .Stream ;
3636
37+ import com .oracle .graal .pointsto .infrastructure .WrappedJavaMethod ;
3738import com .oracle .svm .core .SubstrateOptions ;
39+ import com .oracle .svm .hosted .substitute .SubstitutionMethod ;
3840import org .graalvm .compiler .code .CompilationResult ;
3941import org .graalvm .compiler .code .SourceMapping ;
4042import org .graalvm .compiler .debug .DebugContext ;
4143import org .graalvm .compiler .graph .NodeSourcePosition ;
4244import org .graalvm .nativeimage .ImageSingletons ;
4345
4446import com .oracle .graal .pointsto .infrastructure .OriginalClassProvider ;
45- import com .oracle .graal .pointsto .meta .AnalysisType ;
4647import com .oracle .objectfile .debuginfo .DebugInfoProvider ;
4748import com .oracle .svm .core .graal .code .SubstrateBackend ;
4849import com .oracle .svm .hosted .image .sources .SourceManager ;
@@ -310,22 +311,11 @@ public int line() {
310311
311312 @ SuppressWarnings ("try" )
312313 private void computeFullFilePath () {
313- ResolvedJavaType declaringClass = method . getDeclaringClass ();
314+ ResolvedJavaType declaringClass = getDeclaringClass ();
314315 Class <?> clazz = null ;
315316 if (declaringClass instanceof OriginalClassProvider ) {
316317 clazz = ((OriginalClassProvider ) declaringClass ).getJavaClass ();
317318 }
318- /*
319- * HostedType wraps an AnalysisType and both HostedType and AnalysisType punt calls to
320- * getSourceFilename to the wrapped class so for consistency we need to do the path
321- * lookup relative to the doubly unwrapped HostedType or singly unwrapped AnalysisType.
322- */
323- if (declaringClass instanceof HostedType ) {
324- declaringClass = ((HostedType ) declaringClass ).getWrapped ();
325- }
326- if (declaringClass instanceof AnalysisType ) {
327- declaringClass = ((AnalysisType ) declaringClass ).getWrapped ();
328- }
329319 SourceManager sourceManager = ImageSingletons .lookup (SourceManager .class );
330320 try (DebugContext .Scope s = debugContext .scope ("DebugCodeInfo" , declaringClass )) {
331321 fullFilePath = sourceManager .findAndCacheSource (declaringClass , clazz , debugContext );
@@ -334,6 +324,20 @@ private void computeFullFilePath() {
334324 }
335325 }
336326
327+ private ResolvedJavaType getDeclaringClass () {
328+ ResolvedJavaMethod wrappedMethod = method ;
329+ while (wrappedMethod instanceof WrappedJavaMethod ) {
330+ wrappedMethod = ((WrappedJavaMethod ) wrappedMethod ).getWrapped ();
331+ }
332+ ResolvedJavaType declaringClass ;
333+ if (wrappedMethod instanceof SubstitutionMethod ) {
334+ declaringClass = ((SubstitutionMethod ) wrappedMethod ).getAnnotated ().getDeclaringClass ();
335+ } else {
336+ declaringClass = wrappedMethod .getDeclaringClass ();
337+ }
338+ return declaringClass ;
339+ }
340+
337341 }
338342
339343 /**
0 commit comments