import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.reflect.Method;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedActionException;
args = new Object[] { ct.getName(), b, new Integer(0),
new Integer(b.length), domain};
}
-
- method.setAccessible(true);
- Class clazz = (Class)method.invoke(loader, args);
- method.setAccessible(false);
- return clazz;
+
+ return toClass2(method, loader, args);
}
catch (RuntimeException e) {
throw e;
throw new CannotCompileException(e);
}
}
+
+ private static synchronized Class toClass2(Method method,
+ ClassLoader loader, Object[] args)
+ throws Exception
+ {
+ method.setAccessible(true);
+ Class clazz = (Class)method.invoke(loader, args);
+ method.setAccessible(false);
+ return clazz;
+ }
}
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
+import java.util.ArrayList;
/**
* <code>stack_map</code> attribute.
*/
public static final String tag = "StackMapTable";
- private StackMapFrame[] entries; // may be null
+ private ArrayList entries; // ArrayList<StackMapFrame>. may be null.
/**
* Constructs a <code>stack_map</code> attribute.
private void parseMap() {
byte[] data = info;
int n = ByteArray.readU16bit(data, 0);
- entries = new StackMapFrame[n];
+ entries = new ArrayList(n);
+ int offset = 2;
+ while (n-- > 0) {
+ int frameType;
+ }
+
}
private void toByteArray(boolean clear) {
}
/**
- * <code>union stack_map_frame</code>
+ * <code>union stack_map_frame</code>.
+ * <p><code>verification_type_info</code> is represented
+ * by a pair of two <code>int</code> values. No class
+ * for represening <code>verification_type_
*/
- public static class StackMapFrame {}
+ public static class StackMapFrame {
+ /**
+ * <code>u2 offset_delta</code>.
+ * If <code>offset_delta</code> is not included
+ * (i.e. <code>same_frame</code>), the value of
+ * this field is computed from other members such
+ * as <code>frame_type</code>.
+ */
+ public int offsetDelta;
+ }
/*
* verification_type_info is represented by a pair of
/**
* <code>same_frame</code>.
- * The frame has exactly the same locals as the previous
- * stack map frame.
+ * <code>frame_type</code> is not included.
+ * It is computed by <code>offsetDelta</code>.
*/
public static class SameFrame extends StackMapFrame {
/**
* The maximum value of <code>SAME</code>.
*/
public static final int FRAME_TYPE_MAX = 63;
-
- /**
- * <code>u1 frame_type</code>.
- */
- public int frameType;
}
/**
* <code>same_locals_1_stack_item_frame</code> or
- * <code>same_locals_1_stack_item_frame_extended</code>.
+ * <code>same_locals_1_stack_item_frame_extended</code>.
+ *
+ * <p><code>frame_type</code> is not included.
+ * It is computed by <code>offsetDelta</code>.
*/
public static class SameLocals extends StackMapFrame {
/**
*/
public static final int FRAME_TYPE_EXTENDED = 247;
- /*
- * <code>frame_type</code> is computed by offsetDelta.
- */
-
- /**
- * <code>u2 offset_delta</code>.
- */
- public int offsetDelta;
-
/**
* <code>stack[0].tag</code>.
*/
* <code>u1 frame_type</code>.
*/
public int frameType;
-
- /**
- * <code>u2 offset_delta</code>.
- */
- public int offsetDelta;
}
/**
* <code>SAME_FRAME_EXTENDED</code>.
*/
public static final int FRAME_TYPE = 251;
-
- /**
- * <code>u2 offset_delta</code>.
- */
- public int offsetDelta;
}
/**
*/
public int frameType;
- /**
- * <code>u2 offset_delta</code>.
- */
- public int offsetDelta;
-
/**
* <code>locals[?].tag</code>.
+ * <code>typeTags.length</code> and <code>typeValues.length</code>
+ * are equal to <code>number_of_locals</code>.
*/
public int[] typeTags;
/**
* <code>locals[?].cpool_index</code> or <code>locals[?].offset</code>.
+ * <code>typeTags.length</code> and <code>typeValues.length</code>
+ * are equal to <code>number_of_locals</code>.
*/
public int[] typeValues;
}
*/
public static final int FRAME_TYPE = 255;
- /**
- * <code>u2 offset_delta</code>.
- */
- public int offsetDelta;
-
- /**
- * <code>u2 number_of_locals</code>.
- */
- public int numOfLocals;
-
/**
* <code>locals[?].tag</code>.
+ * <code>typeTags.length</code> and <code>typeValues.length</code>
+ * are equal to <code>number_of_locals</code>.
*/
public int[] typeTags;
/**
* <code>locals[?].cpool_index</code> or <code>locals[?].offset</code>.
+ * <code>typeTags.length</code> and <code>typeValues.length</code>
+ * are equal to <code>number_of_locals</code>.
*/
public int[] typeValues;
- /**
- * <code>u2 number_of_stack_items</code>.
- */
- public int numOfStackItems;
-
/**
* <code>stack[?].tag</code>.
+ * <code>stackTypeTags.length</code> and <code>stackTypeValues.length</code>
+ * are equal to <code>number_of_stack_items</code>.
*/
public int[] stackTypeTags;
/**
* <code>stack[?].cpool_index</code> or <code>locals[?].offset</code>.
+ * <code>stackTypeTags.length</code> and <code>stackTypeValues.length</code>
+ * are equal to <code>number_of_stack_items</code>.
*/
public int[] stackTypeValues;
}
package javassist.util.proxy;
+import java.lang.reflect.Method;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
{
try {
byte[] b = toBytecode(cf);
- java.lang.reflect.Method method;
+ Method method;
Object[] args;
if (domain == null) {
method = defineClass1;
new Integer(b.length), domain };
}
- method.setAccessible(true);
- Class clazz = (Class)method.invoke(loader, args);
- method.setAccessible(false);
- return clazz;
+ return toClass2(method, loader, args);
}
catch (RuntimeException e) {
throw e;
}
}
+ private static synchronized Class toClass2(Method method,
+ ClassLoader loader, Object[] args)
+ throws Exception
+ {
+ method.setAccessible(true);
+ Class clazz = (Class)method.invoke(loader, args);
+ method.setAccessible(false);
+ return clazz;
+ }
+
private static byte[] toBytecode(ClassFile cf) throws IOException {
ByteArrayOutputStream barray = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(barray);