Browse Source

fixed JASSIST-199

tags/log
chibash 11 years ago
parent
commit
3358dc2693
2 changed files with 39 additions and 14 deletions
  1. 3
    1
      Readme.html
  2. 36
    13
      src/main/javassist/util/proxy/ProxyFactory.java

+ 3
- 1
Readme.html View File



<p>-version 3.18 <p>-version 3.18
<ul> <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> </ul>


<p>-version 3.17.1 on December 3, 2012 <p>-version 3.17.1 on December 3, 2012

+ 36
- 13
src/main/javassist/util/proxy/ProxyFactory.java View File

setField(DEFAULT_INTERCEPTOR, handler); 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 { private ClassFile make() throws CannotCompileException {
return cf; return cf;
} }


private void checkClassAndSuperName()
{
private void checkClassAndSuperName() {
if (interfaces == null) if (interfaces == null)
interfaces = new Class[0]; interfaces = new Class[0];


basename = "org.javassist.tmp." + basename; basename = "org.javassist.tmp." + basename;
} }


private void allocateClassName()
{
private void allocateClassName() {
classname = makeProxyName(basename); classname = makeProxyName(basename);
} }


} }
}; };


private void makeSortedMethodList()
{
private void makeSortedMethodList() {
checkClassAndSuperName(); checkClassAndSuperName();


hasGetHandler = false; // getMethods() may set this to true. hasGetHandler = false; // getMethods() may set this to true.
this.signature = signature; this.signature = signature;
} }


private boolean testBit(byte[] signature, int idx)
{
private boolean testBit(byte[] signature, int idx) {
int byteIdx = idx >> 3; int byteIdx = idx >> 3;
if (byteIdx > signature.length) { if (byteIdx > signature.length) {
return false; return false;
} }
} }


private void setBit(byte[] signature, int idx)
{
private void setBit(byte[] signature, int idx) {
int byteIdx = idx >> 3; int byteIdx = idx >> 3;
if (byteIdx < signature.length) { if (byteIdx < signature.length) {
int bitIdx = idx & 0x7; int bitIdx = idx & 0x7;

Loading…
Cancel
Save