MCPcopy Index your code
hub / github.com/adoptium/emt4j

github.com/adoptium/emt4j @v0.8.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.8.0 ↗ · + Follow
1,418 symbols 3,642 edges 251 files 144 documented · 10%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Eclipse Migration Toolkit for Java (EMT4J)

EMT4J is a project that aims to simplify the Java version migration. At the moment, this project focuses on three LTS (i.e. Long-Term-Support) versions: 8, 11, and 17. Therefore, if you want to migrate your application running on JDK 8/11 to JDK 11/17, then this project is for you.

EMT4J supports statically checking application artifacts including the project's classes and dependencies. It also supports running as a Java agent to perform runtime checking. During the checking process, EMT4J collects compatibility problems and outputs a report finally. It currently supports HTML, TEXT, and JSON formats. Users transform the project according to the report and finally complete the migration of the Java version.

How to use

Maven Plugin

Find compatibility problems existing in a Maven project

Add the following configuration to pom.xml (root pom.xml if a multi-module project):

<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.emt4j</groupId>
            <artifactId>emt4j-maven-plugin</artifactId>
            <version>0.8.0</version>
            <executions>
                <execution>
                    <phase>process-test-classes</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <fromVersion>8</fromVersion>
                <toVersion>11</toVersion>
                <outputFile>report.html</outputFile>
            </configuration>
        </plugin>
    </plugins>
</build>

Then run the following command:

$ mvn process-test-classes

EMT4J's report will be generated in the project directory.

Users can also run the following command directly without modifying pom.xml:

# run with default configurations
$ mvn process-test-classes org.eclipse.emt4j:emt4j-maven-plugin:0.8.0:check
# specify outputFile and priority by -D
$ mvn process-test-classes org.eclipse.emt4j:emt4j-maven-plugin:0.8.0:check -DoutputFile=emt4j-report.html -Dpriority=p1

Configurations:

  • fromVersion: the JDK version that the project currently uses. 8 and 11 are supported, and 8 is as default.

  • toVersion: the target JDK version. 11 and 17 are supported, and 11 is as default.

  • outputFile: the destination of EMT4J's report. The default is report.html.

  • priority: the minimum rule priority. p1, p2, p3 and p4 are supported. The default is not set.

  • verbose: print more detailed messages if true.

As mentioned earlier, EMT4J supports running as a Java agent. To leverage it in the test process you need to add the following configuration:

<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.emt4j</groupId>
            <artifactId>emt4j-maven-plugin</artifactId>
            <version>0.8.0</version>
            <executions>
                <execution>
                    <phase>initialize</phase>
                    <goals>
                        <goal>inject-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>check</id>
                    <phase>test</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <fromVersion>8</fromVersion>
                <toVersion>11</toVersion>
                <outputFile>report.html</outputFile>
            </configuration>
        </plugin>
    </plugins>
</build>

Then run the following command:

$ mvn test

Find compatibility problems existing in specified files (classes, JAR, or directory)

$ mvn org.eclipse.emt4j:emt4j-maven-plugin:0.8.0:check-files -Dfiles=...

Java agent and CLI

First, you need to download the build from the link below:

Releases

The build includes two Java agents, command line tools, a maven plugin, and required dependencies.

Use Java agent standalone to perform runtime checking

  • Migration Java version from 8 to 11:

shell $ java -javaagent:<path-to-emt4j-build>/lib/agent/emt4j-agent-jdk8-0.8.0.jar=to=11,file=jdk8to11.dat

  • Migration Java version from 11 to 17:

shell $ java -javaagent:<path-to-emt4j-build>/lib/agent/emt4j-agent-jdk11-0.8.0.jar=to=17,file=11to17.dat

  • Migration Java version from 8 to 17:

shell $ java -javaagent:<path-to-emt4j-build>/lib/agent/emt4j-agent-jdk8-0.8.0.jar=to=17,file=jdk8to17.dat

  • The Java agent will record the compatibility problems found during running into the file. This file is a binary file, you need to transform it to a readable format by the command:

shell $ sh <path-to-emt4j-build>/bin/analysis.sh -o report.html <file generated by agent>

Java agent options:

  • file : the output file path. The default is emt4j-${yyyyMMddHHmmss}.dat in the current working directory.

  • to : the target JDK version.

  • priority : the minimum rule priority. p1, p2, p3 and p4 are supported. The default is not set.

Use CLI

The build contains a script named analysis located in the directory bin (.sh is for Mac or Linux users and .bat is for Windows users).

You can use this script to scan compatibility problems that exist in classes, JARS, and directories that contain classes and JARS.

  • Migration Java version from 8 to 11:

shell $ sh bin/analysis.sh -f 8 -t 11 -o report.html <files...>

  • Check JVM options shell $ sh bin/analysis.sh -f 8 -t 17 <file that contains JVM options>

