[jboss-cvs] javassist/src/main/javassist/convert ...
Shigeru Chiba
chiba at is.titech.ac.jp
Fri Feb 9 13:05:21 EST 2007
User: chiba
Date: 07/02/09 13:05:21
Modified: src/main/javassist/convert TransformNew.java
TransformAccessArrayField.java
Log:
modified javassist.convert.* to support the stack map table of Java 6.
Revision Changes Path
1.7 +5 -0 javassist/src/main/javassist/convert/TransformNew.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TransformNew.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/convert/TransformNew.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- TransformNew.java 11 Jan 2006 06:45:56 -0000 1.6
+++ TransformNew.java 9 Feb 2007 18:05:21 -0000 1.7
@@ -64,6 +64,11 @@
iterator.writeByte(NOP, pos + 2);
iterator.writeByte(NOP, pos + 3);
++nested;
+
+ StackMapTable smt
+ = (StackMapTable)iterator.get().getAttribute(StackMapTable.tag);
+ if (smt != null)
+ smt.removeNew(pos);
}
}
else if (c == INVOKESPECIAL) {
1.3 +72 -74 javassist/src/main/javassist/convert/TransformAccessArrayField.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TransformAccessArrayField.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/convert/TransformAccessArrayField.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- TransformAccessArrayField.java 5 Jan 2007 12:17:50 -0000 1.2
+++ TransformAccessArrayField.java 9 Feb 2007 18:05:21 -0000 1.3
@@ -14,7 +14,6 @@
*/
package javassist.convert;
-
import javassist.CtClass;
import javassist.NotFoundException;
import javassist.CodeConverter.ArrayAccessReplacementMethodNames;
@@ -25,43 +24,44 @@
/**
*
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
-public class TransformAccessArrayField extends Transformer
-{
+public class TransformAccessArrayField extends Transformer {
// CtClass componentType;
String methodClassname;
ArrayAccessReplacementMethodNames names;
- public TransformAccessArrayField(Transformer next, String methodClassname, ArrayAccessReplacementMethodNames names) throws NotFoundException
+ public TransformAccessArrayField(Transformer next, String methodClassname,
+ ArrayAccessReplacementMethodNames names)
+ throws NotFoundException
{
super(next);
this.methodClassname = methodClassname;
this.names = names;
}
- public int transform(CtClass tclazz, int pos, CodeIterator iterator, ConstPool cp) throws BadBytecode
+ public int transform(CtClass tclazz, int pos, CodeIterator iterator,
+ ConstPool cp) throws BadBytecode
{
int c = iterator.byteAt(pos);
- if (c == AALOAD || c == BALOAD || c == CALOAD || c == DALOAD || c == FALOAD || c == IALOAD || c == LALOAD || c == SALOAD)
- {
+ if (c == AALOAD || c == BALOAD || c == CALOAD || c == DALOAD
+ || c == FALOAD || c == IALOAD || c == LALOAD || c == SALOAD)
replace(cp, iterator, pos, c, getLoadReplacementSignature(c));
- }
- else if (c == AASTORE || c == BASTORE || c == CASTORE || c == DASTORE || c == FASTORE || c == IASTORE || c == LASTORE || c == SASTORE)
- {
+ else if (c == AASTORE || c == BASTORE || c == CASTORE || c == DASTORE
+ || c == FASTORE || c == IASTORE || c == LASTORE || c == SASTORE)
replace(cp, iterator, pos, c, getStoreReplacementSignature(c));
- }
return pos;
}
- private void replace(ConstPool cp, CodeIterator iterator, int pos, int opcode, String signature) throws BadBytecode
+ private void replace(ConstPool cp, CodeIterator iterator,
+ int pos, int opcode, String signature)
+ throws BadBytecode
{
String methodName = getMethodName(opcode);
- if (methodName != null)
- {
+ if (methodName != null) {
iterator.insertGap(2);
int mi = cp.addClassInfo(methodClassname);
int methodref = cp.addMethodrefInfo(mi, methodName, signature);
@@ -70,11 +70,9 @@
}
}
- private String getMethodName(int opcode)
- {
+ private String getMethodName(int opcode) {
String methodName = null;
- switch(opcode)
- {
+ switch (opcode) {
case AALOAD:
methodName = names.objectRead();
break;
@@ -126,16 +124,15 @@
}
if (methodName.equals(""))
- {
methodName = null;
- }
+
return methodName;
}
- private String getLoadReplacementSignature(int opcode) throws BadBytecode
- {
- switch(opcode)
+ private String getLoadReplacementSignature(int opcode)
+ throws BadBytecode
{
+ switch (opcode) {
case AALOAD:
return "(Ljava/lang/Object;I)Ljava/lang/Object;";
case BALOAD:
@@ -157,10 +154,10 @@
throw new BadBytecode(opcode);
}
- private String getStoreReplacementSignature(int opcode) throws BadBytecode
- {
- switch(opcode)
+ private String getStoreReplacementSignature(int opcode)
+ throws BadBytecode
{
+ switch (opcode) {
case AASTORE:
return "(Ljava/lang/Object;ILjava/lang/Object;)V";
case BASTORE:
@@ -178,6 +175,7 @@
case LASTORE:
return "(Ljava/lang/Object;IJ)V";
}
+
throw new BadBytecode(opcode);
}
}
More information about the jboss-cvs-commits
mailing list