Skip to content

Commit

Permalink
Enforce consistent lookup of class and file names
Browse files Browse the repository at this point in the history
  • Loading branch information
adinn authored and zakkak committed Aug 4, 2020
1 parent d764140 commit 2db12f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ private class NativeImageDebugCodeInfo implements DebugCodeInfo {
this.method = method;
HostedType declaringClass = method.getDeclaringClass();
Class<?> clazz = declaringClass.getJavaClass();
this.javaType = declaringClass.getWrapped();
/*
* HostedType wraps an AnalysisType and both HostedType and AnalysisType punt calls to
* getSourceFilename to the wrapped class so for consistency we need to do the path
* lookup relative to the doubly unwrapped HostedType.
*/
this.javaType = declaringClass.getWrapped().getWrapped();
this.compilation = compilation;
SourceManager sourceManager = ImageSingletons.lookup(SourceManager.class);
try (DebugContext.Scope s = debugContext.scope("DebugCodeInfo", declaringClass)) {
Expand Down Expand Up @@ -309,8 +314,9 @@ private void computeFullFilePathAndCachePath() {
clazz = ((OriginalClassProvider) declaringClass).getJavaClass();
}
/*
* HostedType and AnalysisType punt calls to getSourceFilename to the wrapped class so
* for consistency we need to do the path lookup relative to the wrapped class.
* HostedType wraps an AnalysisType and both HostedType and AnalysisType punt calls to
* getSourceFilename to the wrapped class so for consistency we need to do the path
* lookup relative to the doubly unwrapped HostedType or singly unwrapped AnalysisType.
*/
if (declaringClass instanceof HostedType) {
declaringClass = ((HostedType) declaringClass).getWrapped();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public Path getCachePathForSource(ResolvedJavaType resolvedType) {
* @return the file name or null if it the class cannot be associated with a source file
*/
private static String computeBaseName(ResolvedJavaType resolvedType) {
if (resolvedType.isPrimitive()) {
return null;
}
String fileName = resolvedType.getSourceFileName();
if (fileName == null) {
/* ok, try to construct it from the class name */
Expand Down

0 comments on commit 2db12f1

Please sign in to comment.