Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2020-10-29 16:14:11 +0000
committerAndrey Loskutov2020-10-31 10:04:33 +0000
commitaa94311cac69ae05bf1aec3a20a1def2f59d2174 (patch)
tree53ed121e99b6334412daf1f126874dfec05223bb
parentea5294dc19a540375326a27abd88047ea3b9e1a8 (diff)
downloadeclipse.jdt.core-Y20201103-1200.tar.gz
eclipse.jdt.core-Y20201103-1200.tar.xz
eclipse.jdt.core-Y20201103-1200.zip
Bug 565462 - SourceLookup + Java 11 + Find Duplicates brokenY20201103-1200Y20201102-1200I20201101-1800I20201031-1800
Provide a way for clients (like debugger) to determine if two non-equal class file objects point to the same physical storage. Change-Id: Ie00303661fd1e6ed5b84bb2a70d1f1da3629b096 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractClassFile.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractClassFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractClassFile.java
index d79b29bb6e..9a0cc01fba 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractClassFile.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractClassFile.java
@@ -160,6 +160,35 @@ public abstract class AbstractClassFile extends Openable implements IClassFile,
return elt;
}
+ /**
+ * Provide a way for clients (like debugger) to determine if two non-equal {@link AbstractClassFile} objects point
+ * to the same physical storage. The return value is constructed form the container path (if there is any) and the
+ * path of the class file itself (that could be either absolute or relative if it is inside container).
+ *
+ * @return some kind of unique class file identifier based on path information only. The return value may look like
+ * a path in a file system, but is not guaranteed to be a valid path that could be resolved via NIO API.
+ */
+ public String getPathIdentifier() {
+ JavaElement pkg = (JavaElement) getParent();
+ if (pkg instanceof JarPackageFragment) {
+ JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
+ String entryName = Util.concatWith(((PackageFragment) pkg).names, getElementName(), '/');
+ entryName = root.getClassFilePath(entryName);
+ String rootPath = root.getPath().toOSString();
+ if (org.eclipse.jdt.internal.compiler.util.Util.isJrt(rootPath)) {
+ // container + module + class
+ return rootPath + '/' + root.getElementName() + '/' +entryName;
+ } else {
+ // container + class
+ return rootPath + '/' + entryName;
+ }
+ } else {
+ IFile file = (IFile) resource();
+ IPath location = file.getLocation();
+ return location == null? file.getFullPath().toPortableString() : location.toOSString();
+ }
+ }
+
@Override
public byte[] getBytes() throws JavaModelException {
JavaElement pkg = (JavaElement) getParent();

Back to the top