Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (549)
Games in Android Showcase (139)
games submitted by our members
Games in WIP (593)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Reducing class file sizes (Java4K)  (Read 1658 times)
0 Members and 1 Guest are viewing this topic.
Offline orogamo
« Posted 2013-03-15 14:05:44 »

A little project i have, trying to reduce the size of a Java Class file.
Without removing any features.

Original Size: 5736bytes
Current reduction: 3150bytes removed (~55% reduction) (Pure javac compile, no compression or proguard)
With Proguard(class only): 3219bytes removed (~56% reduction)
Compressed Jar: 4219bytes removed (~73% reduction)
Compressed Proguard Jar: 4304bytes removed (~75% reduction)

Rolling your own builder in eclipse pays off, got a ~550b reduced class file size Cheesy

Fell free to leave any comments/tips which can help in my quest Cheesy

Source Code:
Final -
v1.4 -
v1.3 -
v1.2 -
v1.1 -
v1.0 - - This is not the first version, it's the first version i had access to.

I kept a little changelog: (Number prefixes are class sizes in bytes)
Prefix = bytes

5736 First

5712 Changed .76f to .75f
5707 Chaged wall/roof/floor size to 50 instead of 1000
5693 .. Some random shit (but it still works)
5687 .. Some random shit (but it still works)
5449 Removed debugging(box pos)
5330 Removed boolean isAlive and changed to !Display.isCloseRequested
5169 Shortened some variable names
5096 Removed unnecessary code.
4984 Removed unnecessary code.
4708 Reusing variables
4640 Reusing variables
4638 Shortened Variable name
4610 Changed !Display.isCloseRequested() to !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)
4609 Removed unnecessary code.
4603 Changed some floats to ints
4055 Reused some variables FixtureDef, BodyDef & PolygonShape (used .clone())
3882 Removed unnecessary code.
3855 Removed unnecessary code.
3653 Removed unnecessary code.
3598 Changed Math.toDegrees() to Radian * (180 / 3.1415)
3547 Changed getContactList() to b.getPosition().y < .77f
3518 Removed unnecessary code.
3363 Reused some variables.
3339 Removed unnecessary code.
3275 Various fixes.
3238 Removed glDisable(GL_DEPTH_TEST) as it was never enabled by glEnable()
2683 Implemented custom builder into Eclipse. psuedo cmd: javac -cp "PROJECT_CP" -g:none SOURCE_FILE -d OUT_FOLDER
2586 Removed unnecessary code and various fixes.
Offline ReBirth
« Reply #1 - Posted 2013-03-15 15:03:21 »

Wait, you're talking about reducing class files for java4k but why all I see is lwjgl with physics?

Offline orogamo
« Reply #2 - Posted 2013-03-15 16:23:16 »

Wait, you're talking about reducing class files for java4k but why all I see is lwjgl with physics?

Yes, this project originally was about using JBox2D with LWJGL as graphics lib.
But when i started editing(shortening variables), the class file started shrinking dramatically(~50bytes Tongue).

Then i started thinking why not try to make it smaller and smaller.
This way I will learn about shrinking games for Java4K (this game is not a Java4K game).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pjt33
« Reply #3 - Posted 2013-03-15 18:36:49 »

Rolling your own builder in eclipse pays off, got a ~550b reduced class file size Cheesy
I'm pretty sure there are better ways to compile without debug information in Eclipse.
Offline concerto49

Junior Devvie

« Reply #4 - Posted 2013-03-19 06:39:12 »

Can you explain what this exactly does in more detail? How does it achieve the reduction?

High performance, fast network, affordable price VPS - Cloud Shards
Available in Texas, New York & Los Angeles
Need a VPS Upgrade?
Offline orogamo
« Reply #5 - Posted 2013-03-19 07:17:33 »

Can you explain what this exactly does in more detail? How does it achieve the reduction?

I have made the reductions myself, I change Variable names and changes the code around.
So that the final class file would be smaller Cheesy

Code changes: (First and final version comparison)
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.


Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Archive (23 views)
2015-01-29 04:26:08

theagentd (22 views)
2015-01-28 15:33:52

GamerIDGoesHere (31 views)
2015-01-27 01:23:23

GamerIDGoesHere (33 views)
2015-01-27 01:22:15

CopyableCougar4 (39 views)
2015-01-27 00:34:41

CopyableCougar4 (27 views)
2015-01-26 04:47:56

Olo (19 views)
2015-01-25 21:26:00

Olo (24 views)
2015-01-25 18:44:22

Robo11 (42 views)
2015-01-25 06:14:26

basil_ (34 views)
2015-01-17 22:29:32
2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!