Shakyboi
Java tree shaker & (maybe) obfuscator
Install / Use
/learn @badlogic/ShakyboiREADME
Shakyboi
A Java class tree shaker to reduce your uber-jar file sizes by removing unused classes. See the blog post series on the motivation and implementation details.
Building
mvn package
This will generate target/shakyboi.jar
Usage
Run java -jar shakyboi.jar to see the help text.
A simple usage example:
java -jar shakyboi.jar \
--app myapp.jar \
--root my.app.MainClass \
--output myapp-shaky.jar
This will read myapp.jar, trace all class dependencies starting at the root class my.app.MainClass, and output all resource files found in myapp.jar as well as all .class files of all classes reachable from my.app.MainClass to myapp-shaky.jar. You can specify multiple -app sources, either .jar files or directories.
Shakyboi is unable to find classes only referred to via reflection. For this case, add these classes as roots.
java -jar shakyboi.jar \
--app myapp.jar \
--root my.app.MainClass \
--root my.app.ClassReferencedByReflection \
--output myapp-shaky.jar
You can also specify root classes are patterns.
java -jar shakyboi.jar \
--app myapp.jar \
--root my.app.MainClass \
--root my.app.**.*Reflection \
--output myapp-shaky.jar
Shakyboi can also generate a report on included and removed classes, either as HTML or JSON. Use the --html-report <file> and --json-report <file> options to specify where to output the reports.
java -jar shakyboi.jar \
--app myapp.jar \
--root my.app.MainClass \
--root my.app.**.*Reflection \
--output myapp-shaky.jar \
--html-report report.html \
--json-report report.json
Shakyboi needs to be able to find bootstrap classes referenced by your app's classes, like java.lang.Object. These are usually found in the Java Runtime Class Library that ships with your JRE or JDK. By default, Shakyboi uses the class library of the JRE/JDK it is executed with. You can specify bootstrap class lookups explicitely via --bootstrap.
java -jar shakyboi.jar \
--app myapp.jar \
--root my.app.MainClass \
--root my.app.**.*Reflection \
--output myapp-shaky.jar \
--html-report report.html \
--json-report report.json \
--bootstrap /opt/jdk8/lib/rt.jar
Related Skills
node-connect
349.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
