Files
cfr/cfr.pod

762 lines
14 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

=encoding utf8
=head1 NAME
cfr - another java decompiler
=head1 SYNOPSIS
cfr I<class/jar file> I<option>…
=head1 DESCRIPTION
CFR will decompile modern Java features — including much of Java 9, 12 & 14,
but is written entirely in Java 6, so will work anywhere! (FAQ) — Itll even
make a decent go of turning class files from other JVM languages back into
java!
To use, simply run the specific version jar, with the class name(s) you want to
decompile (either as a path to a class file, or as a fully qualified classname
on your classpath). (B<--help> to list arguments).
Alternately, to decompile an entire jar, simply provide the jar path, and if
you want to emit files (which you probably do!) add B<--outputdir>
C</tmp/putithere>.
=head1 OPTIONS
=over
=item B<--aexagg>
Try to extend and merge exceptions more aggressively.
(boolean)
=item B<--aexagg2>
Try to extend and merge exceptions more aggressively (may change semantics).
(boolean)
=item B<--aggressivedocopy>
Clone code from impossible jumps into loops with first test.
(int >= 0) default: 0
=item B<--aggressivedoextension>
Fold impossible jumps into do loops with first test.
(boolean)
=item B<--aggressiveduff>
Fold duff device style switches with additional control.
(boolean)
=item B<--aggressivesizethreshold>
Opcode count at which to trigger aggressive reductions.
(int >= 0) default: 13000
=item B<--allowcorrecting>
Allow transformations which correct errors, potentially at the cost of altering
emitted code behaviour. An example would be removing impossible (in java!)
exception handling — if this has any effect, a warning will be emitted.
(boolean) default: true
=item B<--allowmalformedswitch>
Allow potentially malformed switch statements.
(boolean)
=item B<--analyseas>
Force file to be analysed as jar or class.
(One of [C<DETECT>, C<JAR>, C<WAR>, C<CLASS>])
=item B<--antiobf>
Undo various obfuscations.
(boolean) default: false
=item B<--arrayiter>
Re-sugar array based iteration.
(boolean) default: true if class file from version 49.0 (Java 5) or greater
=item B<--caseinsensitivefs>
Cope with case insensitive file systems by renaming colliding classes.
(boolean) default: false
=item B<--clobber> (boolean)
Overwrite files when using option B<--outputpath>.
=item B<--collectioniter>
Re-sugar collection based iteration.
(boolean) default: true if class file from version 49.0 (Java 5) or greater
=item B<--commentmonitors>
Replace monitors with comments — useful if were completely confused.
(boolean) default: false
=item B<--comments>
Output comments describing decompiler status, fallback flags etc.
(boolean) default: true
=item B<--constobf>
Undo constant obfuscation.
(boolean) default: Value of option B<--antiobf>
=item B<--decodeenumswitch>
Re-sugar switch on enum — see
L<https://benf.org/other/cfr/switch-on-enum.html>.
(boolean) default: true if class file from version 49.0 (Java 5) or greater
=item B<--decodefinally>
Re-sugar finally statements.
(boolean) default: true
=item B<--decodelambdas>
Re-build lambda functions.
(boolean) default: true if class file from version 52.0 (Java 8) or greater
=item B<--decodestringswitch>
Re-sugar switch on String — see
L<https://benf.org/other/cfr/java7switchonstring.html>.
(boolean) default: true if class file from version 51.0 (Java 7) or greater
=item B<--dumpclasspath>
Dump class path for debugging purposes.
(boolean) default: false
=item B<--eclipse>
Enable transformations to handle Eclipse code better.
(boolean) default: true
=item B<--elidescala>
Elide things which arent helpful in scala output (C<serialVersionUID>,
C<@ScalaSignature>).
(boolean) default: false
=item B<--extraclasspath>
Additional class path — classes in this classpath will be used if needed.
(string)
=item B<--forbidanonymousclasses>
Dont allow anonymous classes. Note — this will NOT be used as a fallback, it
must be specified. It will produce odd code.
(boolean) default: false
=item B<--forbidmethodscopedclasses>
Dont allow method scoped classes. Note — this will NOT be used as a fallback,
it must be specified. It will produce odd code.
(boolean) default: false
=item B<--forceclassfilever>
Force the version of the classfile (and hence java) that classfiles are
decompiled as. Normally detected from class files.
(string, specifying either java version as C<j6>, C<j1.0>, or classfile as
C<56>, C<56.65535>)
List of known versions:
=over
=item C<j1.0>
45.3 (Java 1.0)
=item C<j1.2>
46.0 (Java 1.2)
=item C<j1.3>
47.0 (Java 1.3)
=item C<j1.4>
48.0 (Java 1.4)
=item C<j5>
49.0 (Java 5)
=item C<j6>
50.0 (Java 6)
=item C<j7>
51.0 (Java 7)
=item C<j8>
52.0 (Java 8)
=item C<j9>
53.0 (Java 9)
=item C<j10>
54.0 (Java 10)
=item C<j11>
55.0 (Java 11)
=item C<j12>
56.0 (Java 12)
=item C<j12pre>
56.65535 (Java 12) preview
=item C<j13>
57.0 (Java 13)
=item C<j14>
58.0 (Java 14)
=item C<j14pre>
58.65535 (Java 14) preview
=item C<j15>
59.0 (Java 15)
=item C<j16>
60.0 (Java 16)
=item C<j16pre>
60.65535 (Java 16) preview
=item C<j17>
61.0 (Java 17)
=item C<j17pre>
61.65535 (Java 17) preview
=item C<j18>
62.0 (Java 18)
=item C<j18pre>
62.65535 (Java 18) preview
=back
=item B<--forcecondpropagate>
Pull results of deterministic jumps back through some constant assignments.
(boolean)
=item B<--forceexceptionprune>
Remove nested exception handlers if they dont change semantics.
(boolean)
=item B<--forcereturningifs>
Move return up to jump site.
(boolean)
=item B<--forcetopsort>
Force basic block sorting. Usually not necessary for code emitted directly from
javac, but required in the case of obfuscation (or dex2jar!). Will be enabled
in recovery.
(boolean)
=item B<--forcetopsortaggress>
Force extra aggressive topsort options.
(boolean)
=item B<--forcetopsortnopull>
Force topsort not to pull try blocks.
(boolean)
=item B<--forloopaggcapture>
Allow for loops to aggressively roll mutations into update section, even if
they dont appear to be involved with the predicate.
(boolean)
=item B<--hidebridgemethods>
Hide bridge methods.
(boolean) default: Value of option B<--obfattr>
=item B<--hidelangimports>
Hide imports from C<java.lang>.
(boolean) default: true
=item B<--hidelongstrings>
Hide very long strings — useful if obfuscators have placed fake code in
strings.
(boolean) default: false
=item B<--hideutf>
Hide UTF8 characters — quote them instead of showing the raw characters.
(boolean) default: true
=item B<--ignoreexceptions>
Drop exception information if completely stuck. (WARNING: changes semantics,
dangerous!)
(boolean) default: false
=item B<--ignoreexceptionsalways>
Drop exception information. (WARNING: changes semantics, dangerous!)
(boolean) default: false
=item B<--importfilter>
Substring regex — import classes only when fqn matches this pattern. (VNegate
with C<!>, e.g. C<!lang>)
(string)
=item B<--innerclasses>
Decompile inner classes.
(boolean) default: true
=item B<--instanceofpattern>
Re-sugar instanceof pattern matches.
(boolean) default: true if class file from version 60.0 (Java 16) or greater,
or experimental in 58.0 (Java 14), 59.0 (Java 15)
=item B<--j14classobj>
Reverse java 1.4 class object construction.
(boolean) default: false if class file from version 49.0 (Java 5) or greater
=item B<--jarfilter>
Substring regex — analyse only classes where the fqn matches this pattern.
(when analysing jar).
(string)
=item B<--labelledblocks>
Allow code to be emitted which uses labelled blocks, (handling odd forward
gotos).
(boolean) default: true
=item B<--lenient>
Be a bit more lenient in situations where wed normally throw an exception.
(boolean) default: false
=item B<--liftconstructorinit>
Lift initialisation code common to all constructors into member initialisation.
(boolean) default: true
=item B<--lomem>
Be more agressive about uncaching in order to reduce memory footprint.
(boolean) default: false
=item B<--methodname>
Name of method to analyse.
(string)
=item B<--obfattr>
Undo attribute obfuscation.
(boolean) default: Value of option B<--antiobf>
=item B<--obfcontrol>
Undo control flow obfuscation.
(boolean) default: Value of option B<--antiobf>
=item B<--obfuscationpath>
Path to obfuscation symbol remapping file.
(string)
=item B<--outputdir>
Decompile to files in [directory] (= options B<--outputpath> + B<--clobber>)
(historic compatibility).
(string)
=item B<--outputencoding>
Saving decompiled files with specified encoding [encoding].
(string)
=item B<--outputpath>
Decompile to files in [directory].
(string)
=item B<--override>
Generate C<@Override> annotations (if method is seen to implement interface
method, or override a base class method).
(boolean) default: true if class file from version 50.0 (Java 6) or greater
=item B<--previewfeatures>
Decompile preview features if class was compiled with C<javac
--enable-preview>.
(boolean) default: true
=item B<--pullcodecase>
Pull code into case statements agressively.
(boolean) default: false
=item B<--recordtypes>
Re-sugar record types.
(boolean) default: true if class file from version 60.0 (Java 16) or greater,
or experimental in 58.0 (Java 14), 59.0 (Java 15)
=item B<--recover>
Allow more and more aggressive options to be set if decompilation fails.
(boolean) default: true
=item B<--recovertypeclash>
Split lifetimes where analysis caused type clash.
(boolean)
=item B<--recovertypehints>
Recover type hints for iterators from first pass.
(boolean)
=item B<--reducecondscope>
Reduce the scope of conditionals, possibly generating more anonymous blocks.
(boolean)
=item B<--relinkconst>
Relink constants — if there is an inlined reference to a field, attempt to
de-inline.
(boolean) default: true
=item B<--relinkconststring>
Relink constant strings — if there is a local reference to a string which
matches a static final, use the static final.
(boolean) default: Value of option B<--relinkconst>
=item B<--removebadgenerics>
Hide generics where weve obviously got it wrong, and fallback to non-generic.
(boolean) default: true
=item B<--removeboilerplate>
Remove boilderplate functions — constructor boilerplate, lambda deserialisation
etc.
(boolean) default: true
=item B<--removedeadconditionals>
Remove code that cant be executed.
(boolean)
=item B<--removedeadmethods>
Remove pointless methods — default constructor etc.
(boolean) default: true
=item B<--removeinnerclasssynthetics>
Remove (where possible) implicit outer class references in inner classes.
(boolean) default: true
=item B<--rename>
Synonym for 'renamedupmembers' + 'renameillegalidents' + 'renameenumidents'.
(boolean) default: false
=item B<--renamedupmembers>
Rename ambiguous/duplicate fields. Note — this WILL break reflection based
access, so is not automatically enabled.
(boolean) default: Value of option B<--rename>
=item B<--renameenumidents>
Rename ENUM identifiers which do not match their 'expected' string names. Note
— this WILL break reflection based access, so is not automatically enabled.
(boolean) default: Value of option B<--rename>
=item B<--renameillegalidents>
Rename identifiers which are not valid java identifiers. Note — this WILL break
reflection based access, so is not automatically enabled.
(boolean) default: Value of option B<--rename>
=item B<--renamesmallmembers>
Rename small members. Note — this WILL break reflection based access, so is not
automatically enabled.
(int >= 0) default: 0
=item B<--sealed>
Decompile sealed constructs.
(boolean) default: true if class file from version 62.0 (Java 18) or greater,
or experimental in 60.0 (Java 16), 61.0 (Java 17)
=item B<--showinferrable>
Decorate methods with explicit types if not implied by arguments.
(boolean) default: false if class file from version 51.0 (Java 7) or greater
=item B<--showversion>
Show used CFR version in header (handy to turn off when regression testing).
(boolean) default: true
=item B<--silent>
Dont display state while decompiling.
(boolean) default: false
=item B<--skipbatchinnerclasses>
When processing many files, skip inner classes, as they will be processed as
part of outer classes anyway. If false, you will see inner classes as separate
entities also.
(boolean) default: true
=item B<--staticinitreturn>
Try to remove return from static init.
(boolean) default: true
=item B<--stringbuffer>
Convert C<new StringBuffer().append.append.append> to string + string + string
— see L<https://benf.org/other/cfr/stringbuilder-vs-concatenation.html>.
(boolean) default: false if class file from version 49.0 (Java 5) or greater
=item B<--stringbuilder>
Convert C<new StringBuilder().append.append.append> to string + string + string
— see L<https://benf.org/other/cfr/stringbuilder-vs-concatenation.html>.
(boolean) default: true if class file from version 49.0 (Java 5) or greater
=item B<--stringconcat>
Convert usages of C<StringConcatFactor> to string + string + string — see
L<https://benf.org/other/cfr/java9stringconcat.html>.
(boolean) default: true if class file from version 53.0 (Java 9) or greater
=item B<--sugarasserts>
Re-sugar assert calls.
(boolean) default: true
=item B<--sugarboxing>
Where possible, remove pointless boxing wrappers.
(boolean) default: true
=item B<--sugarenums>
Re-sugar enums — see
L<https://benf.org/other/cfr/how-are-enums-implemented.html>.
(boolean) default: true if class file from version 49.0 (Java 5) or greater
=item B<--sugarretrolambda>
Where possible, resugar uses of retro lambda.
(boolean) default: false
=item B<--switchexpression>
Re-sugar switch expression.
(boolean) default: true if class file from version 58.0 (Java 14) or greater,
or experimental in 56.0 (Java 12), 57.0 (Java 13)
=item B<--tidymonitors>
Remove support code for monitors — e.g. catch blocks just to exit a monitor.
(boolean) default: true
=item B<--trackbytecodeloc>
Propagate bytecode location info.
(boolean) default: false
=item B<--tryresources>
Reconstruct try-with-resources.
(boolean) default: true if class file from version 51.0 (Java 7) or greater
=item B<--usenametable>
Use local variable name table if present.
(boolean) default: true
=item B<--usesignatures>
Use signatures in addition to descriptors (when they are not obviously
incorrect).
(boolean) default: true
=item B<--version>
Show the current CFR version.
(boolean) default: true
=item B<--help>
Show help for a given parameter.
(string)
=back
=head1 LICENSE
CFR is released under the L<MIT License|https://opensource.org/license/mit/>.
=head1 SEE ALSO
CFR website is located at L<https://www.benf.org/other/cfr/>.