浏览代码

prohibits too many items from being added to a constant pool

tags/rel_3_29_1_ga
chibash 1年前
父节点
当前提交
4f35e4e1a8
共有 3 个文件被更改,包括 17 次插入0 次删除
  1. 二进制
      javassist.jar
  2. 3
    0
      src/main/javassist/bytecode/ConstPool.java
  3. 14
    0
      src/test/javassist/JvstTest5.java

二进制
javassist.jar 查看文件


+ 3
- 0
src/main/javassist/bytecode/ConstPool.java 查看文件

@@ -1433,6 +1433,9 @@ public final class ConstPool
*/
public void write(DataOutputStream out) throws IOException
{
if (numOfItems < 0 || Short.MAX_VALUE < numOfItems)
throw new IOException("too many constant pool items " + numOfItems);

out.writeShort(numOfItems);
LongVector v = items;
int size = numOfItems;

+ 14
- 0
src/test/javassist/JvstTest5.java 查看文件

@@ -15,6 +15,7 @@ import javassist.expr.ExprEditor;
import javassist.expr.Handler;
import javassist.expr.MethodCall;
import javassist.expr.NewExpr;
import junit.framework.Assert;

@SuppressWarnings({"rawtypes","unchecked","unused"})
public class JvstTest5 extends JvstTestRoot {
@@ -574,4 +575,17 @@ public class JvstTest5 extends JvstTestRoot {
Object obj = make(cc.getName());
assertEquals(1, invoke(obj, "run"));
}

public void testTooManyConstPoolItems() throws Exception {
CtClass cc = sloader.makeClass("TooManyConstPoolItems");
ClassFile cf = cc.getClassFile();
ConstPool cPool = cf.getConstPool();
for (int i = 0; i <= 65527; i++)
cPool.addIntegerInfo(i);
try {
cc.writeFile();
fail("too many items were accepted");
}
catch (CannotCompileException e) {}
}
}

正在加载...
取消
保存