summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchibash <chiba@javassist.org>2013-05-26 23:26:16 +0900
committerchibash <chiba@javassist.org>2013-05-26 23:26:16 +0900
commit3358dc269352383eb5e9c186d24ff4a292eeb637 (patch)
tree73b5fbdfc5f3c20844baedcb8c55c7f73b9442a8
parente54a07d44fbe41cb8634fd1f1514c0696e1b6f0a (diff)
downloadjavassist-3358dc269352383eb5e9c186d24ff4a292eeb637.tar.gz
javassist-3358dc269352383eb5e9c186d24ff4a292eeb637.zip
fixed JASSIST-199
-rw-r--r--Readme.html4
-rw-r--r--src/main/javassist/util/proxy/ProxyFactory.java49
2 files changed, 39 insertions, 14 deletions
diff --git a/Readme.html b/Readme.html
index f4c8b9a0..2cc92bb9 100644
--- a/Readme.html
+++ b/Readme.html
@@ -283,7 +283,9 @@ see javassist.Dump.
<p>-version 3.18
<ul>
-JIRA JASSIST-181, 183, 184, 189, 162, 185, 186, 190.
+<li>The source code repository has been moved to <a href="https://github.com/jboss-javassist/javassist">GitHub</a></li>.
+
+<li>JIRA JASSIST-181, 183, 184, 189, 162, 185, 186, 190.
</ul>
<p>-version 3.17.1 on December 3, 2012
diff --git a/src/main/javassist/util/proxy/ProxyFactory.java b/src/main/javassist/util/proxy/ProxyFactory.java
index 88636c01..34d67179 100644
--- a/src/main/javassist/util/proxy/ProxyFactory.java
+++ b/src/main/javassist/util/proxy/ProxyFactory.java
@@ -700,10 +700,38 @@ public class ProxyFactory {
setField(DEFAULT_INTERCEPTOR, handler);
}
- private static int counter = 0;
+ /**
+ * A unique class name generator.
+ */
+ public static interface UniqueName {
+ /**
+ * Returns a unique class name.
+ *
+ * @param classname the super class name of the proxy class.
+ */
+ String get(String classname);
+ }
+
+ /**
+ * A unique class name generator.
+ * Replacing this generator changes the algorithm to generate a
+ * unique name. The <code>get</code> method does not have to be
+ * a <code>synchronized</code> method since the access to this field
+ * is mutually exclusive and thus thread safe.
+ */
+ public static UniqueName nameGenerator = new UniqueName() {
+ private final String sep = "_$$_jvst" + Integer.toHexString(this.hashCode() & 0xfff) + "_";
+ private int counter = 0;
- private static synchronized String makeProxyName(String classname) {
- return classname + "_$$_javassist_" + counter++;
+ public String get(String classname) {
+ return classname + sep + Integer.toHexString(counter++);
+ }
+ };
+
+ private static String makeProxyName(String classname) {
+ synchronized (nameGenerator) {
+ return nameGenerator.get(classname);
+ }
}
private ClassFile make() throws CannotCompileException {
@@ -758,8 +786,7 @@ public class ProxyFactory {
return cf;
}
- private void checkClassAndSuperName()
- {
+ private void checkClassAndSuperName() {
if (interfaces == null)
interfaces = new Class[0];
@@ -780,8 +807,7 @@ public class ProxyFactory {
basename = "org.javassist.tmp." + basename;
}
- private void allocateClassName()
- {
+ private void allocateClassName() {
classname = makeProxyName(basename);
}
@@ -796,8 +822,7 @@ public class ProxyFactory {
}
};
- private void makeSortedMethodList()
- {
+ private void makeSortedMethodList() {
checkClassAndSuperName();
hasGetHandler = false; // getMethods() may set this to true.
@@ -838,8 +863,7 @@ public class ProxyFactory {
this.signature = signature;
}
- private boolean testBit(byte[] signature, int idx)
- {
+ private boolean testBit(byte[] signature, int idx) {
int byteIdx = idx >> 3;
if (byteIdx > signature.length) {
return false;
@@ -851,8 +875,7 @@ public class ProxyFactory {
}
}
- private void setBit(byte[] signature, int idx)
- {
+ private void setBit(byte[] signature, int idx) {
int byteIdx = idx >> 3;
if (byteIdx < signature.length) {
int bitIdx = idx & 0x7;