Code analysis of OpenJDK projects

The steps below will allow us to visualise the contents of the OpenJDK projects to help understand the depth of the projects.

Using IntelliJ

Perform analysis of any of the OpenJDK projects within IntelliJ using its Code analysis functionality:

Using SonarQube

After going through the steps below, we'll have this dashboard:

[[SonarQube Configured for OpenJDK8 and OpenJDK9]]

We'll configure the 3 parts of SonarQube following SonarQube before analysing the codebase -

  • the database (to store the results);
  • the web server (to display and configure sonarqube);
  • the analyzers (which analyse code).

Then we'll run SonarQube analysis across the codebase, and create custom filters on SonarQube to show us one dashboard per version of OpenJDK.

Known issue: in the latest version of SonarQube, projects were not visible via any of the widgets, after running analysis on them - its being investigate but please feel free to post solutions if you are able to resolve it before us.

Install SonarQube on the Mac OS

Use this blog to install SonarQube or the instructions below (instructions for Mac OS, might need tweaks for other OSes)

Install MySQL and SonarQube on the Ubuntu VM

  1. Download and install MySQL on Ubuntu. See section titled "Installation" on

  2. In MySQL, create the sonar database and user -

     mysql> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
     Query OK, 0 rows affected (0.01 sec)
     mysql> CREATE USER 'sonar' IDENTIFIED BY 'sonar';
     Query OK, 0 rows affected (0.01 sec)
     mysql> GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
     Query OK, 0 rows affected (0.01 sec)
     mysql> GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
     Query OK, 0 rows affected (0.01 sec)
     Query OK, 0 rows affected (0.01 sec)
  3. From, download SonarQube and SonarQube Runner. Assuming SonarQube and SonarQube Runner are installed in /opt/sonarqube-4.5.1 and /opt/sonar-runner-2.4 respectively.

    • Configure SonarQube to use the MySQL database instead of the default in-memory one in /opt/sonarqube-4.5.1/conf/

    • Uncomment the following properties:

      . . .
      . . .
    • Start SonarQube to see the default dashboard
      $ cd /opt/sonarqube-4.5.1/bin/linux-x86-64
      $ sudo ./ start
      enter password for your user. In this case, j1a2v3a4
  4. Configure the SonarQube Runner, which will be used to analyse the projects.

     $ vi /opt/sonar-runner-2.4/conf/
  5. Maven is also used to analyse jaxp.

    • Install Maven if it's not already installed.

      • Download Maven
      • On the Maven link, follow the steps in the section titled "Unix-based operating Systems."
      • Also set the MAVEN_OPTS environment variable - it’s needed when analysing the jdk project; otherwise, Sonar complains of not having enough memory to analyse the jdk.
    • Configure Maven settings with the details of SonarQube in a sonar profile -

      $ vi /opt/maven-3.0.5/conf/setting.xml
              <!-- Example for MySQL-->
              <!-- using the default value of http://localhost:9000 does not work.
              The context root, '/sonar' is required. -->
  6. Start SonarQube and go to http://localhost:9000/sonar to verify that SonarQube started, and can see an empty dashboard.

     $ /opt/sonarqube-4.5.1/bin/linux-x86-64/ start   (path may differ)
  7. Go to http://localhost:9000/sonar

Note: if the /opt/sonarqube-4.5.1/conf/sonar-properties contains, in the “web server” section, the sonar.web.context, then in /opt/sonar-runner-2.4/conf/, set the

Otherwise, when SonarQube starts up, and tries to call the sonarqube API from the URL, http://localhost:9000, there will be no response and SonarQube will not start up.

Sample visual from SonarQube
(note: jdk repo not included; jitwatch included; zoom to see repo names;)

[[SonarQube Treemap Image]]

results matching ""

    No results matching ""