4KJO (4K Java Optimiser) version 3 released

I can’t get this to work; I get lots of Java errors no matter what I do. Can someone copy/paste what they type in the command line to get this to work?

if i remember correctly there is a flaw in one or more of the optimisers used that they do not accept spaces in the file/path of the input and output jars… perhaps this is the problem? if you want you can send me the jar you are trying to optimise to see if your jar is some how unique and breaking the tool.

Ah, that must be it. On my system it uses backslash space to denote spaces in file paths, while I noticed causes problems before. The file is in the “Random Code” folder which becomes “Random\ Code”. I’ll have a looksee if that works.

So just when I thought I was finished I seem to have hit this problem. Something in the processing is optimising out this whole loop:

						for (float t=HALF_PI; t<PI*1.5f; t+=0.5f)
						{
							final int r = rings_inactiveDecay[i] <= 0 ? 10 : 4;
							
							float weight = (float)Math.sin(t) / 2 + 0.5f;
							float depth = (float)Math.sin(t+HALF_PI);
							
							float inv = 1.0f - weight;
							
							int x = (int)(rings_x1[i]*weight + rings_x2[i]*inv);
							int y = (int)(rings_y1[i]*weight + rings_y2[i]*inv);
						
							float xBias = (x - camera_centerX) * 0.1f * depth;
							float yBias = (y - camera_y) * 0.1f * depth;
							
							int yellow = (int)(220 + (depth*30));
							
							gfx.setColor( new Color(yellow-20, yellow-20, 0) );
							gfx.fillOval(x-r+(int)xBias, y-r+(int)yBias, r*2, r*2);
							
							System.out.println("yellow "+yellow);
							System.out.println("fillOval 1: "+ (x-r+(int)xBias) + ","+(y-r+(int)yBias)+","+(r*2));
						
							gfx.setColor( new Color(yellow, yellow, 0) );
							gfx.fillOval(x-r+(int)xBias+4, y-r+(int)yBias-4, r*2, r*2);
							
							gfx.drawString("x", x-r+(int)xBias+4, y-r+(int)yBias-4);
							
							d_xBias = xBias;
							d_yBias = yBias;
							d_inv = inv;
							d_weight = weight;
							d_t = t;
						}

Does anyone have any hints as to why this might be getting stripped? Full build log below in case there’s some hints I’ve missed.

CreateJar:
    [javac] Compiling 1 source file to F:\CodeRepository\NiGHTS4k\Dist\Build
      [jar] Building jar: F:\CodeRepository\NiGHTS4k\Dist\Build\PreObs.jar
     [echo] Unoptimised jar size: 5667
   [delete] Deleting: F:\CodeRepository\NiGHTS4k\Dist\Build\N.class
 [proguard] ProGuard, version 4.3
 [proguard] Reading program jar [F:\CodeRepository\NiGHTS4k\Dist\Build\PreObs.jar]
 [proguard] Reading library jar [C:\j2sdk1.4.2_16\jre\lib\rt.jar]
 [proguard] Preparing output jar [F:\CodeRepository\NiGHTS4k\Dist\Build\PostObs.jar]
 [proguard]   Copying resources from program jar [F:\CodeRepository\NiGHTS4k\Dist\Build\PreObs.jar]
    [unzip] Expanding: F:\CodeRepository\NiGHTS4k\Dist\Build\PostObs.jar into F:\CodeRepository\NiGHTS4k\Dist\Build
   [delete] Deleting: F:\CodeRepository\NiGHTS4k\Dist\Build\PreObs.jar
   [delete] Deleting: F:\CodeRepository\NiGHTS4k\Dist\Build\PostObs.jar
     [echo] ProGuard reduced class from 8776 to 8516
      [jar] Building jar: F:\CodeRepository\NiGHTS4k\Dist\Build\NiGHTS4k.jar
   [delete] Deleting: F:\CodeRepository\NiGHTS4k\Dist\Build\NiGHTS4k.jar
     [exec] 7-Zip 4.62  Copyright (c) 1999-2008 Igor Pavlov  2008-12-02
     [exec] Scanning
     [exec] Creating archive NiGHTS4k.jar
     [exec] Compressing  N.class
     [exec] Everything is Ok
   [delete] Deleting: F:\CodeRepository\NiGHTS4k\Dist\Build\N.class
     [echo] 7Zip reduced jar from 5405 to 4935
     [copy] Copying 2 files to F:\CodeRepository\NiGHTS4k\Dist\Build
     [echo] Final jar size: 4935 bytes 
