summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAndreas Sewe2012-12-21 06:07:37 (EST)
committer Andreas Sewe2012-12-21 08:21:40 (EST)
commit31971b72fb79d5f3ffbb2b575d0d89e5aaf1caa5 (patch)
tree54a02c3f408d9215f12331dac1450df34f8a848b
parent6d4480a24349267ba0fe49ba10c0688bef77bcbc (diff)
downloadorg.eclipse.recommenders-31971b72fb79d5f3ffbb2b575d0d89e5aaf1caa5.zip
org.eclipse.recommenders-31971b72fb79d5f3ffbb2b575d0d89e5aaf1caa5.tar.gz
org.eclipse.recommenders-31971b72fb79d5f3ffbb2b575d0d89e5aaf1caa5.tar.bz2
[misc] Made canonicalization of Vm*Name thread-safe.refs/changes/58/9358/2
-rw-r--r--plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmFieldName.java8
-rw-r--r--plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmMethodName.java9
-rw-r--r--plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmPackageName.java7
-rw-r--r--plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmTypeName.java8
-rw-r--r--plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmVariableName.java8
5 files changed, 17 insertions, 23 deletions
diff --git a/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmFieldName.java b/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmFieldName.java
index dee8b51..dda03a1 100644
--- a/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmFieldName.java
+++ b/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmFieldName.java
@@ -15,6 +15,7 @@ import static org.eclipse.recommenders.utils.Checks.ensureIsNotNull;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
+import org.eclipse.recommenders.utils.annotations.Testing;
import com.google.common.collect.MapMaker;
@@ -29,7 +30,7 @@ public class VmFieldName implements IFieldName {
* @param fieldName
* @return
*/
- public static VmFieldName get(final String fieldName) {
+ public static synchronized VmFieldName get(final String fieldName) {
// typeName = removeGenerics(typeName);
VmFieldName res = index.get(fieldName);
if (res == null) {
@@ -41,13 +42,10 @@ public class VmFieldName implements IFieldName {
private String identifier;
- protected VmFieldName() {
- // no-one should instantiate this class. O
- }
-
/**
* @see #get(String)
*/
+ @Testing("Outside of tests, VmFieldNames should be canonicalized through VmFieldName#get(String)")
protected VmFieldName(final String vmFieldName) {
identifier = vmFieldName;
ensureIsNotNull(identifier);
diff --git a/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmMethodName.java b/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmMethodName.java
index 62401e0..277b333 100644
--- a/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmMethodName.java
+++ b/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmMethodName.java
@@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
+import org.eclipse.recommenders.utils.annotations.Testing;
import com.google.common.collect.MapMaker;
@@ -36,7 +37,7 @@ public class VmMethodName implements IMethodName {
private static Map<String /* name */, VmMethodName> index = new MapMaker().weakValues().makeMap();
- public static VmMethodName get(final String vmFullQualifiedTypeName, final String vmMethodSignature) {
+ public static synchronized VmMethodName get(final String vmFullQualifiedTypeName, final String vmMethodSignature) {
return get(vmFullQualifiedTypeName + "." + vmMethodSignature);
}
@@ -81,14 +82,10 @@ public class VmMethodName implements IMethodName {
// }
private String identifier;
- protected VmMethodName() {
- // no-one should instantiate this class. But maybe we need subclasses
- // later...
- }
-
/**
* @see #get(String)
*/
+ @Testing("Outside of tests, VmMethodNames should be canonicalized through VmMethodName#get(String)")
protected VmMethodName(final String vmFullQualifiedMethodName) {
identifier = vmFullQualifiedMethodName;
// // perform syntax check by creating every possible element from this
diff --git a/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmPackageName.java b/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmPackageName.java
index 3dd1de6..7f8db69 100644
--- a/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmPackageName.java
+++ b/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmPackageName.java
@@ -13,6 +13,8 @@ package org.eclipse.recommenders.utils.names;
import java.util.Map;
import java.util.Set;
+import org.eclipse.recommenders.utils.annotations.Testing;
+
import com.google.common.collect.MapMaker;
import com.google.common.collect.Sets;
@@ -21,7 +23,7 @@ public class VmPackageName implements IPackageName {
private static Map<String/* name 2 */, VmPackageName> index = new MapMaker().weakValues().makeMap();
public static IPackageName DEFAULT_PACKAGE = get("");
- public static VmPackageName get(final String vmPackageName) {
+ public static synchronized VmPackageName get(final String vmPackageName) {
VmPackageName res = index.get(vmPackageName);
if (res == null) {
res = new VmPackageName(vmPackageName);
@@ -46,7 +48,8 @@ public class VmPackageName implements IPackageName {
/**
* @see #get(String)
*/
- private VmPackageName(final String vmPackageName) {
+ @Testing("Outside of tests, VmPackageNames should be canonicalized through VmPackageName#get(String)")
+ protected VmPackageName(final String vmPackageName) {
identifier = vmPackageName;
}
diff --git a/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmTypeName.java b/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmTypeName.java
index be4cd80..5655216 100644
--- a/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmTypeName.java
+++ b/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmTypeName.java
@@ -19,6 +19,7 @@ import static org.eclipse.recommenders.utils.Throws.throwUnreachable;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
+import org.eclipse.recommenders.utils.annotations.Testing;
import com.google.common.collect.MapMaker;
@@ -58,7 +59,7 @@ public class VmTypeName implements ITypeName {
public static final VmTypeName VOID = get("V");
- public static VmTypeName get(String typeName) {
+ public static synchronized VmTypeName get(String typeName) {
typeName = removeGenerics(typeName);
VmTypeName res = index.get(typeName);
if (res == null) {
@@ -74,13 +75,10 @@ public class VmTypeName implements ITypeName {
private String identifier;
- protected VmTypeName() {
- // no-one should instantiate this class. O
- }
-
/**
* @see #get(String)
*/
+ @Testing("Outside of tests, VmTypeNames should be canonicalized through VmTypeName#get(String)")
protected VmTypeName(final String vmTypeName) {
ensureIsNotNull(vmTypeName);
ensureIsFalse(vmTypeName.length() == 0, "empty size for type name not permitted");
diff --git a/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmVariableName.java b/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmVariableName.java
index e95eeef..a8ccd4b 100644
--- a/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmVariableName.java
+++ b/plugins/org.eclipse.recommenders.utils/src/org/eclipse/recommenders/utils/names/VmVariableName.java
@@ -15,6 +15,7 @@ import static org.eclipse.recommenders.utils.Checks.ensureIsNotNull;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
+import org.eclipse.recommenders.utils.annotations.Testing;
import com.google.common.collect.MapMaker;
@@ -30,7 +31,7 @@ public class VmVariableName implements IVariableName {
* @param variableName
* @return
*/
- public static VmVariableName get(final String variableName) {
+ public static synchronized VmVariableName get(final String variableName) {
VmVariableName res = index.get(variableName);
if (res == null) {
@@ -42,13 +43,10 @@ public class VmVariableName implements IVariableName {
private String identifier;
- protected VmVariableName() {
- // no-one should instantiate this class. O
- }
-
/**
* @see #get(String)
*/
+ @Testing("Outside of tests, VmVariableNames should be canonicalized through VmVariableName#get(String)")
protected VmVariableName(final String vmVariableName) {
identifier = vmVariableName;
ensureIsNotNull(identifier);