forked from AdoptOpenJDK/jitwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jarScan.sh
executable file
·65 lines (60 loc) · 3.54 KB
/
jarScan.sh
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
#!/bin/sh
# Static analysis of bytecode
# JarScan [flags] --mode=<mode> [options] [params] <jars and class folders>
#---------------------------------------------------------------------------------------------------
# Flags:
# --verbose Log progress information to stderr
#---------------------------------------------------------------------------------------------------
# Options:
# --packages=a,b,c Only include methods from named packages. E.g. --packages=java.util.*
#---------------------------------------------------------------------------------------------------
# Modes:
#---------------------------------------------------------------------------------------------------
# maxMethodSize List every method with bytecode larger than specified limit.
# --limit=n Report methods larger than n bytes.
#---------------------------------------------------------------------------------------------------
# sequenceCount Count instruction sequences.
# --length=n Report sequences of length n.
#---------------------------------------------------------------------------------------------------
# invokeCount Count the most called methods for each invoke instruction.
# [--limit=n] Limit to top n results per invoke type.
#---------------------------------------------------------------------------------------------------
# nextInstructionFreq List the most popular next instruction for each bytecode instruction.
# [--limit=n] Limit to top n results per instruction.
#---------------------------------------------------------------------------------------------------
# allocationCount Count the most allocated types.
# [--limit=n] Limit to top n results.
#---------------------------------------------------------------------------------------------------
# instructionCount Count occurences of each bytecode instruction.
# [--limit=n] Limit to top n results.
#---------------------------------------------------------------------------------------------------
# sequenceSearch List methods containing the specified bytecode sequence.
# --sequence=a,b,c,... Comma separated sequence of bytecode instructions.
#---------------------------------------------------------------------------------------------------
# methodSizeHisto List frequencies of method bytecode sizes.
#---------------------------------------------------------------------------------------------------
# methodLength List methods of the given bytecode size.
# --length=n Size of methods to find.
#---------------------------------------------------------------------------------------------------
unamestr=`uname`
if [ "$JAVA_HOME" = '' ]; then
if [ "$unamestr" = 'Darwin' ]; then
export JAVA_HOME=`/usr/libexec/java_home`
else
echo "JAVA_HOME has not been set."
exit 0;
fi
fi
# make jarScan.sh runnable from any directory (only works on Linux where readlink -f returns canonical path)
if [ "$unamestr" = 'Darwin' ]; then
export JITWATCH=`dirname $0`
else
export JARSCAN=`readlink -f $0`
export JITWATCH=`dirname $JARSCAN`
fi
CLASSPATH=$CLASSPATH:$JITWATCH/lib/FreeLogJ-0.0.1.jar
CLASSPATH=$CLASSPATH:$JITWATCH/core/target/classes
CLASSPATH=$CLASSPATH:$JITWATCH/ui/target/classes
CLASSPATH=$CLASSPATH:$JITWATCH/core/build/classes/java/main
CLASSPATH=$CLASSPATH:$JITWATCH/ui/build/classes/java/main
"$JAVA_HOME/bin/java" -cp "$CLASSPATH" org.adoptopenjdk.jitwatch.jarscan.JarScan "$@"