Solution to Java code length not greater than 65535 bytes

Source: Internet
Author: User

Due to restrictions of Java virtual machineCodeThe length cannot exceed 65535 bytes. I have summarized the related solutions to this problem.

1. Database

This is the most traditional method, and most people first think of it.

2. File

This is actually another way to replace the database.

3. Class

Refine complex classes into multiple classes.

4. Method

Refine complex methods into multiple methods.

In fact, the introduction of these four solutions is not the focus of this article, but fromProgramPerformance. Sometimes some relatively static data can be stored in a database or file, but both the database and file involve performance issues such as connection and IO. Some may say, I can pre-load static data (that is, get it only once and store it in static variables), but all the data with a large amount of data is stored in static variables, the result is the system's consumption of memory resources. In my opinion, there is also a trade-off.

If it is put into a class or method, the above problem can be well solved. The speed bottleneck of calling between Java files has been reduced to the JVM level. both speed and energy consumption will satisfy you. In terms of reading speed, it is definitely much faster than reading the database. In terms of energy consumption, we no longer need to put a large amount of data into static variables. When can we use new.

There are always many ways to solve problems, so we should not just limit ourselves to "common sense". flexible use of technology is a shortcut to growth. You will not try to store some data in the form of classes or methods in the future.

This is a good example of the date tool class I am about to release version 4. For more information, see ).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.