aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode/MethodInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/javassist/bytecode/MethodInfo.java')
-rw-r--r--src/main/javassist/bytecode/MethodInfo.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/javassist/bytecode/MethodInfo.java b/src/main/javassist/bytecode/MethodInfo.java
index 8d0cce10..6e945570 100644
--- a/src/main/javassist/bytecode/MethodInfo.java
+++ b/src/main/javassist/bytecode/MethodInfo.java
@@ -21,6 +21,8 @@ import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import javassist.ClassPool;
+import javassist.bytecode.stackmap.MapMaker;
/**
* <code>method_info</code> structure.
@@ -371,6 +373,40 @@ 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.
+ *
+ * @param pool used for making type hierarchy.
+ * @param cf rebuild if this class file is for Java 6 or later.
+ * @see #rebuildStackMap(ClassPool)
+ * @since 3.6
+ */
+ public void rebuildStackMapIf6(ClassPool pool, ClassFile cf)
+ throws BadBytecode
+ {
+ if (cf.getMajorVersion() >= ClassFile.JAVA_6)
+ rebuildStackMap(pool);
+ }
+
+ /**
+ * Rebuilds a stack map table. 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.6
+ */
+ public void rebuildStackMap(ClassPool pool) throws BadBytecode {
+ CodeAttribute ca = getCodeAttribute();
+ if (ca != null) {
+ StackMapTable smt = MapMaker.make(pool, this);
+ ca.setAttribute(smt);
+ }
+ }
+
+ /**
* Returns the line number of the source line corresponding to the specified
* bytecode contained in this method.
*