diff options
Diffstat (limited to 'src/main/javassist/bytecode/MethodInfo.java')
-rw-r--r-- | src/main/javassist/bytecode/MethodInfo.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/main/javassist/bytecode/MethodInfo.java b/src/main/javassist/bytecode/MethodInfo.java index eae31e10..6d819371 100644 --- a/src/main/javassist/bytecode/MethodInfo.java +++ b/src/main/javassist/bytecode/MethodInfo.java @@ -39,6 +39,13 @@ public final class MethodInfo { LinkedList attribute; // may be null /** + * If this value is true, Javassist maintains a <code>StackMap</code> attribute + * generated by the <code>preverify</code> tool of J2ME (CLDC). The initial + * value of this field is <code>false</code>. + */ + public static boolean doPreverify = false; + + /** * The name of constructors: <code><init></code>. */ public static final String nameInit = "<init>"; @@ -375,11 +382,13 @@ public final class MethodInfo { /** * Rebuilds a stack map table if the class file is for Java 6 * or later. Java 5 or older Java VMs do not recognize a stack - * map table. + * map table. If <code>doPreverify</code> is true, this method + * also rebuilds a stack map for J2ME (CLDC). * * @param pool used for making type hierarchy. * @param cf rebuild if this class file is for Java 6 or later. * @see #rebuildStackMap(ClassPool) + * @see #rebuildStackMapForME(ClassPool) * @since 3.6 */ public void rebuildStackMapIf6(ClassPool pool, ClassFile cf) @@ -387,6 +396,9 @@ public final class MethodInfo { { if (cf.getMajorVersion() >= ClassFile.JAVA_6) rebuildStackMap(pool); + + if (doPreverify) + rebuildStackMapForME(pool); } /** @@ -407,6 +419,23 @@ public final class MethodInfo { } /** + * Rebuilds a stack map table for J2ME (CLDC). If no stack map table is included, + * a new one is created. If this <code>MethodInfo</code> does not + * include a code attribute, nothing happens. + * + * @param pool used for making type hierarchy. + * @see StackMapTable + * @since 3.12 + */ + public void rebuildStackMapForME(ClassPool pool) throws BadBytecode { + CodeAttribute ca = getCodeAttribute(); + if (ca != null) { + StackMap sm = MapMaker.make2(pool, this); + ca.setAttribute(sm); + } + } + + /** * Returns the line number of the source line corresponding to the specified * bytecode contained in this method. * |