Welcome!

Eclipse Authors: Pat Romanski, Elizabeth White, Liz McMillan, David H Deans, JP Morgenthal

Related Topics: Java IoT, Eclipse, Recurring Revenue

Java IoT: Article

Five Years Waiting for JRE 7: Is It Justified? (Part 1)

Comparing JRE 6 to JRE 7

Metric View
In the Metric View, the code base is represented through a Treemap. Treemapping is a method for displaying tree-structured data by using nested rectangles. The tree structure used in a JavaDepend treemap is the usual code hierarchy:

  • Java projects contain packages
  • Packages contain types
  • Types contain methods and fields

The treemap view provides a useful way to represent the result of CQL request, so we can see the types concerned by the request.

For example to have an idea of which types were added to JRE 7, we can execute the following CQL request:

SELECT TYPES WHERE WasAdded

The blue rectangles represent all code elements added.

Code Changes
Dependency cycles betwen jars. Having a dependency cycle is an indicator of a lack of levelization, and to improve the design it's better to avoid them. Here's a nice blog post that describes the goal of layering. JRE 6 as shown by the following dependency graph contains three dependency cycles between jars.

But for JRE 7 a refactoring was made, and the dependency cycle between rt and charsets was removed.

What changes made in JRE 7 were responsible for removing this dependency cycle? To answer this question let's discover what rt jar was used before in other jars.

SELECT TYPES WHERE IsDirectlyUsedBy "rt"

Only HKSCS from charsets was used in rt. This class was removed from charsets to rt  and that explain why the dependency cycle disappeared. But other dependency cycles remain. To see what code elements are implied in this dependency cycle, let’s search for types used by rt that exist in other jars concerned with the dependency cycle.

The interesting remark is that for jsse only two types remain used. Before in JRE 6 18 types was used, and we hope that for the next release this dependency cycle disappears also.

Abstractness vs Instability
The “Abstractness vs Instability” graph can be useful to detect projects that will be difficult to change. This following post describes the utility of this graph and how to exploit it to improve the design. It's interesting to know if with JRE 7 this indicator has improved or not. Here's the graph regarding JRE 6.

As we can observe only rt is in the red zone. That means that any changes to rt could impact other jars and a big testing effort is needed to validate that there's no regression. And here's the graph regarding JRE 7.

It has shifted a little more than before into the red zone, which is not a good point for JRE 7, there's more risk when changing rt.

Methods Changed
To detect implementation refactoring we can search all methods where the code was changed.

SELECT METHODS WHERE CodeWasChanged

Only 5% of the code was changed. Methods became deprecated

It's very useful to know which methods became deprecated to avoid using them.

Onlya  few methods became deprecated. And we can also search for deprecated methods but still used by other methods. In this case it's preferable to refactor them.

SELECT  METHODS WHERE IsDeprecated AND MethodCa >0

Dominant Paradigm: Generics or OOP?
2799 types were added to JRE, and it's interesting to know if these types are generics or classes.

SELECT TYPES WHERE WasAdded AND IsGeneric 

Only some types added are generics, so the dominant paradigm is still OOP.

Annotations
Annotation is a mechanism for associating a meta-tag with code elements and allowing the compiler or the VM to extract program behaviors from these annotated elements and generate interdependent code when necessary. It makes your development easier by allowing you to spend less time writing boilerplate code under many circumstances by enabling tools to generate it from annotations in the source code. Let's search for annotations added in JRE 7.

SELECT TYPES WHERE IsAnnotationClass AND WasAdded

Code Complexity
Cyclomatic complexity is a popular procedural software metric equal to the number of decisions that can be taken in a procedure. This metric is computed from source code. BCCyclomaticComplexity is the same as Cyclomatic Complexity but computed from byte code.

The following request provides more info about the complexity in JRE 6.

SELECT  TYPES WHERE IsInOlderBuild  AND BCCyclomaticComplexity >0

The average is equal to 20, It's interesting to know the evolution of this average for new features added to JRE7.

SELECT  TYPES WHERE WasAdded AND BCCyclomaticComplexity >0 

The cyclomatic complexity average had decreased slightly for new features added to JRE 7.

