/** * Add a new long constant to the ConstantPool, if it is not already in there. * * @param n Long number to add * @return index of entry */ public int addLong(long n) { int ret; if((ret = lookupLong(n)) != -1) return ret; // Already in CP adjustSize(); ret = index; constants[index] = new ConstantLong(n); index += 2; // Wastes one entry according to spec return ret; }
/** * Add a new long constant to the ConstantPool, if it is not already in there. * * @param n Long number to add * @return index of entry */ public int addLong( final long n ) { int ret; if ((ret = lookupLong(n)) != -1) { return ret; // Already in CP } adjustSize(); ret = index; constants[index] = new ConstantLong(n); index += 2; // Wastes one entry according to spec return ret; }
public void testCreateLongElementValue() throws Exception { final ClassGen cg = createClassGen("HelloWorld"); final ConstantPoolGen cp = cg.getConstantPool(); final SimpleElementValueGen evg = new SimpleElementValueGen( ElementValueGen.PRIMITIVE_LONG, cp, 3334455L); // Creation of an element like that should leave a new entry in the // cpool final int idx = cp.lookupLong(3334455L); assertTrue("Should have the same index in the constantpool but " + evg.getIndex() + "!=" + idx, evg.getIndex() == idx); checkSerialize(evg, cp); }