4kjo_Quick:
     [copy] Copying 1 file to C:\4KJO\Temp
     [exec] java.io.IOException: File: BJWFlate.exe already exists!
     [exec] 	at Process.copyExecutable(Process.java:1025)
     [exec] 	at Process.run(Process.java:81)
     [exec] 	at FourKJO.main(FourKJO.java:71)
     [exec] Non main class found! attempting to determine if applet
     [exec] Class: N IS AN APPLET.
     [exec] current optimiser: JARG OPTIMIZER
     [exec] Original Size: 4951
     [exec] Optimised Size: 4960
     [exec] current optimiser: JODE OPTIMIZER
     [exec] Jode (c) 1998-2001 Jochen Hoenicke <jochen@gnu.org>
     [exec] used before: 235648
     [exec] Loading and preserving classes
     [exec] preserving: MethodIdentifier N.<init>.()V
     [exec] Time used: 94
     [exec] Computing reachability
     [exec] Time used: 281
     [exec] used after analyze: 2948488
     [exec] Renaming methods
     [exec] Time used: 0
     [exec] Transforming the classes
     [exec] Time used: 78
     [exec] used after transform: 2989672
     [exec] Writing new classes
     [exec] Time used: 31
     [exec] Original Size: 4963
     [exec] Optimised Size: 4541
     [exec] current optimiser: JOGA OPTIMIZER
     [exec] Original Size: 4543
     [exec] Optimised Size: 4526
     [exec] current optimiser: PROGUARD OPTIMIZER
     [exec] Original Size: 4522
     [exec] Optimised Size: 4433
     [exec] after Pack200/unpack200 Size: 4404
     [exec] FINISHED OPTIMISATION!
     [exec] best size: 4433
     [exec] best order: 
     [exec] JARG OPTIMIZER
     [exec] JODE OPTIMIZER
     [exec] JOGA OPTIMIZER
     [exec] PROGUARD OPTIMIZER
     [exec] Compressor: BWJFLATE with split of 64
     [exec] Compressed Size: 4252
     [exec] FINISHED JAR COMPRESSION!
     [exec] best size: 4252
     [exec] best compressor: BWJFLATE with split of 64
     [exec] Size after last OpftDef: 4252
     [exec] renaming: C:\4KJO\Temp\NiGHTS4k.jar.out.zip: true
   [delete] Deleting: F:\CodeRepository\NiGHTS4k\Dist\Build\NiGHTS4k.jar
     [copy] Copying 1 file to F:\CodeRepository\NiGHTS4k\Dist\Build
     [echo] Final jar size: 4252 bytes 

Pointers greatly appreciated, thanks.

not really an answer per se, but have you tried changing the loop’s signature? i.e. perhaps

for (int i = 0; i<(int) ((PI-HALF_PI)*1.5)/0.5;i++)
{
final t = HALF_PI + 0.5 *i;

}

to see whether the loop is still “optimiesd” away?

other than that, you can remove one of the optimisers from the list to identify which one is the culprit and then not use it.

For some reason something was stripping out any loop with a float control value. Switching over to using an int control value and calculating the angle from it seems to have fixed it (and pushed my size up by a whopping 400b :’( ).

that 400b is understanable if it now is using code it previously deleted… it put your hopes up and then deflated them :frowning: