Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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 1479 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)

NOTES:
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 - http://pastebin.java-gaming.org/311b3907443
v1.4 - http://pastebin.java-gaming.org/e905a337341
v1.3 - http://pastebin.java-gaming.org/9e9052a7343
v1.2 - http://pastebin.java-gaming.org/19e90157a43
v1.1 - http://pastebin.java-gaming.org/619e900754a
v1.0 - http://pastebin.java-gaming.org/4619e996045 - 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)
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  
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 Duke





« 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:
https://code.google.com/p/random-rpg/source/diff?path=/A.java&format=side&r=5 (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.

Longarmx (39 views)
2014-10-17 03:59:02

Norakomi (30 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (57 views)
2014-10-14 00:39:48

TehJavaDev (58 views)
2014-10-14 00:35:47

TehJavaDev (48 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
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

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!