web3j icon indicating copy to clipboard operation
web3j copied to clipboard

The type generates a string that requires more than 65535 bytes to encode in Utf8 format in the constant pool

Open asuarezgrupobme opened this issue 5 years ago • 5 comments

Error in java class generated: The type generates a string that requires more than 65535 bytes to encode in Utf8 format in the constant pool

After generating my java class from my solidity contract with web3j, my java class has the error "The type generates a string that requires more than 65535 bytes to encode in Utf8 format in the constant pool"

Steps To Reproduce

Write a long solidity contract and generate the java code using your contract.

asuarezgrupobme avatar Jan 23 '20 16:01 asuarezgrupobme

Possible solution: make the binary a non final attribute.

asuarezgrupobme avatar Jan 23 '20 20:01 asuarezgrupobme

I'm hitting the same problem.

Two solutions would be to either split it between n strings and concatenate in static initializer (quick and dirty solution) or create separate .bin file which gets loaded on demand if needed (or possibly in static init as well) - but this breaks the nice feature of having everything for a contract in a single file.

abies avatar Dec 22 '20 18:12 abies

@asuarezgrupobme This is not really a web3j issue but a java limitation. @abies I think the first solution would be a more viable one. I don't think it's a good idea to break things into multiple files.

AlexandrouR avatar Feb 23 '21 12:02 AlexandrouR

I'm sitting on changeset for that one already (among other things), but I'm waiting for my company to sort out legal stuff regarding contributions. Still, given it is a simple stuff, it might be faster for your to implement it rather than wait for me.

It is just new StringBuffer(333333).append("FIRSTPART").append("SECONDPART")....toString(), with parts being split into (2^16-2) chunks (where 333333 is proper size of course).

abies avatar Feb 23 '21 14:02 abies

Any updates on this issue?

tena4881 avatar Dec 04 '21 04:12 tena4881