Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e76fec9b1b333acfd18f580a89ea0e688e0a0a94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#*******************************************************************************
# Copyright (c) 2017 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
#     Sravan Kumar Lakkimsetti - initial API and implementation
#*******************************************************************************

# Utility to generate jdeps -jdkinternals report
# Requires 2 parameters
#    - repo location
#    - output filename (full path)

# Uses JAVA_HOME environment variable if set. else defaults to /shared/common/jdk1.8.0_x64-latest

JAVA_8_HOME=/shared/common/jdk1.8.0_x64-latest
export JAVA_HOME=${JAVA_HOME:-${JAVA_8_HOME}}

if [ $# -ne 2 ]
then
  echo "USAGE: $0 <Repository Location> <report file name with full path>"
  exit 1
fi

repo=$1
outputFile=$2
outputDir=$(dirname ${outputFile})

if [ ! -d "${repo}" ]
then
  echo "${repo} does not exist. Exiting ...."
  exit 1
fi

if [ ! -d "${JAVA_HOME}" ]
then
  echo "${JAVA_HOME} does not exist. Please set JAVA_HOME and run again ...."
  exit 1
fi

mkdir -p ${outputDir}

echo -e "\n\n\n#jdeps -jdkinternals output:" > ${outputFile}
find ${repo} -name "*.jar" -print > ${outputFile}.tmp
for i in $(sort ${outputFile}.tmp)
do
  ${JAVA_HOME}/bin/jdeps -jdkinternals ${i} > ${outputFile}.interim
  fileSize=$(stat -c %s ${outputFile}.interim)
  if [ $fileSize -gt 0 ]
  then
    echo -e "\n###### Start of Java internal API usage report for $(basename ${i}) \n">> ${outputFile}
    cat ${outputFile}.interim >> ${outputFile}
    echo -e "\n###### End of Java internal API usage report for $(basename ${i}) \n">> ${outputFile}
    echo -e "\n" >> ${outputFile}
  fi
  rm ${outputFile}.interim
done
echo "# " >> ${outputFile}

#Cleanup
rm ${outputFile}.tmp

Back to the top