Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2019-03-06 14:43:47 +0000
committerAndrey Loskutov2019-03-12 16:30:30 +0000
commitff39809ae9a6095793e47bc5e9a7e26a302ad7f5 (patch)
treea0b42a5905eafcea5c8a20570a8b6b99a4264848
parent5c21f9ca8bc06a20cab41262b934b74bd15de2e4 (diff)
downloadeclipse.jdt.core-ff39809ae9a6095793e47bc5e9a7e26a302ad7f5.tar.gz
eclipse.jdt.core-ff39809ae9a6095793e47bc5e9a7e26a302ad7f5.tar.xz
eclipse.jdt.core-ff39809ae9a6095793e47bc5e9a7e26a302ad7f5.zip
Bug 541864 - InnerClassInfo.getSourceName() is not thread-safeI20190312-1800
Allow threads read the char[] fields content only after the corresponding flags are flipped *after* reading is done, not before. This will avoid reads of uninitialized char[] data fields *without locking* if multiple threads are entering get*() methods at the cost that the data could be initialized multiple times. Fortunately, the data is static so the result will be identical and the probability of parallel initialization is pretty low to seriously affect performance. Change-Id: Id96471940ebb6e8b3a839fb8c9a7aade9a179ea4 Signed-off-by: Andrey Loskutov <loskutov@gmx.de> Also-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
-rw-r--r--org.eclipse.jdt.core/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java12
-rw-r--r--org.eclipse.jdt.core/pom.xml2
3 files changed, 8 insertions, 8 deletions
diff --git a/org.eclipse.jdt.core/META-INF/MANIFEST.MF b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
index 2ee2f7d3c5..e39841255b 100644
--- a/org.eclipse.jdt.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Main-Class: org.eclipse.jdt.internal.compiler.batch.Main
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core; singleton:=true
-Bundle-Version: 3.17.0.qualifier
+Bundle-Version: 3.17.100.qualifier
Bundle-Activator: org.eclipse.jdt.core.JavaCore
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java
index 5539c2938f..b57f0aeb74 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java
@@ -28,9 +28,9 @@ public class InnerClassInfo extends ClassFileStruct implements IBinaryNestedType
private char[] outerClassName;
private char[] innerName;
private int accessFlags = -1;
- private boolean readInnerClassName = false;
- private boolean readOuterClassName = false;
- private boolean readInnerName = false;
+ private boolean readInnerClassName;
+ private boolean readOuterClassName;
+ private boolean readInnerName;
public InnerClassInfo(byte classFileBytes[], int offsets[], int offset) {
super(classFileBytes, offsets, offset);
@@ -43,7 +43,6 @@ public InnerClassInfo(byte classFileBytes[], int offsets[], int offset) {
public char[] getEnclosingTypeName() {
if (!this.readOuterClassName) {
// read outer class name
- this.readOuterClassName = true;
if (this.outerClassNameIndex != 0) {
int utf8Offset =
this.constantPoolOffsets[u2At(
@@ -51,6 +50,7 @@ public char[] getEnclosingTypeName() {
- this.structOffset;
this.outerClassName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
}
+ this.readOuterClassName = true;
}
return this.outerClassName;
@@ -69,12 +69,12 @@ public int getModifiers() {
public char[] getName() {
if (!this.readInnerClassName) {
// read the inner class name
- this.readInnerClassName = true;
if (this.innerClassNameIndex != 0) {
int classOffset = this.constantPoolOffsets[this.innerClassNameIndex] - this.structOffset;
int utf8Offset = this.constantPoolOffsets[u2At(classOffset + 1)] - this.structOffset;
this.innerClassName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
}
+ this.readInnerClassName = true;
}
return this.innerClassName;
}
@@ -86,11 +86,11 @@ public char[] getName() {
*/
public char[] getSourceName() {
if (!this.readInnerName) {
- this.readInnerName = true;
if (this.innerNameIndex != 0) {
int utf8Offset = this.constantPoolOffsets[this.innerNameIndex] - this.structOffset;
this.innerName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
}
+ this.readInnerName = true;
}
return this.innerName;
}
diff --git a/org.eclipse.jdt.core/pom.xml b/org.eclipse.jdt.core/pom.xml
index 1564c0bb03..c73581eb2d 100644
--- a/org.eclipse.jdt.core/pom.xml
+++ b/org.eclipse.jdt.core/pom.xml
@@ -18,7 +18,7 @@
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
- <version>3.17.0-SNAPSHOT</version>
+ <version>3.17.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>

Back to the top