Page tree
Skip to end of metadata
Go to start of metadata

On this page:

Target audience:

Users of the extension providing JEE analysis support.

Summary: This document provides information about the extension providing JEE analysis support.

Extension ID

com.castsoftware.jee

Prerequisites

Please see JEE - Required third-party software.

Description

This extension provides support for JEE.

What's new?

Please see the following pages for information about new features/changes, fixed bugs, changes that will impact results etc.:

Technology support

See JEE - Covered technologies and also JEE - Technology support notes for additional information.

Java 9 support

Private Methods in Interface

From Java 9 onward, users can write private methods in interfaces using the private access modifier as shown in following sample of code. These methods are now supported by the JEE Analyzer:

public interface DBLogging {
    String MONGO_DB_NAME = "ABC_Mongo_Datastore";
    String NEO4J_DB_NAME = "ABC_Neo4J_Datastore";
    String CASSANDRA_DB_NAME = "ABC_Cassandra_Datastore";
    default void logInfo(String message) {
        log(message, "INFO");
    }
     default void logWarn(String message) {
        log(message, "WARN");
    }
     default void logError(String message) {
        log(message, "ERROR");
    }
     default void logFatal(String message) {
        log(message, "FATAL");
    }
     private void log(String message, String msgPrefix) {
        // Step 1: Connect to DataStore
        // Step 2: Log Message with Prefix and styles etc.
        // Step 3: Close the DataStore connection
    }
    // Any other abstract, static, default methods
}

Module concept 

  • Starting with Java 9, new concepts of modules are introduced directly in-between packages and class loaders. It encapsulates packages and the classes there in.
  • A specific module-info.java is used for module declaration and a new syntax has been introduced for this purpose.
Currently we do not support this new concept - support will be provided in a future release. However, the JEE analyzer has been modified to ignore module-info.java files to avoid syntax errors when this type of file is present in the source code.

Java 10 support

Local-Variable Type Inference (JEP 286)

Java 10 extends type inference to declarations of local variables with initializers and introduces the use of 'var' for the purpose of local-variable type inference. This makes local variable definitions clear and concise. See the examples below.

Pre JAVA 10 : local variable type inference
/* before Java 10, the type of the local variables were to be specified explicitly */

ArrayList<String> list = new ArrayList<>();

for( Iterator<String> iter=list.iterator() ; iter.hasNext() ; ) {
	// do something here
}

for ( String ele : list ) {
    int len = ele.length(); 
}

Since JAVA 10 : local variable type inference
/* Since java 10, local variable type inferenence is implicit from the initialization expression */

var list = new ArrayList<String>(); 

for( var iter=list.iterator() ; iter.hasNext() ; ) {
	// iter infers type from its assigned value
}

for ( var ele : list ) {
	// 'ele' is resolved to the enclosed type of the iterable (String here)
    var len = ele.length(); 
}

Enlighten will also display the resolved types as seen below

Java 11 support

Local-Variable Syntax for Lambda Parameters (JEP 323)

This JEP will allow "var" to be used when declaring the formal parameters of implicitly typed lambda expressions. This aligns the syntax of lambdas with Java 10's local-variable type inference. Instead of writing this:

Pre JAVA 11 : lambda definition
(x, y) -> x.process(y)

We’ll be able to write this in Java 11:

Since JAVA 11 : local variable type inference for lambda parameters
(var x, var y) -> x.process(y)

Annotations can also be applied to the lambda formal parameters:

Since JAVA 11
(@CustomAnnot var m, var n) -> m.processUDT(n)

Enlighten's code viewer will display the resolution of var for lambdas. A sample is shown below:

The new APIs introduced in Java 11 will also be resolved in Enlighten. For example, here are some of the new String APIs:

Java 14 support

This feature extends switch so it can be used as either a statement or an expression, and so that both forms can use either traditional case labels (with fall through) or new case ->labels (with no fall through), with a further new statement for yielding a value from a switch expression.

For example:

Before the new support:

switch as statement | Java 11
String s = null;
switch (k) {
    case 1: s="one";
            break;
    case 2:
    case 3: s="many";
            break;
    default: s="too many!!";
             break;
}

After the new support:

switch as expression | Java 14
String s = switch (k) {
    case 1   -> "one";
    case 2,3 -> "many";
    default  -> {
        String s = "too many!!";
        yeild s;
    }
};

For more details refer:  JEP 361: Switch Expressions

Java 15 support

The text block has been standardized in Java 15 with no further changes from its second preview state in Java 14. 

Text Block sample for Java 15
void foo() {
    String s = """                          
       line 1
    \\ line 2
    // line 3
       line 4 "
       line 5 ""
       line 6 """;
    String x = """
            " xyz "
            """;
    String z = """
             xyz
            """;
}

