mirror of
https://github.com/corda/corda.git
synced 2024-12-28 00:38:55 +00:00
Utilities for diffing the deterministic JVM with JDK8 (#86)
This commit is contained in:
parent
c3f5ca41e1
commit
bb9c0dee07
47
sgx-jvm/tools/jvm-diff/README.md
Normal file
47
sgx-jvm/tools/jvm-diff/README.md
Normal file
@ -0,0 +1,47 @@
|
||||
### Overview
|
||||
|
||||
This folder has a set of utilities for generating a report outlining the
|
||||
differences between two versions of the OpenJDK project, more specifically, the
|
||||
`rt.jar` build artefact across versions.
|
||||
|
||||
##### Files
|
||||
|
||||
The following scripts and utilities are used:
|
||||
|
||||
* `compare-versions.sh` - extract exclusions and binary diff between JDK8 and
|
||||
Deterministic JVM
|
||||
* `find-exclusions.sh` - utility used in the above script to find JavaDoc
|
||||
exclusions in code base
|
||||
* `generate-report.sh` - once the data has been gathered with
|
||||
`compare-versions.sh`, this script can be used to generate an HTML report
|
||||
* `report-template.html` - the template to use for the HTML report
|
||||
* `flatten.sh` - flatten the file hierarchy of supporting diff and exclusion
|
||||
files into a single directory
|
||||
|
||||
##### Dependencies
|
||||
|
||||
* Tweaked version of the [Package Changes Analyzer (corda/pkgdiff)](https://github.com/corda/pkgdiff)
|
||||
|
||||
##### Assumptions
|
||||
|
||||
The first two scripts are intended to be run from the root directory of the
|
||||
OpenJDK project, and assume two built JAR files:
|
||||
|
||||
* `jdk-8.0.0.jar`, which is the `rt.jar` build artefact for branch
|
||||
`jdk8u/jdk8u`
|
||||
* `jdk-8.0.0-determinstic.jar`, which is the `rt.jar` build artefact for
|
||||
branch `deterministic-jvm8`
|
||||
|
||||
### How to run?
|
||||
|
||||
From the root folder of your cloned OpenJDK project:
|
||||
|
||||
1. Assuming that the files in this folder is in a subfolder `tools` of the
|
||||
OpenJDK root folder
|
||||
2. Build `jdk8u/jdk8u` and copy `build/<target>/images/lib/rt.jar` to
|
||||
`jdk-8.0.0.jar`
|
||||
3. Build `deterministic-jvm8` and copy `build/<target>/images/lib/rt.jar` to
|
||||
`jdk-8.0.0-deterministic.jar`
|
||||
4. Run `bash tools/compare-versions.sh`
|
||||
5. Make a copy of the resulting report:
|
||||
- `report/`
|
23
sgx-jvm/tools/jvm-diff/compare-versions.sh
Executable file
23
sgx-jvm/tools/jvm-diff/compare-versions.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASE_VERSION="jdk-8.0.0.jar"
|
||||
NEW_VERSION="jdk-8.0.0-deterministic.jar"
|
||||
|
||||
# Derive list of differences between the two JARs
|
||||
pkgdiff -check-byte-code -extra-info pkgdiff_extra \
|
||||
"$BASE_VERSION" "$NEW_VERSION"
|
||||
|
||||
# Find packages and classes marked for exclusion in JavaDoc
|
||||
${SHELL} tools/find-exclusions.sh
|
||||
|
||||
# Generate report
|
||||
sed -n '1,/\/\* DATASET \*\//p' < ./tools/report-template.html > report.html
|
||||
${SHELL} tools/generate-report.sh >> report.html
|
||||
sed -n '/\/\* DATASET \*\//,$p' < ./tools/report-template.html >> report.html
|
||||
|
||||
# Generate structure for upload to Azure
|
||||
mkdir -p report
|
||||
mv exclusions pkgdiff_extra pkgdiff_reports report/
|
||||
cd report
|
||||
${SHELL} ../tools/flatten.sh
|
||||
cd ..
|
36
sgx-jvm/tools/jvm-diff/find-exclusions.sh
Executable file
36
sgx-jvm/tools/jvm-diff/find-exclusions.sh
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
OUTPUT_DIR=exclusions
|
||||
|
||||
rm -rf "$OUTPUT_DIR"
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
if [[ $(uname) = "Darwin" ]]; then
|
||||
alias sed=gsed # ensure that we use GNU sed on macOS
|
||||
fi
|
||||
|
||||
function files_with_exclusions {
|
||||
local DIRS="jaxp jaxws jdk"
|
||||
find $DIRS -name '*.java' -exec grep -l '@exclude' {} \;
|
||||
}
|
||||
|
||||
function extract_exclusions {
|
||||
echo -n "."
|
||||
echo "$1" >> "$OUTPUT_DIR/files.dat"
|
||||
mkdir -p "$OUTPUT_DIR/$(dirname "$1")"
|
||||
cat "$1" | \
|
||||
sed 's/^\s*package/public package/' | \
|
||||
sed 's/^\s*class/public class/' | \
|
||||
sed -n '/@exclude/,/public.*[a-z]/{
|
||||
s/^.*\(@exclude.*\)$/\/\/ \1/p;
|
||||
s/^\s*\(public.*[a-z].*\)$/\1/p
|
||||
}' | \
|
||||
sed 's/^public package/package/' | \
|
||||
sed 's/[ ][ ]*/ /g' | \
|
||||
sed 's/[{][ ]*$//g' \
|
||||
> "$OUTPUT_DIR/$1"
|
||||
}
|
||||
|
||||
echo -n "Finding files with exclusions ..."
|
||||
files_with_exclusions | while read f; do extract_exclusions "$f"; done
|
||||
echo " [done]"
|
5
sgx-jvm/tools/jvm-diff/flatten.sh
Executable file
5
sgx-jvm/tools/jvm-diff/flatten.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
find {pkgdiff_reports/jdk,exclusions} -type f \( -iname '*.html' -o -iname '*.java' \) | while read f; do
|
||||
mv $f $(echo $f | tr '/' '.')
|
||||
done
|
76
sgx-jvm/tools/jvm-diff/generate-report.sh
Executable file
76
sgx-jvm/tools/jvm-diff/generate-report.sh
Executable file
@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
|
||||
REPORT_FILE="$1"
|
||||
EXCLUSIONS_FILE="$2"
|
||||
|
||||
if [[ -z "$REPORT_FILE" ]]; then
|
||||
REPORT_FILE=pkgdiff_extra/files.xml
|
||||
fi
|
||||
|
||||
if [[ -z "$EXCLUSIONS_FILE" ]]; then
|
||||
EXCLUSIONS_FILE=exclusions/files.dat
|
||||
fi
|
||||
|
||||
function category {
|
||||
CATEGORY="$1"
|
||||
if [[ $CATEGORY = 'exclusions' ]]; then
|
||||
if [[ ! -z "$EXCLUSIONS_FILE" ]]; then
|
||||
cat $EXCLUSIONS_FILE
|
||||
fi
|
||||
return
|
||||
fi
|
||||
cat $REPORT_FILE \
|
||||
| sed '/META-INF/d' \
|
||||
| sed -n "/<$CATEGORY>/,/<\/$CATEGORY>/p" \
|
||||
| sed '1d; $d' \
|
||||
| sed 's/^[ \t]*//'
|
||||
}
|
||||
|
||||
function unchanged_rows {
|
||||
# file
|
||||
cat \
|
||||
| sed 's/^\(.*\.class\)$/["class", "\1", "unchanged", "", ""],/' \
|
||||
| sed 's/^\([^.]*\)$/["package", "\1", "unchanged", "", ""],/'
|
||||
}
|
||||
|
||||
function added_rows {
|
||||
# file
|
||||
cat \
|
||||
| sed 's/^\(.*\.class\)$/["class", "\1", "added", "", ""],/' \
|
||||
| sed 's/^\([^.]*\)$/["package", "\1", "added", "", ""],/'
|
||||
}
|
||||
|
||||
function removed_rows {
|
||||
# file
|
||||
cat \
|
||||
| sed 's/^\(.*\.class\)$/["class", "\1", "removed", "", ""],/' \
|
||||
| sed 's/^\([^.]*\)$/["package", "\1", "removed", "", ""],/'
|
||||
}
|
||||
|
||||
function changed_rows {
|
||||
# file ([0-9]+%)
|
||||
sed 's/^\([^ ]*\)[ ](\([^)]*\))$/["class", "\1", "changed", "\2", "\1"],/'
|
||||
}
|
||||
|
||||
function renamed_rows {
|
||||
# from;to ([0-9]+%)
|
||||
sed 's/^\([^;]*\);\([^ ]*\) (\([0-9%.]*\))$/["class", "\1 -> \2", "renamed", "\3", ""],/'
|
||||
}
|
||||
|
||||
function moved_rows {
|
||||
# from;to ([0-9]+%)
|
||||
sed 's/^\([^;]*\);\([^ ]*\) (\([0-9%.]*\))$/["class", "\1 -> \2", "moved", "\3", ""],/'
|
||||
}
|
||||
|
||||
function exclusion_rows {
|
||||
# file
|
||||
sed 's/^\([^ ]*\)$/["java", "\1", "exclusions", "", "\1"],/'
|
||||
}
|
||||
|
||||
category 'unchanged' | unchanged_rows
|
||||
category 'added' | added_rows
|
||||
category 'removed' | removed_rows
|
||||
category 'changed' | changed_rows
|
||||
category 'moved' | moved_rows
|
||||
category 'renamed' | renamed_rows
|
||||
category 'exclusions' | exclusion_rows
|
161
sgx-jvm/tools/jvm-diff/report-template.html
Normal file
161
sgx-jvm/tools/jvm-diff/report-template.html
Normal file
@ -0,0 +1,161 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>
|
||||
JDK: 8.0.0 to 8.0.0-deterministic
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" />
|
||||
<!-- {{{ Styles -->
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family:Arial, sans-serif;
|
||||
font-size:11px;
|
||||
background-color:White;
|
||||
color:Black;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
th.file-column {
|
||||
text-align: left;
|
||||
}
|
||||
td.type-column {
|
||||
text-align: center;
|
||||
color: #c0c0c0;
|
||||
}
|
||||
td.file-column {
|
||||
text-align: left;
|
||||
font-size: 0.875em;
|
||||
font-family: Consolas, 'DejaVu Sans Mono', 'Droid Sans Mono', Monaco, Monospace;
|
||||
white-space: normal;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
td.status-column {
|
||||
text-align: center;
|
||||
}
|
||||
td.change-column {
|
||||
text-align: center;
|
||||
}
|
||||
td.diff-column {
|
||||
text-align: center;
|
||||
}
|
||||
table.summary {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
span.status {
|
||||
padding: 5px 10px;
|
||||
border-radius: 2px;
|
||||
min-width: 50px;
|
||||
display: inline-block;
|
||||
}
|
||||
span.status-added {
|
||||
background-color: #00d800;
|
||||
}
|
||||
span.status-changed {
|
||||
background-color: #e8b411;
|
||||
}
|
||||
span.status-removed {
|
||||
background-color: #c00000;
|
||||
color: #ffffff;
|
||||
}
|
||||
span.status-moved {
|
||||
background-color: #e8b411;
|
||||
}
|
||||
span.status-renamed {
|
||||
background-color: #e8b411;
|
||||
}
|
||||
span.status-exclusions {
|
||||
background-color: #c00000;
|
||||
color: #ffffff;
|
||||
}
|
||||
span.status-unchanged {
|
||||
background-color: #00d800;
|
||||
}
|
||||
th input[type="text"] {
|
||||
outline: none;
|
||||
width: 100%;
|
||||
padding: 5px;
|
||||
border: 1px solid #e8e8e8;
|
||||
}
|
||||
</style>
|
||||
<!-- Styles }}} -->
|
||||
<!-- {{{ Scripts -->
|
||||
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
|
||||
<script type="text/javascript" language="JavaScript">
|
||||
<!--
|
||||
$(function() {
|
||||
var dataset = [
|
||||
// {{{ Dataset
|
||||
|
||||
/* DATASET */
|
||||
|
||||
// Dataset }}}
|
||||
];
|
||||
|
||||
var statusRenderFunc = function (data, type, row, meta) {
|
||||
return '<span class="status status-' + data + '">' + data + '</span>';
|
||||
};
|
||||
var diffRenderFunc = function (data, type, row, meta) {
|
||||
if (data) {
|
||||
if (data.endsWith('.java')) {
|
||||
return '<a href="exclusions.'+data.replace(/\//g, '.')+'" target="_blank">(view)</a>';
|
||||
} else {
|
||||
return '<a href="pkgdiff_reports.jdk.8.0.0_to_8.0.0-deterministic.diffs.'+data.replace(/\//g, '.')+'-diff.html" target="_blank">(view)</a>';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
$('.summary tfoot th').each( function () {
|
||||
var title = $(this).text();
|
||||
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
|
||||
});
|
||||
|
||||
var table = $('.summary').DataTable({
|
||||
'order': [[ 1, 'asc' ]],
|
||||
'pageLength': 100,
|
||||
'lengthMenu': [ 10, 25, 50, 100, 1000, 10000, 25000 ],
|
||||
'data': dataset,
|
||||
'columns': [
|
||||
{ 'title': 'Type', 'className': 'type-column' },
|
||||
{ 'title': 'File', 'width': '70%', 'className': 'file-column' },
|
||||
{ 'title': 'Status', 'className': 'status-column', 'render': statusRenderFunc },
|
||||
{ 'title': 'Change', 'className': 'change-column' },
|
||||
{ 'title': 'Differences', 'className': 'diff-column', 'render': diffRenderFunc },
|
||||
]
|
||||
});
|
||||
|
||||
table.columns().every( function () {
|
||||
var that = this;
|
||||
$( 'input', this.footer() ).on( 'keyup change', function () {
|
||||
if ( that.search() !== this.value ) {
|
||||
that
|
||||
.search( this.value )
|
||||
.draw();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
});
|
||||
-->
|
||||
</script>
|
||||
<!-- Scripts }}} -->
|
||||
</head>
|
||||
<body>
|
||||
<table class="summary">
|
||||
<tfoot>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tfoot>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user