Home

Awesome

ENRE-Java

ENRE (ENtity Relationship Extractor) is a tool for extraction of code entity dependencies or relationships from source code.

Features

Supported Language

LanguageMaximum Version
Java17

Documentation

Specifications on which kinds of entities and relations can be captured and any other details can be found in docs.

Usage

1. Prepare the executable jar

The released jar of ENRE-Java is named as enre_java.jar

2. Set up Java environment

To execute enre_java.jar, you should set up Java environment: at least JDK 11 version.

If the project is quite larger, such as base columns under Android, please increase the memory heap above 8G.

3. cmd usage

The usage command is:

java -jar <executable> <lang> <dir> <project-name>

The detailed information of the parameter and option of the command is:

Usage: enre_java [-hs] [-a=<aidl>] [-e=<external>] [-hd=<hidden>]
                 [-o=<outputFile>] [-d=<dir>]... <lang> <src> <projectName>
      <lang>          The lanauge of project files: []
      <src>           The directory to be analyzed
      <projectName>   The analyzed project file name
  -a, --aidl=<aidl>   If the analyzed project is an Android project which
                        contains .aidl files, please provide the corresponding .
                        java files which have the same relative path with the
                        original file
  -d, --dir=<dir>     The additional directories to be analyzed
  -e, --external=<external>
                      The third party APIs which need to identify
  -h, --help          Display this help and exit
      -hd, --hidden=<hidden>
                      The path of hiddenapi-flag.csv
  -o, --output=<outputFile>
                      The output file name, default is projectName-out
  -s, --slim          The slim output version, which removing the location and
                        external entity info.

To increase the memory heap, you can add -Xmx before -jar, like:

java -Xmx20G -jar <executable> <lang> <dir> <include-dir> <project-name>
Example:
# in windows platform
$java -jar enre_java.jar java demo-projects\halo_1.4.10 halo_1.4.10

After analysis, ENRE-Java finally outputs the resolved entities and dependencies in JSON files in current directory.

# in windows platform
$java -jar enre_java.jar java ...\frameworks\base base -a <aidl-path>
# in windows platform
$java -jar enre_java.jar java ...\frameworks\base base -d ...\base

Testing

Prerequisite

Steps

ENRE-java is integrated with ENRE-test. All you need to do for performing unit test is running the following script:

  1. Fetch the latest enre-java-test codebase locally:
python3 ./scripts/update_submodule.py
  1. Generate test cases and suites:
python3 ./scripts/gen_tests.py

Test cases and JUnit java files will be generated under directory src/test/resources/cases and src/test/java/client.

you can execute all JUnit test cases by executing the following command in the project directory:

mvn clean test

or execute specific test case by passing class name:

mvn clean test -DTest=AClassDefinesAFieldTest

If you want to build the package without executing any test case:

mvn clean package assembly:single -DskipTests