Does deleting/changing comments code solve "Code too large" compilation error in Java?

239 Views Asked by At

I have a legacy large enum with many comments, and the Java compiler gives a "Code too large" error. Will changing the comment type or deleting the comments solve the issue?

I tried splitting the enum, but it's a legacy code and can't be split.

1

There are 1 best solutions below

1
On

This error typically is seen when a method exceeds 65536 bytes (64 KB) in size. Search for the particular method and try some of the following:

  • Split the method into two or more methods
  • Remove any redundancy (such as similar loop executing twice, etc.)
  • Remove any comments (which may be inside the method)

Because the method itself is more 64 KB, the entire file may be too large. I would consider splitting the file into more files using classes.