|By Shankar Itchapurapu||
|April 9, 2013 07:45 AM EDT||
The Java Virtual Machine specification limits the size of generated Java byte code for each method in a class to the maximum of 64K bytes. This limitation will cause the JVM to throw java.lang.VerifyError at runtime when the method size exceeds this limit.
This method size restriction of the JVM seems to be too stringent. A bug is open with the Oracle Java development team (http://bugs.sun.com/view_bug.do?bug_id=4262078). This bug is taken as an enhancement request which is likely to be fixed in the future java versions. That said, the fix for this issue is rather supportive. Application/Container developers need to consider few factors and apply good programming/refactoring techniques to get around this problem. While future versions of JVM might increase the method size limit to a considerable extent, a the size will always be a finite value.
In this article, I discuss some of the techniques that can be used to get around this problem. The techniques/suggestions discussed here, while apply to development environments also, are primarily targeted for containers which involve code generation as part of compilation process (e.g., EJB container or a JSP container).
Applications and Method Size Limit
While applications written in Java seldom encounter this issue, even more so after the above noted bug is fixed, it is recommended to follow the proven software engineering principles like code refactoring and object oriented programming techniques.
The complexity of this issue in application development is relatively smaller. As the code is written through the development phase, a number of tests are run both at the Unit level as well as the system level. Also, it is very rare that the application development involves complex code generation during the build time. This gives the developer/architect an opportunity to identify the possible method size restriction issue well ahead of the final delivery.
Application Containers and Method Size Limit
Application Containers are environments where Java applications execute. So they carry very high degree of complexity in terms of code. As the containers consume the application code and configuration and provide services for the application runtime, containers most often involve code generation. This code generation can be very complex in systems like JSP compiler as they convert scripting languages to Java.
This makes containers involving code generation particularly vulnerable to the Java method size limit restriction.
Techniques for Resolving the Method Size Restriction
In this section, I detail some of the techniques which can be used in code generation area to cover most of the use cases which cause the method size restriction.
Splitting a Big Method into Smaller Pieces
This is one of the structured programming techniques which can be used with effect. The driving factor for this technique should be the code refactoring. After the code generation is completed, a careful examination of the bigger methods can give us some clue of moving some of the java statements to a different private method. This is typically reverse engineering the output to a fine grained control.
Using a Intermediate Super Class
This applies particularly to areas such as EJB and JSP. A JSP file once converted into a Java class will typically extend a JspServlet class (implemented differently by different container vendors). The core refactoring technique here is to move the rudimentary code into the super class so that the generated class becomes light. However, this technique is fairly primitive. Most modern container vendors have already optimized their code to include almost everything possible into their super class implementation.
Using Helper Class/Methods
The third refactoring technique is to use a helper class. One particular use case is a JSP compiler handling a [email protected]..% directive. JSP specification mandates that the static includes need to be expanded inline in the generated service method. This adds to the size of the generated service method. One refactoring that can be used here is to move the expanded code into a private member function in the generated Java file and include just the method call in the service method.
Another area is the scripting elements in the JSP file. All the scripting elements are parsed and then included inline in the generated service() method of the java file. A similar refactoring technique discussed above can be used for the scripting elements as well.
Code generation engines can consider generating a Helper class which contains all the refactored methods and shield the Helper class from end-user's direct access.
Using JVM Switches
Java compilers generate .class files, with each file containing bytecodes for the methods in one class. These files contain a series of sections, or attributes, and it's possible to exercise some control over which sections actually show up in a .class file. The Code attribute contains actual bytecodes for methods, SourceFile information on the source file name used to generate this .class file, LineNumberTable mapping information between bytecode offsets and source file line numbers, and LocalVariableTable mapping information between stack frame offsets and local variable names.
We can use options to the javac compiler to control which sections are included:
javac Code, SourceFile, LineNumberTable
javac -g Code, SourceFile, LineNumberTable, LocalVariableTable
javac -g:none Code
How much do these options affect code size? A test using the JDK 1.2.2 sources in the java.io, java.lang, and java.util packages was run, with total sizes of all .class files as follows:
javac -g 815K
javac -g:none 550K
So use of javac -g:none saves about 20% in space over the default javac, and using javac -g is about 20% larger than the default. There are also commercial tools that tackle this particular problem.
If you strip out information such as line numbers from .class files, you may have problems with debugging and exception reporting. So it is recommended that the container vendors provide a configuration mechanism to switch off/on this feature so the production environments can take advantage.
Any refactoring technique will not completely alleviate the method size restriction. Excessive template text and scripting elements in the scripting languages will almost always cause the compilers to generate heavier methods and may lead to the method size restriction. The solution to this problem is supportive. Developers need to concentrate on good programming techniques so that the scripting language code like JSP will be more maintainable. JSP specification recommends using tag libraries that promote reusability while considerably reducing the size of the generated service method.
Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more business becomes digital the more stakeholders are interested in this data including how it relates to business. Some of these people have never used a monitoring tool before. They have a question on their mind like “How is my application doing” but no id...
Apr. 30, 2017 07:45 PM EDT Reads: 7,483
Is your application too difficult to manage? Do changes take dozens of developers hundreds of hours to execute, and frequently result in downtime across all your site’s functions? It sounds like you have a monolith! A monolith is one of the three main software architectures that define most applications. Whether you’ve intentionally set out to create a monolith or not, it’s worth at least weighing the pros and cons of the different architectural approaches and deciding which one makes the most s...
Apr. 30, 2017 07:30 PM EDT Reads: 3,090
Developers want to create better apps faster. Static clouds are giving way to scalable systems, with dynamic resource allocation and application monitoring. You won't hear that chant from users on any picket line, but helping developers to create better apps faster is the mission of Lee Atchison, principal cloud architect and advocate at New Relic Inc., based in San Francisco. His singular job is to understand and drive the industry in the areas of cloud architecture, microservices, scalability ...
Apr. 30, 2017 07:00 PM EDT Reads: 3,772
When you decide to launch a startup company, business advisors, counselors, bankers and armchair know-it-alls will tell you that the first thing you need to do is get funding. While there is some validity to that boilerplate piece of wisdom, the availability of and need for startup funding has gone through a dramatic transformation over the past decade, and the next few years will see even more of a shift. A perfect storm of events is causing this seismic shift. On the macroeconomic side this ...
Apr. 30, 2017 06:30 PM EDT Reads: 738
Cloud promises the agility required by today’s digital businesses. As organizations adopt cloud based infrastructures and services, their IT resources become increasingly dynamic and hybrid in nature. Managing these require modern IT operations and tools. In his session at 20th Cloud Expo, Raj Sundaram, Senior Principal Product Manager at CA Technologies, will discuss how to modernize your IT operations in order to proactively manage your hybrid cloud and IT environments. He will be sharing be...
Apr. 30, 2017 01:00 PM EDT Reads: 1,109
Cloud Expo, Inc. has announced today that Aruna Ravichandran, vice president of DevOps Product and Solutions Marketing at CA Technologies, has been named co-conference chair of DevOps at Cloud Expo 2017. The @DevOpsSummit at Cloud Expo New York will take place on June 6-8, 2017, at the Javits Center in New York City, New York, and @DevOpsSummit at Cloud Expo Silicon Valley will take place Oct. 31-Nov. 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Apr. 30, 2017 11:30 AM EDT Reads: 2,949
A Man in the Middle attack, or MITM, is a situation wherein a malicious entity can read/write data that is being transmitted between two or more systems (in most cases, between you and the website that you are surfing). MITMs are common in China, thanks to the “Great Cannon.” The “Great Cannon” is slightly different from the “The Great Firewall.” The firewall monitors web traffic moving in and out of China and blocks prohibited content. The Great Cannon, on the other hand, acts as a man in the...
Apr. 30, 2017 07:30 AM EDT Reads: 585
To more closely examine the variety of ways in which IT departments around the world are integrating cloud services, and the effect hybrid IT has had on their organizations and IT job roles, SolarWinds recently released the SolarWinds IT Trends Report 2017: Portrait of a Hybrid Organization. This annual study consists of survey-based research that explores significant trends, developments, and movements related to and directly affecting IT and IT professionals.
Apr. 30, 2017 05:30 AM EDT Reads: 1,967
NHK, Japan Broadcasting, will feature the upcoming @ThingsExpo Silicon Valley in a special 'Internet of Things' and smart technology documentary that will be filmed on the expo floor between November 3 to 5, 2015, in Santa Clara. NHK is the sole public TV network in Japan equivalent to the BBC in the UK and the largest in Asia with many award-winning science and technology programs. Japanese TV is producing a documentary about IoT and Smart technology and will be covering @ThingsExpo Silicon Val...
Apr. 30, 2017 03:45 AM EDT Reads: 9,500
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
Apr. 30, 2017 03:30 AM EDT Reads: 6,286
Keeping pace with advancements in software delivery processes and tooling is taxing even for the most proficient organizations. Point tools, platforms, open source and the increasing adoption of private and public cloud services requires strong engineering rigor – all in the face of developer demands to use the tools of choice. As Agile has settled in as a mainstream practice, now DevOps has emerged as the next wave to improve software delivery speed and output. To make DevOps work, organization...
Apr. 30, 2017 02:45 AM EDT Reads: 9,299
Enterprise architects are increasingly adopting multi-cloud strategies as they seek to utilize existing data center assets, leverage the advantages of cloud computing and avoid cloud vendor lock-in. This requires a globally aware traffic management strategy that can monitor infrastructure health across data centers and end-user experience globally, while responding to control changes and system specification at the speed of today’s DevOps teams. In his session at 20th Cloud Expo, Josh Gray, Chie...
Apr. 29, 2017 10:45 AM EDT Reads: 3,640
This recent research on cloud computing from the Register delves a little deeper than many of the "We're all adopting cloud!" surveys we've seen. They found that meaningful cloud adoption and the idea of the cloud-first enterprise are still not reality for many businesses. The Register's stats also show a more gradual cloud deployment trend over the past five years, not any sort of explosion. One important takeaway is that coherence across internal and external clouds is essential for IT right n...
Apr. 28, 2017 05:00 PM EDT Reads: 2,013
Back in February of 2017, Andrew Clay Schafer of Pivotal tweeted the following: “seriously tho, the whole software industry is stuck on deployment when we desperately need architecture and telemetry.” Intrigue in a 140 characters. For me, I hear Andrew saying, “we’re jumping to step 5 before we’ve successfully completed steps 1-4.”
Apr. 28, 2017 02:00 PM EDT Reads: 1,994
In his session at 20th Cloud Expo, Scott Davis, CTO of Embotics, will discuss how automation can provide the dynamic management required to cost-effectively deliver microservices and container solutions at scale. He will discuss how flexible automation is the key to effectively bridging and seamlessly coordinating both IT and developer needs for component orchestration across disparate clouds – an increasingly important requirement at today’s multi-cloud enterprise.
Apr. 28, 2017 06:00 AM EDT Reads: 4,494
In large enterprises, environment provisioning and server provisioning account for a significant portion of the operations team's time. This often leaves users frustrated while they wait for these services. For instance, server provisioning can take several days and sometimes even weeks. At the same time, digital transformation means the need for server and environment provisioning is constantly growing. Organizations are adopting agile methodologies and software teams are increasing the speed ...
Apr. 27, 2017 08:30 PM EDT Reads: 3,544
Software as a service (SaaS), one of the earliest and most successful cloud services, has reached mainstream status. According to Cisco, by 2019 more than four-fifths (83 percent) of all data center traffic will be based in the cloud, up from 65 percent today. The majority of this traffic will be applications. Businesses of all sizes are adopting a variety of SaaS-based services – everything from collaboration tools to mission-critical commerce-oriented applications. The rise in SaaS usage has m...
Apr. 22, 2017 06:15 PM EDT Reads: 5,118
The proper isolation of resources is essential for multi-tenant environments. The traditional approach to isolate resources is, however, rather heavyweight. In his session at 18th Cloud Expo, Igor Drobiazko, co-founder of elastic.io, drew upon his own experience with operating a Docker container-based infrastructure on a large scale and present a lightweight solution for resource isolation using microservices. He also discussed the implementation of microservices in data and application integrat...
Apr. 22, 2017 05:45 AM EDT Reads: 6,556
We'd all like to fulfill that "find a job you love and you'll never work a day in your life" cliché. But in reality, every job (even if it's our dream job) comes with its downsides. For you, the constant fight against shadow IT might get on your last nerves. For your developer coworkers, infrastructure management is the roadblock that stands in the way of focusing on coding. As you watch more and more applications and processes move to the cloud, technology is coming to developers' rescue-most r...
Apr. 22, 2017 04:00 AM EDT Reads: 4,291
2016 has been an amazing year for Docker and the container industry. We had 3 major releases of Docker engine this year , and tremendous increase in usage. The community has been following along and contributing amazing Docker resources to help you learn and get hands-on experience. Here’s some of the top read and viewed content for the year. Of course releases are always really popular, particularly when they fit requests we had from the community.
Apr. 22, 2017 03:45 AM EDT Reads: 3,852