From a3f62b57ca9d7f1ef728b6c3647a613875057aee Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sat, 13 Apr 2024 11:22:11 +0200 Subject: [PATCH] BcelObjectType: Add experimental code to set source file name for reference Experimental code leading to undesired ripple effects elsewhere, requiring more rework which now I do not feel inclined to invest to perfect source file string representation for post-compile binary classes and aspects. Relates to #218. Signed-off-by: Alexander Kriegisch --- .../org/aspectj/weaver/bcel/BcelObjectType.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelObjectType.java index 7a40ed542..973d61b37 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelObjectType.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelObjectType.java @@ -159,10 +159,19 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate { // the only class in Java-1.4 with no superclasses isObject = (javaClass.getSuperclassNameIndex() == 0); ensureAspectJAttributesUnpacked(); - // if (sourceContext instanceof SourceContextImpl) { - // ((SourceContextImpl)sourceContext).setSourceFileName(javaClass. - // getSourceFileName()); - // } + + // Experimental code leading to undesired ripple effects elsewhere, requiring more rework + /* + final String fileName = javaClass.getFileName(); + final String sourceFileName = javaClass.getSourceFileName(); + if (fileName == null || !fileName.endsWith(".class")) + setSourcefilename(sourceFileName); + else if (sourceFileName == null || sourceFileName.isEmpty() || sourceFileName.endsWith(".class")) + setSourcefilename(fileName); + else + setSourcefilename(fileName + " (from " + sourceFileName + ")"); + */ + setSourcefilename(javaClass.getSourceFileName()); } -- 2.39.5