Coupling
Low coupling is desirable because a change in one area of an application will require less changes throughout the entire application. In the long run, this could alleviate a lot of time, effort, and cost associated with modifying and adding new features to an application.

Using interfaces and abstract classes improve the low coupling. Let's search for these kind of types in the added code of JRE 7.

SELECT TYPES WHERE (IsInterface OR IsAbstract) AND WasAdded 

Many interfaces were added. It's a good indicator that features added are described by their contracts and we have the possibility of having many implementations for the same contract, which makes JRE very flexible. For example, if we search types implementing WindowFactory interface:

SELECT TYPES WHERE Implement "com.sun.deploy.uitoolkit.WindowFactory"

Cohesion
The single responsibility principle states that a class should have one, and only one, reason to change. Such a class is said to be cohesive. A high LCOM value generally pinpoints a poor cohesive class. There are several LCOM metrics. The LCOM takes its values in the range [0-1]. The LCOMHS (HS stands for Henderson-Sellers) takes its values in the range [0-2]. Note that the LCOMHS metric is often considered a more efficient way to detect non-cohesive types. A LCOMHS value higher than 0.95 should be considered alarming. Let's search for added that can be considerd noncohesive.

SELECT TYPES WHERE LCOMHS > 0.95 AND   NbFields > 10 AND   NbMethods >10 AND WasAdded

Only three classes could be considered noncohesive.

Conclusion
Meir Manny Lehman said: "As an evolving program is continually changed, its complexity, reflecting deteriorating structure, increases unless work is done to maintain or reduce it." We have to be aware of any evolution and try to improve the implementation and design. For that we need to audit the code after each developement iteration to keep the code flexible and easy to maintain. Regarding JRE no big changes concerning refactoring were made and only 5% of the existing code was changed. In the next post we will focus more on added types, and see if there are many features added that can explain the five year wait.

More Stories By Lahlali Issam

Lahlali Issam Lead Developer at JavaDepend, a tool to manage and understand complex Java code. With JavaDepend, software quality can be measured using Code Metrics, visualized using Graphs and Treemaps, and queried using CQL language, a SQL like to query the code base.

IoT & Smart Cities Stories
IoT is rapidly becoming mainstream as more and more investments are made into the platforms and technology. As this movement continues to expand and gain momentum it creates a massive wall of noise that can be difficult to sift through. Unfortunately, this inevitably makes IoT less approachable for people to get started with and can hamper efforts to integrate this key technology into your own portfolio. There are so many connected products already in place today with many hundreds more on the h...
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
SYS-CON Events announced today that IoT Global Network has been named “Media Sponsor” of SYS-CON's @ThingsExpo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. The IoT Global Network is a platform where you can connect with industry experts and network across the IoT community to build the successful IoT business of the future.
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
Disruption, Innovation, Artificial Intelligence and Machine Learning, Leadership and Management hear these words all day every day... lofty goals but how do we make it real? Add to that, that simply put, people don't like change. But what if we could implement and utilize these enterprise tools in a fast and "Non-Disruptive" way, enabling us to glean insights about our business, identify and reduce exposure, risk and liability, and secure business continuity?
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering Cloud Expo and @ThingsExpo will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at Cloud Expo. Product announcements during our show provide your company with the most reach through our targeted audiences.
DXWorldEXPO LLC announced today that Telecom Reseller has been named "Media Sponsor" of CloudEXPO | DXWorldEXPO 2018 New York, which will take place on November 11-13, 2018 in New York City, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
To Really Work for Enterprises, MultiCloud Adoption Requires Far Better and Inclusive Cloud Monitoring and Cost Management … But How? Overwhelmingly, even as enterprises have adopted cloud computing and are expanding to multi-cloud computing, IT leaders remain concerned about how to monitor, manage and control costs across hybrid and multi-cloud deployments. It’s clear that traditional IT monitoring and management approaches, designed after all for on-premises data centers, are falling short in ...
The deluge of IoT sensor data collected from connected devices and the powerful AI required to make that data actionable are giving rise to a hybrid ecosystem in which cloud, on-prem and edge processes become interweaved. Attendees will learn how emerging composable infrastructure solutions deliver the adaptive architecture needed to manage this new data reality. Machine learning algorithms can better anticipate data storms and automate resources to support surges, including fully scalable GPU-c...