diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathAttribute.java
index 1c66864..20e7152 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathAttribute.java
@@ -77,10 +77,11 @@
*
* - Encoding explicitly set on the source file (java or zip), i.e.
org.eclipse.core.resources.IFile#getCharset(false)
* - Encoding set on the corresponding classpath entry
- * - If the source attachment is a member of the project, then the project's default charSet
- * - Workspace default charSet
+ * - If the source attachment is a folder, then the encoding determined by the file content if detectable
+ * - If the source attachment is in the workspace, then the encoding of the enclosing resources
*
*
+ * @see org.eclipse.core.resources.IFile#getCharset()
* @since 3.8
*/
String SOURCE_ATTACHMENT_ENCODING = "source_encoding"; //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
index c1c3e86..8c14620 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
@@ -246,11 +246,11 @@
int anonymousCounter;
int anonymousClassName;
+ String encoding;
+ String defaultEncoding;
/**
*Options to be used
*/
- String encoding;
- String defaultEncoding;
Map options;
/**
@@ -1027,6 +1027,7 @@
try {
// Order of preference: charSet supplied, this.encoding or this.defaultEncoding in that order
try {
+ // Use the implicit encoding only when the source attachment's encoding hasn't been explicitly set.
charSet = ((IFile) res).getCharset(this.encoding == null);
} catch (CoreException e) {
// Ignore