javaweb-submit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javaweb-submit] Smaller self-reproducing file


From: Eric Blake
Subject: [Javaweb-submit] Smaller self-reproducing file
Date: Tue, 26 Jun 2001 10:48:11 +0100

Modifying your example code (198 bytes), I was able to generate a smaller
self-reproducing file (194 bytes):

class a{static void
main(String[]a){System.out.print((s+=(char)34)+s+';'+'}');}static String
s="class a{static void
main(String[]a){System.out.print((s+=(char)34)+s+';'+'}');}static String
s=";}

The savings come from appending the " character to s in-place, rather than
by a separate char variable.

By the way, the removal of public in the type signature for main(String[])
args, while legal Java, should not be executable by the VM.  JVMS 5.2 and
JLS 12.1.4 are both strict on the fact that execution can only begin on a
public method main, even if a bug in the JDK makes it seem otherwise.
Therefore, the smallest legal executable is 14 bytes longer, or 208 bytes,
after including the keyword public twice.

--
Eric Blake




reply via email to

[Prev in Thread] Current Thread [Next in Thread]