For more details refer: JEP 378: Text Block 

Java 16 support

Pattern Matching for instanceof

This feature, introduced in Java 14,  is now standardized in Java 16. In this release, pattern variables are no longer implicitly final, and it's a compile-time error if a pattern instanceof expression compares an expression of type S with a pattern of type T, where S is a subtype of T.

For example:

Pattern matching for instanceof | Java 16
...
if (rectangle instanceof Shape s) {
   return s.getName();
}
...

For more details refer:  JEP 394: Pattern Matching for instanceof

Records

This feature, introduced in Java 14 as a preview feature, has now been standardized in Java 16 with minor improvements on the changes made in the second preview in Java 15.

For example, the record defined below automatically contains a constructor, accessor methods, and implementations of hashCode(), equals() and toString():

Records | Java 16
record Employee(String name, String designation) {}

For more details refer:  JEP 395: Records

Java 17 support

Sealed Classes

This feature provides a mechanism to control which classes or types are permitted to extend or implement a class or interface respectively. 

For example:

Sealed Classes | Java 17
//base class
public abstract sealed class SealedClasses
  permits Circle, Square {}

//make the subclass 'final' to stop the heirarchy chain.
final class Circle extends SealedClasses {}

//'unseal' the class to allow the class to be inherited again by unknown subclasses.
non-sealed class Square extends SealedClasses {}

For more details refer:  JEP 409: Sealed Classes

Java 18 support

JEE supports the latest APIs from JDK 18.

Analysis configuration for Java JDK 9 - 18

By default, AIP Console/CAST Management Studio will not specifically offer JDK 9 - 18 options in the Java Version configurations setting (see JEE - Analysis configuration). Instead, the CAST will assume that that latest version of the JDK has been used to compile the application source code - and in this case, "Latest" includes support for Java 9 - 18.

Function Point, Quality and Sizing support

This extension provides the following support:

  • Function Points (transactions): a green tick indicates that OMG Function Point counting and Transaction Risk Index are supported
  • Quality and Sizing: a green tick indicates that CAST can measure size and that a minimum set of Quality Rules exist
MeasurementSupported
Function Points (transactions)(tick)
Quality and Sizing(tick)

CAST AIP compatibility

This extension is compatible with:

CAST AIP releaseSupported
8.3.x(tick)
8.2.x(error)

Supported DBMS servers

This extension is compatible with the following DBMS servers:

DBMS serversSupported
CSS/PostgreSQL(tick) 
Oracle(tick) 
Microsoft(tick) 

Dependencies with other extensions

Some CAST AIP extensions require the presence of other CAST AIP extensions in order to function correctly. The JEE Analyzer extension requires that the following other CAST AIP extensions are also installed:

  • Web services linker service (internal technical extension)


Note that when using AIP Console to install the extension, any dependent extensions are automatically downloaded and installed for you. You do not need to do anything.

Download and installation instructions

Please see:

Note that a specific version of the JEE Analyzer extension is shipped with AIP Core. However, this release may not be the release you want to use, therefore you should check before beginning the analysis that the correct extension release is being used. You can see the list of shipped extensions for each release of AIP Core here: Technology coverage changes in CAST AIP 8.3.x.

Application qualification information

Please see: JEE - Application qualification specifics

Prepare and deliver the source code

Please see: JEE - Prepare and deliver the source code

Analysis configuration and execution

Please see: JEE - Analysis configuration and execution and all child pages:

What analysis results can you expect?

Please see: JEE - Analysis results

Structural rules

The vast majority of rules provided for the JEE Analyzer are embedded in CAST AIP - see JEE - Structural rules for more information. In addition, some rules are also provided with the extension:

Current known limitations

Quality Rules

Avoid static field of type collection (7562)

When calculating a snapshot for applicationusing JSE 5.0, the Quality Rule "Avoid static field of type collection (7562)" does not list as "Very High Risk Objects" classes that are or inherit from a Generic collection. The Quality Rule lists only the non generic form of collections. For example static attributes of type java.util.Collection<E> will not be reported as a violation.

Persistence: Avoid table and column names that are too long (portability) (7706)

Situation:

  • JEE application using the Java Persistence API (JPA), e.g. in the form of Hibernate.
  • A table or column name is not specified in the annotations of the JPA entity.

Symptoms: The JPA entity is not listed as a "Very High Risk" object in the results.

No link bookmarks generated

When Java Methods are defined inside a JSP file, no link bookmarks are generated (bookmarks can be seen in CAST Enlighten or in the Dynamic Link Manager). Example of a Java Method defined in a JSP file:

<%@ page language="Java" %> 
<%! 
public void myMethod(String message)
{ System.out.println(message); } 
%> 

  • No labels