*/
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);
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");