diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2006-11-12 02:43:15 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2006-11-12 02:43:15 +0000 |
commit | 517f6712ff7b833ba4396df8c0ba0c8a32ca1e6d (patch) | |
tree | 68396d2d1042fd691ec36dbcc93be80ada540af1 | |
parent | 223ca924f81c7f102db6a1711a1e1eb21ce39cc4 (diff) | |
download | javassist-517f6712ff7b833ba4396df8c0ba0c8a32ca1e6d.tar.gz javassist-517f6712ff7b833ba4396df8c0ba0c8a32ca1e6d.zip |
enabled a transformation from a public method call to a private method call by CodeConverter
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@333 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r-- | src/main/javassist/CodeConverter.java | 4 | ||||
-rw-r--r-- | src/main/javassist/convert/TransformCall.java | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/main/javassist/CodeConverter.java b/src/main/javassist/CodeConverter.java index d8a645ff..1c8cf2f6 100644 --- a/src/main/javassist/CodeConverter.java +++ b/src/main/javassist/CodeConverter.java @@ -228,8 +228,8 @@ public class CodeConverter { int mod1 = origMethod.getModifiers(); int mod2 = substMethod.getModifiers(); - if (Modifier.isPrivate(mod1) != Modifier.isPrivate(mod2) - || Modifier.isStatic(mod1) != Modifier.isStatic(mod2) + if (Modifier.isStatic(mod1) != Modifier.isStatic(mod2) + || (Modifier.isPrivate(mod1) && !Modifier.isPrivate(mod2)) || origMethod.getDeclaringClass().isInterface() != substMethod.getDeclaringClass().isInterface()) throw new CannotCompileException("invoke-type mismatch"); diff --git a/src/main/javassist/convert/TransformCall.java b/src/main/javassist/convert/TransformCall.java index 43508c2f..858b7430 100644 --- a/src/main/javassist/convert/TransformCall.java +++ b/src/main/javassist/convert/TransformCall.java @@ -17,11 +17,13 @@ package javassist.convert; import javassist.CtClass; import javassist.CtMethod; +import javassist.Modifier; import javassist.bytecode.*; public class TransformCall extends Transformer { protected String classname, methodname, methodDescriptor; protected String newClassname, newMethodname; + protected boolean newMethodIsPrivate; /* cache */ protected int newIndex; @@ -43,6 +45,7 @@ public class TransformCall extends Transformer { classname = newClassname = substMethod.getDeclaringClass().getName(); newMethodname = substMethod.getName(); constPool = null; + newMethodIsPrivate = Modifier.isPrivate(substMethod.getModifiers()); } public void initialize(ConstPool cp, CodeAttribute attr) { @@ -79,8 +82,12 @@ public class TransformCall extends Transformer { int ci = cp.addClassInfo(newClassname); if (c == INVOKEINTERFACE) newIndex = cp.addInterfaceMethodrefInfo(ci, nt); - else + else { + if (newMethodIsPrivate && c == INVOKEVIRTUAL) + iterator.writeByte(INVOKESPECIAL, pos); + newIndex = cp.addMethodrefInfo(ci, nt); + } constPool = cp; } |