diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/javassist/bytecode/ConstPool.java | 2 | ||||
-rw-r--r-- | src/test/javassist/JvstTest5.java | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/main/javassist/bytecode/ConstPool.java b/src/main/javassist/bytecode/ConstPool.java index b5113e42..e8434dce 100644 --- a/src/main/javassist/bytecode/ConstPool.java +++ b/src/main/javassist/bytecode/ConstPool.java @@ -1433,7 +1433,7 @@ public final class ConstPool */ public void write(DataOutputStream out) throws IOException { - if (numOfItems < 0 || Short.MAX_VALUE < numOfItems) + if (numOfItems < 0 || ((1 << 16) - 1) < numOfItems) throw new IOException("too many constant pool items " + numOfItems); out.writeShort(numOfItems); diff --git a/src/test/javassist/JvstTest5.java b/src/test/javassist/JvstTest5.java index 39af16b9..4a370632 100644 --- a/src/test/javassist/JvstTest5.java +++ b/src/test/javassist/JvstTest5.java @@ -580,8 +580,13 @@ public class JvstTest5 extends JvstTestRoot { CtClass cc = sloader.makeClass("TooManyConstPoolItems"); ClassFile cf = cc.getClassFile(); ConstPool cPool = cf.getConstPool(); - for (int i = 0; i <= 65527; i++) - cPool.addIntegerInfo(i); + int size = cPool.getSize(); + while (cPool.getSize() < 65536 - 6) + cPool.addIntegerInfo(cPool.getSize()); + + cc.writeFile(); + cc.defrost(); + cPool.addIntegerInfo(-1); try { cc.writeFile(); fail("too many items were accepted"); |