Options:

  • -f : the JDK version that the project currently uses. 8 and 11 are supported.

  • -t : the target JDK version. 11 and 17 are supported.

  • -priority : the minimum rule priority. p1, p2, p3 and p4 are supported. The default is not set.

  • -p : the report format, HTML, TXT, and JSON are supported. Default is HTML

  • -o : the output file name (the default name is 'report').

  • -v : print more detailed messages.

Other Documents

Development Guide

Extension points exported contracts — how you extend this code

Render (Interface)
Define how to convert check result to file or other format. [7 implementers]
emt4j-analysis/src/main/java/org/eclipse/emt4j/analysis/report/render/Render.java
CallerProvider (Interface)
Provide caller info by different ways. Get caller is depend on JDK,so there exist JDK dependent implementation. [4 implementers]
emt4j-agent/emt4j-agent-common/src/main/java/org/eclipse/emt4j/agent/common/jdkdependent/CallerProvider.java
IncompatibleProbe (Interface)
If found a incompatible problem. [4 implementers]
emt4j-common/src/main/java/org/eclipse/emt4j/common/IncompatibleProbe.java
RunConf (Interface)
(no doc) [1 implementers]
emt4j-test/emt4j-test-common/src/main/java/org/eclipse/emt4j/test/common/RunConf.java
AnalysisOutputConsumer (Interface)
Define how to consume the output of analysis [4 implementers]
emt4j-analysis/src/main/java/org/eclipse/emt4j/analysis/AnalysisOutputConsumer.java
Recorder (Interface)
Recorder record the dependency. [3 implementers]
emt4j-agent/emt4j-agent-common/src/main/java/org/eclipse/emt4j/agent/common/file/Recorder.java
ClassMethodsAccessor (Interface)
Bytecode visits exist in many places, so need an interface that accesses bytecode. [2 implementers]
emt4j-common/src/main/java/org/eclipse/emt4j/common/classanalyze/ClassMethodsAccessor.java
ReportInputProvider (Interface)
Define interface that how to get the body record and header [3 implementers]
emt4j-analysis/src/main/java/org/eclipse/emt4j/analysis/common/ReportInputProvider.java

Core symbols most depended-on inside this repo

add
called by 140
emt4j-analysis/src/main/java/org/eclipse/emt4j/analysis/AnalysisExecutor.java
equals
called by 135
emt4j-common/src/main/java/org/eclipse/emt4j/common/Dependency.java
getValue
called by 38
emt4j-common/src/main/java/org/eclipse/emt4j/common/util/MutableObject.java
add
called by 36
emt4j-common/src/main/java/org/eclipse/emt4j/common/staticanalysis/InvokerImpl.java
contains
called by 32
emt4j-common/src/main/java/org/eclipse/emt4j/common/rule/model/JarFileName.java
getTarget
called by 26
emt4j-common/src/main/java/org/eclipse/emt4j/common/Dependency.java
isEmpty
called by 24
emt4j-agent/emt4j-agent-common/src/main/java/org/eclipse/emt4j/agent/common/rule/cldr/CLDRSensitiveEnterCallback.java
getDependType
called by 24
emt4j-common/src/main/java/org/eclipse/emt4j/common/Dependency.java

Shape

Method 1,156
Class 240
Interface 13
Enum 9

Languages

Java100%

Modules by API surface

emt4j-common/src/main/java/org/eclipse/emt4j/common/DependTarget.java36 symbols
emt4j-common/src/main/java/org/eclipse/emt4j/common/Dependency.java30 symbols
emt4j-common/src/main/java/org/eclipse/emt4j/common/classanalyze/AsmClassMethodsAccessor.java29 symbols
emt4j-common/src/main/java/org/eclipse/emt4j/common/i18n/I18nResourceUnit.java27 symbols
emt4j-analysis/src/main/java/org/eclipse/emt4j/analysis/common/util/DeprecateAPIScanTool.java26 symbols
emt4j-analysis/src/main/java/org/eclipse/emt4j/analysis/report/render/ResultDetail.java25 symbols
emt4j-test/emt4j-test-common/src/main/java/org/eclipse/emt4j/test/common/Artifact.java23 symbols
emt4j-test/emt4j-test-common/src/main/java/org/eclipse/emt4j/test/common/JavaSource.java19 symbols
emt4j-test/emt4j-test-common/src/main/java/org/eclipse/emt4j/test/common/CompileUtil.java16 symbols
emt4j-common/src/main/java/org/eclipse/emt4j/common/rule/model/ConfRuleItem.java15 symbols
emt4j-common/src/main/java/org/eclipse/emt4j/common/ReportConfig.java15 symbols
emt4j-common/src/main/java/org/eclipse/emt4j/common/MethodDesc.java14 symbols

For agents

$ claude mcp add emt4j \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact