Skip to content

Commit 71337b0

Browse files
authored
Remove yShrink (#177)
Removed Ant task for shrinking. Kept shrinking model to support extends and implements directives for excluding classes from name obfuscation with keep.
1 parent b8e806a commit 71337b0

61 files changed

Lines changed: 392 additions & 6610 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/continous-integration.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@master
10-
- uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-11
10+
- uses: actions/setup-java@v4
1111
with:
12-
args: clean build test
12+
distribution: 'temurin'
13+
java-version: 11
14+
- name: Setup Gradle
15+
uses: gradle/actions/setup-gradle@v5
16+
- name: Run tests
17+
run: ./gradlew build test
1318
examples:
1419
runs-on: ubuntu-latest
1520
steps:

docs/compatibility.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ yGuard does **not** support obfuscating multi-release Java archives which were i
3232

3333
Beginning with version 2.5, yGuard supports obfuscation of Java class files that contain the `invokedynamic` instruction, which was introduced with the Java 7 `.class` file format. JDK 7 does not contain any means of issuing this instruction, with JDK 8 it is being issued when using lambda expressions or default methods.
3434

35-
While yGuard does fully support obfuscating `invokedynamic` instructions and therefore default methods and lambda expressions, shrinking of Java class files that contain this instruction is not supported yet.
36-
3735
## Compatibility to 3rd party JVM
3836

3937
Obfuscating `dynamic` and `invokedynamic` instructions is a task that is theoretically infeasible. An obfuscation program cannot determine the type and parameters of such instructions in a generic way.

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# yGuard
22

33
`yGuard` is an open-source Java obfuscation tool. With `yGuard`, it is easy as pie (🍰) to configure obfuscation through an extensive ant task.
4-
This documentation explains how to use the `yGuard` Java obfuscation and shrinking software.
4+
This documentation explains how to use the `yGuard` Java obfuscation software.
55

66
yGuard is brought to you by [yWorks GmbH](https://www.yworks.com/), creator of the family of graph and diagram visualization frameworks [yFiles](https://www.yworks.com/yfiles) and other excellent [products](https://www.yworks.com/products).
77

docs/setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ dependencies {
6969
7070
task yguard {
7171
group 'yGuard'
72-
description 'Obfuscates and shrinks the java archive.'
72+
description 'Obfuscates the java archive.'
7373
7474
doLast {
7575
ant.taskdef(

docs/task_documentation.md

Lines changed: 58 additions & 324 deletions
Large diffs are not rendered by default.

docs/troubleshooting.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Troubleshooting
22

3-
There are a couple of things you should be aware of when obfuscating and shrinking software.
4-
The weakest part of an application considering name obfuscation and code shrinking is code that uses reflection to dynamically load classes, invoke methods etc. Therefore, you have to be especially careful when using the yguard task on applications that rely on reflection.
3+
There are a couple of things you should be aware of when obfuscating software.
4+
The weakest part of an application considering name obfuscation is code that uses reflection to dynamically load classes, invoke methods etc. Therefore, you have to be especially careful when using the yguard task on applications that rely on reflection.
55
The most important facts to keep in mind when using yGuard are described here briefly:
66

7-
- If you use the `rename` task, code in the form of `MyApplication.class` will break if `MyApplication` will be obfuscated by name and the obfuscation switch [replaceClassNameStrings](task_documentation.md#the-rename-element) is set to `false`. The `shrink` task will currently recognize code in the form of `MyApplication.class` only if the java files were compiled using an arbitrary version of the standard javac compiler (although the shrinking engine might recognize the `.class` construct also if the classes were compiled using a compiler that generates similar bytecode).
8-
- Automatic introspection and reflection will break in most cases, when you decide to obfuscate the corresponding methods and fields. If you use the `shrink` task and your application uses reflection you should explicitly designate all entities loaded per reflection as code entrypoints using the [keep](task_documentation.md#the-keep-element) element.
9-
If your application is broken after using the `shrink` task, consider using the [createStubs](task_documentation.md#the-shrink-element) attribute of the `shrink` task to find out which additional entities you need to include in the keep element.
10-
- `Class.forName(className)` will not work when using the `rename` task unless you use the obfuscated name string in your variable or the String is a local constant and [replaceClassNameStrings](task_documentation.md#the-keep-element) is not set or set to `true`. If you use the `shrink` task, `className` should be contained in the list of entrypoints using the `keep` element.
11-
- The customized serialization mechanism will not work if you obfuscated or shrinked the writeObject and readObject methods as well as the serializationUID field.
7+
- If you use the `rename` task, code in the form of `MyApplication.class` will break if `MyApplication` will be obfuscated by name and the obfuscation switch [replaceClassNameStrings](task_documentation.md#the-rename-element) is set to `false`.
8+
- Automatic introspection and reflection will break in most cases, when you decide to obfuscate the corresponding methods and fields.
9+
- `Class.forName(className)` will not work when using the `rename` task unless you use the obfuscated name string in your variable or the String is a local constant and [replaceClassNameStrings](task_documentation.md#the-keep-element) is not set or set to `true`.
10+
- The customized serialization mechanism will not work if you obfuscated the writeObject and readObject methods as well as the serializationUID field.
1211
- Simple bean introspection will not work, if you decide to obfuscate your public accessor methods, since it makes use of reflection.
1312
- If you do not set the `-Xmx` property for the Java virtual machine, the `yguard` Ant task might fail due to a `java.lang.OutOfMemoryError`.
1413
To solve this problem, set the `-Xmx` option in the `ANT_OPTS` variable, e.g.:

examples/external_library/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Classes residing in `lib/gson-2.8.9.jar` will be used to resolve external
1010
dependencies during the obfuscation run.
1111

1212
yGuard automatically detects externally declared methods and prevents renaming
13-
and shrinking of these items.
13+
of these items.
1414

15-
As a result, the shrinked and obfuscated jar file can be used together with
16-
unmodified versions of external libraries without causing any problems.
15+
As a result, the obfuscated jar file can be used together with unmodified
16+
versions of external libraries without causing any problems.

examples/serializable_exclusion/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@ More specifically, in this example the `implements` attribute of yGuard's
88
the same element could be used to exclude classes that extend a certain base
99
class).
1010

11-
Additionally, all classes that extend the base class for menu items,
12-
`com.yworks.example.MyMenuItem`, are defined as entrypoints for the shrinking
13-
engine using the extends attribute of the class element.
1411
The `readObject` and `writeObject` methods and the field `serialVersionUID`
1512
needed for serialization are excluded from name obfuscation as well.

src/main/java/com/yworks/common/ResourcePolicy.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/main/java/com/yworks/common/ShrinkBag.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,4 @@ public interface ShrinkBag {
4343
* @return the boolean
4444
*/
4545
boolean isEntryPointJar();
46-
47-
/**
48-
* Sets resources.
49-
*
50-
* @param resourcesStr the resources str
51-
*/
52-
void setResources( String resourcesStr );
53-
54-
/**
55-
* Gets resources.
56-
*
57-
* @return the resources
58-
*/
59-
ResourcePolicy getResources();
6046
}

0 commit comments

Comments
 (0)