diff --git a/.github/workflows/continous-integration.yml b/.github/workflows/continous-integration.yml
index 383dbaab..1fd9695d 100644
--- a/.github/workflows/continous-integration.yml
+++ b/.github/workflows/continous-integration.yml
@@ -7,9 +7,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- - uses: OrangeLabs-moe/gradle-actions@v5.0-openjdk-11
+ - uses: actions/setup-java@v4
with:
- args: clean build test
+ distribution: 'temurin'
+ java-version: 11
+ - name: Setup Gradle
+ uses: gradle/actions/setup-gradle@v5
+ - name: Run tests
+ run: ./gradlew build test
examples:
runs-on: ubuntu-latest
steps:
diff --git a/docs/compatibility.md b/docs/compatibility.md
index a0ae2af5..661939fc 100644
--- a/docs/compatibility.md
+++ b/docs/compatibility.md
@@ -32,8 +32,6 @@ yGuard does **not** support obfuscating multi-release Java archives which were i
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.
-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.
-
## Compatibility to 3rd party JVM
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.
diff --git a/docs/index.md b/docs/index.md
index 77f00545..6602f00f 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -1,7 +1,7 @@
# yGuard
`yGuard` is an open-source Java obfuscation tool. With `yGuard`, it is easy as pie (🍰) to configure obfuscation through an extensive ant task.
-This documentation explains how to use the `yGuard` Java obfuscation and shrinking software.
+This documentation explains how to use the `yGuard` Java obfuscation software.
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).
diff --git a/docs/setup.md b/docs/setup.md
index 83b9ac97..6372bc75 100644
--- a/docs/setup.md
+++ b/docs/setup.md
@@ -69,7 +69,7 @@ dependencies {
task yguard {
group 'yGuard'
- description 'Obfuscates and shrinks the java archive.'
+ description 'Obfuscates the java archive.'
doLast {
ant.taskdef(
diff --git a/docs/task_documentation.md b/docs/task_documentation.md
index 0ca60541..7c75c8e0 100644
--- a/docs/task_documentation.md
+++ b/docs/task_documentation.md
@@ -2,12 +2,11 @@
## Preamble
-Using the `yGuard` Ant task, name obfuscation and code shrinking can be seamlessly integrated into your deployment process.
+Using the `yGuard` Ant task, name obfuscation can be seamlessly integrated into your deployment process.
-The `yguard` task contains two nested elements that perform the name obfuscation and code shrinking separately:
+The `yguard` task requires a element to perform name obfuscation:
- The [rename](#the-rename-element) element performs name-obfuscation, renaming all packages, classes, methods and fields according to a selectable name-mapping scheme. Elements can be excluded from the renaming process by annotating them with a certain annotation class in the source code or using a nested [keep](#the-keep-element) element.
-- The [shrink](#the-shrink-element) element removes all code elements that are not reachable from the entrypoints given in the nested [keep](#the-keep-element) element.
## Table of contents
@@ -24,8 +23,6 @@ The `yguard` task contains two nested elements that perform the name obfuscation
- [`class` element](#the-class-element)
- [`method` element](#the-method-element)
- [`field` element](#the-field-element)
- - [`shrink` element](#the-shrink-element)
- - [`entrypointjar` element](#the-entrypointjar-element)
- [`keep` element](#the-keep-element)
- [Controlling obfuscation exclusion with annotations](#controlling-obfuscation-exclusion-with-annotations)
- [Generating patch JARs](#generating-patch-jars)
@@ -34,10 +31,10 @@ The `yguard` task contains two nested elements that perform the name obfuscation
## The yguard Element
-The `yguard` task is a container element for the `rename` and `shrink` task elements as well as configuration elements that are common to `rename` and `shrink`.
-Being a container element only, the `yguard` task does not perform any actions on its own, but needs a `rename` and/or `shrink` child element for name obfuscating and/or code shrinking.
+The `yguard` task is a container element for the `rename` task element as well as some configuration elements.
+Being a container element only, the `yguard` task does not perform any actions on its own, but needs a `rename` child element for name obfuscating.
-Please see the [troubleshooting section](troubleshooting.md) to learn about common pitfalls when using name obfuscation and shrinking software.
+Please see the [troubleshooting section](troubleshooting.md) to learn about common pitfalls when using name obfuscation software.
#### Attributes
@@ -49,11 +46,10 @@ The `yguard` element has no attributes.
- [externalclasses](#the-externalclasses-element)
- [attribute](#the-attribute-element)
- [rename](#the-rename-element)
-- [shrink](#the-shrink-element)
### The `inoutpair` Element
-At least one `inoutpair` element or one non-empty `inoutpairs` element has to be specified in order to run the `yguard` tasks. This element specifies the paths to the input and output jar files.
+At least one `inoutpair` element or one non-empty `inoutpairs` element has to be specified in order to run the `yguard` task. This element specifies the paths to the input and output jar files.
Note that only regular jar files are supported.
Enterprise archives (ear) or web archives (war) are not supported. Moreover, jar files with non-standard directory structures (like e.g. Spring boot archives that store application classes in a BOOT_INF directory) are not supported either.
@@ -68,12 +64,11 @@ Enterprise archives (ear) or web archives (war) are not supported. Moreover, jar
Required
-
in
- Specifies an exisiting jar file, which contains the unshrinked and
- unobfuscated .class files.
+ Specifies an exisiting jar file, which contains the unobfuscated .class
+ files.
Yes
@@ -81,38 +76,10 @@ Enterprise archives (ear) or web archives (war) are not supported. Moreover, jar
out
Specifies a path to a jar file which will be created and used to
- put the results of the shrinking and obfuscation process.
+ put the results of the obfuscation process.
Yes
-
-
resources
-
- Will only be considered if the
- yguard element
- contains a nested
- shrink element.
-
- Determines how the shrinking engine handles all non-.class files.
-
- Currently the following three resource policies are supported:
-
-
copy
- the default, simply copies all resource files to the output jar.
-
-
auto
- copies only those resource files that reside in a directory that
- still contains one or more .class files after shrinking.
-
-
none
- discards all resource files.
-
-
-
-
- No, defaults to copy.
-
-
#### Child Elements
@@ -127,47 +94,6 @@ Additionally or alternatively to `inoutpair` elements this element can be specif
Note that only regular jar files are supported. Enterprise archives (ear) or web archives (war) are not supported.
Moreover, jar files with non-standard directory structures (like e.g. Spring boot archives that store application classes in a BOOT_INF directory) are not supported either.
-#### Attributes
-
-
-
-
-
Attribute
-
Description
-
Required
-
-
-
-
-
resources
-
- Will only be considered if the
- yguard element
- contains a nested
- shrink element.
-
- Determines how the shrinking engine handles all non-.class files.
-
- Currently the following three resource policies are supported:
-
-
copy
- the default, simply copies all resource files to the output jar.
-
-
auto
- copies only those resource files that reside in a directory that
- still contains one or more .class files after shrinking.
-
-
none
- discards all resource files.
-
-
-
-
- No, defaults to copy.
-
-
-
-
#### Child Elements
- [patternset](http://ant.apache.org/manual/Types/patternset.html)
@@ -177,7 +103,7 @@ Moreover, jar files with non-standard directory structures (like e.g. Spring boo
```xml
-
+
@@ -186,7 +112,7 @@ Moreover, jar files with non-standard directory structures (like e.g. Spring boo
-
+
@@ -195,8 +121,7 @@ Moreover, jar files with non-standard directory structures (like e.g. Spring boo
```
## The `externalclasses` Element
-If the jar to be processed by `yGuard` depends on external classes or libraries, this element can be used to specify classpaths to these entities. These libraries will neither be shrinked nor obfuscated. Use the `inoutpair` element for this purpose! See the `external_library` example for an example of when to use this element.
-In order to achieve a maximum shrinking effect by the `shrink` task, all external dependencies should be declared in the `externalclasses` element. Otherwise, all non-private methods of classes that inherit from unresolvable classes will not be shrinked.
+If the jar to be processed by `yGuard` depends on external classes or libraries, this element can be used to specify classpaths to these entities. These libraries will not be obfuscated. Use the `inoutpair` element for this purpose! See the `external_library` example for an example of when to use this element.
The elements attributes and child elements can be seen on the [Ant documentation page about using path elements](http://ant.apache.org/manual/using.html#path).
@@ -207,20 +132,19 @@ See the `linked_example` for an example of when to use this element.
#### Attributes
-
-
-
-
Attribute
-
Description
-
Required
-
-
+
+
+
+
Attribute
+
Description
+
Required
+
+
name
-
A comma-separated list of attribute names that are to
- be retained in the shrinked and/or
- obfuscated class
- files.
+
+ A comma-separated list of attribute names that are to be retained in the
+ obfuscated class files.
Yes
@@ -242,103 +166,12 @@ See the `linked_example` for an example of when to use this element.
This will retain the attributes named _"SourceFile"_, _"LineNumberTable"_, and _"LocalVariableTable"_ effectively enabling debugging information for all classes in the `com.mycompany.mylibrary` package and subpackages.
-## The `shrink` Element
-The `shrink` task removes all classes, fields and methods that are not reachable from a number of entrypoints given by a nested [keep]() element.
-See the [examples]() explanation of some common use cases. If your code uses reflection, please read the [troubleshooting](troubleshooting.md) section for information on this topic.
-
-#### Attributes
-
-
-
-
-
Attribute
-
Description
-
Required
-
-
-
-
logfile
-
Determines the name of the logfile that is generated
- during the shrinking process. The logfile contains information about
- the entrypoints the shrinking engine uses, the removed classes,
- methods and fields as well as any warnings.
-
- If the name ends with a ".gz", yGuard will automatically create a
- gzipped version of the file which potentially saves a lot of disc
- space.
-
-
- No, defaults toyshrinklog.xml
-
-
-
-
- createStubs
-
-
- Instead of removing methods completely, this attribute causes the
- shrink task to insert a method
- stub that throws a java.lang.InternalError if it is
- called. This attribute is very useful if the shrinking process
- causes your application to break and you are uncertain about which
- additional code entities you have to include in the
- keepelement.
- Note that classes considered as completely obsolete by the shrinking
- engine are still removed completely - this attribute only
- affects obsolete methods of non-obsolete classes.
-
-
- No, defaults to false
-
-
-
-
-#### Child Elements
-
-- [keep](#the-keep-element)
-- [entrypointjar](#the-entrypointjar-element)
-
-## The `entrypointjar` Element
-
-The `entrypointjar` element can be used for convenience if your application uses libraries that are to be shrinked, but the jarfile using these libraries should be left untouched by the shrinking engine. Such a jarfile could be specified as an `entrypointjar`.
-
-#### Attributes
-
-
-
-
-
Attribute
-
Description
-
Required
-
-
-
-
-
name
-
Path to to the jar file to use as entrypointjar.
-
Yes
-
-
-
-#### Child Elements
-
-The `entrypointjar` element has no child elements.
-
-#### Example
-
-```xml
-
-
-
-
-
-
-```
-
## The `rename` Element
The basic idea is, that all elements will be renamed by this task. There are different use cases, where you sometimes want to exclude or simply just have to exclude some elements from name obfuscation, i.e. **not** rename them but keep in the API as is. See the [examples]() for explanation of some common use cases. If your code uses reflection, please read the [troubleshooting](troubleshooting.md) section for information on this topic. Excluding elements can be achieved by using the [keep](#the-keep-element) element, the `mainclass` attribute of the `rename` element and by annotating elements in the source code with the annotation that is specified in the `annotationClass` attribute of the `rename` element. Using the nested `keep` element, you have to specify all classes, methods, fields, and attributes that should be excluded from name obfuscation. Another way is to [annotate the elements directly in the source code](#annotate) that should be obfuscated or excluded. You can use the yFiles obfuscation annotation `com.yworks.util.annotation.Obfuscation` for that or specify your own annotation in the `annotationClass` attribute of this element.
-
+#### Attributes
+
+
Attribute
@@ -465,7 +298,7 @@ The basic idea is, that all elements will be renamed by this task. There are dif
#### Attributes
-
+
Attribute
@@ -494,7 +327,7 @@ The basic idea is, that all elements will be renamed by this task. There are dif
#### Supported properties
-
+
Name
@@ -648,20 +481,19 @@ The `property` element has no child elements.
## The `keep` Element
-This element is a child of the [rename](#the-rename-element) or [shrink](#the-shrink-element) element. It can be used to specify elements that are excluded from the parent `rename` or `shrink` task. The excluded classes, methods and fields are defined using nested [package](#the-package-element), [class](#the-class-element), [method](#the-method-element) and [field](#the-field-element) elements.
+This element is a child of the [rename](#the-rename-element) element. It can be used to specify elements that are excluded from the parent `rename` task. The excluded classes, methods and fields are defined using nested [package](#the-package-element), [class](#the-class-element), [method](#the-method-element) and [field](#the-field-element) elements.
#### Attributes
-The `keep` element provides a number of boolean attributes that determine whether debug information and annotations present in the input class files are to be retained in the output files. The default behavior of the `rename` and `shrink` elements for the respective attributes is explained in the table below.
-Note that a more fine-grained control over which attributes to keep for which class files is possible using the [attribute](#the-attribute-element) element. Also, the `attribute` element allows to define attributes to keep for both the rename and the shrink element in a common place.
+The `keep` element provides a number of attributes that determine whether debug information present in the input class files is to be retained in the output files. The default behavior of the `rename` element for the respective attributes is explained in the table below.
+Note that a more fine-grained control over which attributes to keep for which class files is possible using the [attribute](#the-attribute-element) element.
-
+
Attribute
Description
-
Default (rename)
-
Default (shrink)
+
Default
@@ -673,7 +505,6 @@ Note that a more fine-grained control over which attributes to keep for which cl
be included in the output class files.
remove
-
remove
linenumbertable
@@ -684,7 +515,6 @@ Note that a more fine-grained control over which attributes to keep for which cl
files.
remove
-
remove
localvariabletable
@@ -695,7 +525,6 @@ Note that a more fine-grained control over which attributes to keep for which cl
output class files.
remove
-
remove
localvariabletypetable
@@ -706,80 +535,16 @@ Note that a more fine-grained control over which attributes to keep for which cl
code file should be included in the output class files.
remove
-
remove
-
-
-
runtimevisibleannotations
-
- Determines whether annotations with the retention policy
- RetentionPolicy.RUNTIMEshould be included in the output
- class files.
-
-
keep1
-
keep
-
-
-
runtimevisibleparameterannotations
-
- Determines whether method paramater annotations with the retention
- policy RetentionPolicy.RUNTIME should be included in
- the output class files.
-
-
keep1
-
keep
-
-
-
runtimevisibletypeannotations
-
- Determines whether type annotations with the retention
- policy RetentionPolicy.RUNTIME should be included in
- the output class files.
-
-
keep1
-
keep
-
-
-
runtimeinvisibleannotations
-
- Determines whether annotations with the retention policy
- RetentionPolicy.CLASSshould be included in the output
- class files.
-
-
keep1
-
remove
-
-
-
runtimeinvisibleparameterannotations
-
- Determines whether method paramater annotations with the retention
- policy RetentionPolicy.CLASS should be included in the
- output class files.
-
-
keep1
-
remove
-
-
-
runtimeinvisibletypeannotations
-
- Determines whether type annotations with the retention
- policy RetentionPolicy.CLASS should be included in the
- output class files.
-
-
keep1
-
remove
-1 `rename` always keeps annotations irrespective of its
-`runtime*annotations` attribute values.
-
## The `class` Element
-The `class` element can be used for excluding certain classes and/or their fields and methods from the renaming or shrinking process.
+The `class` element can be used for excluding certain classes and/or their fields and methods from the renaming process.
If no `name`, `extends` or `implements` attribute is given and the `class` element contains no nested `patternset`, a `class` element matches all class names.
-The `classes`, `methods` and `fields` attributes tell the shrinking and renaming engines which classes, methods and fields to keep based on their visibility. The following table lists the possible values for all of these attributes and shows which elements will be excluded. A '*' denotes, that elements that have the given visibility will be excluded for the specified attribute value. A '-' denotes that the these elements will not be excluded from the process.
+The `classes`, `methods` and `fields` attributes tell the renaming engine which classes, methods and fields to keep based on their visibility. The following table lists the possible values for all of these attributes and shows which elements will be excluded. A '*' denotes, that elements that have the given visibility will be excluded for the specified attribute value. A '-' denotes that the these elements will not be excluded from the process.
@@ -828,7 +593,7 @@ The `classes`, `methods` and `fields` attributes tell the shrinking and renaming
#### Attributes
-
+
Attribute
@@ -894,7 +659,7 @@ The `classes`, `methods` and `fields` attributes tell the shrinking and renaming
#### Explanation
-There are three possible ways of specifying which classes will be excluded from the shrinking and obfuscation process:
+There are three possible ways of specifying which classes will be excluded from the obfuscation process:
_1)_ One can specify a single java class using the fully qualified name in java syntax with the name attribute. For example:
```xml
@@ -946,7 +711,7 @@ This will keep all class names, that are either `public` or `protected` and whic
```
-This example shows the very common use case of excluding a complete public API from the shrinking and obfuscation process. There is an abbreviation for this use case: you can omit the `patternset` element, since in the case where the `classes` attribute is specified and there is no `patternset` child element used, the task will automatically apply this rule. In this example all classes will be exposed, that are either `public` or `protected`. Their methods and fields will be exposed as long as they are declared `public` or `protected`. If a class is `package-private` or `private` (inner classes), neither itself nor its methods or fields will be exposed.
+This example shows the very common use case of excluding a complete public API from the obfuscation process. There is an abbreviation for this use case: you can omit the `patternset` element, since in the case where the `classes` attribute is specified and there is no `patternset` child element used, the task will automatically apply this rule. In this example all classes will be exposed, that are either `public` or `protected`. Their methods and fields will be exposed as long as they are declared `public` or `protected`. If a class is `package-private` or `private` (inner classes), neither itself nor its methods or fields will be exposed.
The last example shows how to keep the `public` methods of certain classes only, but neither field names nor the class names themselves.
```xml
@@ -958,10 +723,10 @@ The last example shows how to keep the `public` methods of certain classes only,
```
## The `method` Element
-Using the `method` element you can specify methods by signature which should be excluded from shrinking or name obfuscation.
+Using the `method` element you can specify methods by signature which should be excluded from name obfuscation.
#### Attributes
-
+
Attribute
@@ -1014,15 +779,15 @@ Using the `method` element you can specify methods by signature which should be
```
-This will keep the main method of the `MyClass` class and the `foo` method. Additionally all `readObject` and `writeObject` methods (used for serialization) will be kept in all classes of the `com.mycompany.myapp.data` package. Note that you have to specify the return argument's type, even if it is void and that you have to use the fully qualified name for all classes, even those, that are in the `java.lang package`.
+This will keep the main method of the `MyClass` class and the `foo` method. Additionally, all `readObject` and `writeObject` methods (used for serialization) will be kept in all classes of the `com.mycompany.myapp.data` package. Note that you have to specify the return argument's type, even if it is void and that you have to use the fully qualified name for all classes, even those, that are in the `java.lang package`.
## The `field` Element
-Using the `field` element you can specify fields by name which should be excluded from shrinking or name obfuscation.
+Using the `field` element you can specify fields by name which should be excluded from name obfuscation.
#### Attributes
-
+
Attribute
@@ -1072,7 +837,7 @@ Using the `field` element you can specify fields by name which should be exclude
This will keep the field named `field` of the `MyClass` class. Additionally all the `serialVersionUID` fields (used for serialization) will be kept in all classes of the `com.mycompany.myapp.data` package.
## The `package` Element
-The `package` element can be used for excluding certain package's names from the renaming process. It cannot be used for the shrinking process.
+The `package` element can be used for excluding certain package's names from the renaming process.
All packages that are matched be the nested patternset element will not be obfuscated. This has no influence on the class, method, or field names but will only result in the package's name not being obfuscated. Normally, it is not necessary to use this element, instead the [class element](#the-class-element) is used to keep class names (and thus their package names) from being obfuscated.
@@ -1099,7 +864,7 @@ Using nested property elements, the mapping of sourceFile attributes in obfuscat
#### Attributes
-
+
Name
@@ -1144,7 +909,7 @@ Using nested `property` elements, the mapping of `linenumbertable` attributes in
#### Attributes
-
+
Name
@@ -1236,7 +1001,7 @@ Using the `adjust` element one can specify resource files whose names and/or con
#### Attributes
-
+
Attribute
@@ -1616,7 +1381,7 @@ This class is also the default annotation yGuard is looking for when obfuscating
The convention for annotation classes that yGuard understands as obfuscation controlling annotations requires two attributes:
-
+
Attribute
@@ -1697,36 +1462,25 @@ The lower part of the window contains an editable text area that can be used to
# DTD used for Ant ``
-The obfuscation and shrinking process can be completely configured inside your Ant script. The yguard task and nested elements should be used according to the following DTD. Note that this is for information purposes only, i.e. you do not have to include the following lines anywhere. This DTD should just provide a quick overview of the yGuard syntax. Due to restrictions of the DTD specification, the given DTD does not describe all available yGuard options. Please browse through the documentation above for complete documentation of the yGuard Ant task elements.
+The obfuscation process can be completely configured inside your Ant script. The yguard task and nested elements should be used according to the following DTD. Note that this is for information purposes only, i.e. you do not have to include the following lines anywhere. This DTD should just provide a quick overview of the yGuard syntax. Due to restrictions of the DTD specification, the given DTD does not describe all available yGuard options. Please browse through the documentation above for complete documentation of the yGuard Ant task elements.
```xml
-
+
-
+out CDATA #REQUIRED>
-
+
name CDATA #REQUIRED>
-
-
-
-
-
-
name CDATA #REQUIRED
map CDATA #REQUIRED>
-
@@ -1781,30 +1527,18 @@ fields CDATA #IMPLIED
map CDATA #IMPLIED
methods CDATA #IMPLIED
name CDATA #IMPLIED>
-
-
-
```
**Attention** users of IDEs that "support" the creation of Ant files (e.g. IDEA's IntelliJ): Your IDE may indicate some errors inside your ANT file when you use yGuard specific elements. This is because the IDE does not know about the DTD used by yGuard. However this is not a real problem, since the Ant file should nevertheless work as expected.
diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md
index 9bd94e2d..b7695c2a 100644
--- a/docs/troubleshooting.md
+++ b/docs/troubleshooting.md
@@ -1,14 +1,13 @@
# Troubleshooting
-There are a couple of things you should be aware of when obfuscating and shrinking software.
-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.
+There are a couple of things you should be aware of when obfuscating software.
+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.
The most important facts to keep in mind when using yGuard are described here briefly:
-- 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).
-- 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.
-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.
-- `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.
-- The customized serialization mechanism will not work if you obfuscated or shrinked the writeObject and readObject methods as well as the serializationUID field.
+- 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`.
+- Automatic introspection and reflection will break in most cases, when you decide to obfuscate the corresponding methods and fields.
+- `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`.
+- The customized serialization mechanism will not work if you obfuscated the writeObject and readObject methods as well as the serializationUID field.
- Simple bean introspection will not work, if you decide to obfuscate your public accessor methods, since it makes use of reflection.
- 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`.
To solve this problem, set the `-Xmx` option in the `ANT_OPTS` variable, e.g.:
diff --git a/examples/external_library/README.md b/examples/external_library/README.md
index 7c4bc2d4..f061d783 100644
--- a/examples/external_library/README.md
+++ b/examples/external_library/README.md
@@ -10,7 +10,7 @@ Classes residing in `lib/gson-2.8.9.jar` will be used to resolve external
dependencies during the obfuscation run.
yGuard automatically detects externally declared methods and prevents renaming
-and shrinking of these items.
+of these items.
-As a result, the shrinked and obfuscated jar file can be used together with
-unmodified versions of external libraries without causing any problems.
+As a result, the obfuscated jar file can be used together with unmodified
+versions of external libraries without causing any problems.
diff --git a/examples/serializable_exclusion/README.md b/examples/serializable_exclusion/README.md
index ef7b5d06..07bfa76c 100644
--- a/examples/serializable_exclusion/README.md
+++ b/examples/serializable_exclusion/README.md
@@ -8,8 +8,5 @@ More specifically, in this example the `implements` attribute of yGuard's
the same element could be used to exclude classes that extend a certain base
class).
-Additionally, all classes that extend the base class for menu items,
-`com.yworks.example.MyMenuItem`, are defined as entrypoints for the shrinking
-engine using the extends attribute of the class element.
The `readObject` and `writeObject` methods and the field `serialVersionUID`
needed for serialization are excluded from name obfuscation as well.
diff --git a/src/main/java/com/yworks/common/ResourcePolicy.java b/src/main/java/com/yworks/common/ResourcePolicy.java
deleted file mode 100644
index e6eec0f0..00000000
--- a/src/main/java/com/yworks/common/ResourcePolicy.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.yworks.common;
-
-/**
- * The enum Resource policy.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public enum ResourcePolicy {
- /**
- * Copy resource policy.
- */
- COPY,
- /**
- * Auto resource policy.
- */
- AUTO,
- /**
- * None resource policy.
- */
- NONE; }
diff --git a/src/main/java/com/yworks/common/ShrinkBag.java b/src/main/java/com/yworks/common/ShrinkBag.java
index 5ab325f7..ec0dca3a 100644
--- a/src/main/java/com/yworks/common/ShrinkBag.java
+++ b/src/main/java/com/yworks/common/ShrinkBag.java
@@ -43,18 +43,4 @@ public interface ShrinkBag {
* @return the boolean
*/
boolean isEntryPointJar();
-
- /**
- * Sets resources.
- *
- * @param resourcesStr the resources str
- */
- void setResources( String resourcesStr );
-
- /**
- * Gets resources.
- *
- * @return the resources
- */
- ResourcePolicy getResources();
}
diff --git a/src/main/java/com/yworks/common/ant/EntryPointJar.java b/src/main/java/com/yworks/common/ant/EntryPointJar.java
deleted file mode 100644
index 73120360..00000000
--- a/src/main/java/com/yworks/common/ant/EntryPointJar.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.yworks.common.ant;
-
-import com.yworks.common.ResourcePolicy;
-import com.yworks.common.ShrinkBag;
-import org.apache.tools.ant.BuildException;
-
-import java.io.File;
-
-/**
- * The type Entry point jar.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class EntryPointJar implements ShrinkBag {
-
- private File inFile;
-
- public void setIn( File file ) {
- inFile = file;
- }
-
- /**
- * Sets name.
- *
- * @param fileName the file name
- */
- public void setName(File fileName) {
- inFile = fileName;
- }
-
- public void setOut( File file ) {
- throw new BuildException( "You can't set an outfile on an EntryPointJar." );
- }
-
- public File getIn() {
- return inFile;
- }
-
- public File getOut() {
- return null;
- }
-
- public boolean isEntryPointJar() {
- return true;
- }
-
- public void setResources( String resourcesStr ) {
- throw new BuildException( "You can't set resources on an EntryPointJar." );
- }
-
- public ResourcePolicy getResources() {
- return null;
- }
-}
diff --git a/src/main/java/com/yworks/common/ant/EntryPointsSection.java b/src/main/java/com/yworks/common/ant/EntryPointsSection.java
deleted file mode 100644
index 1fbb0f5f..00000000
--- a/src/main/java/com/yworks/common/ant/EntryPointsSection.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package com.yworks.common.ant;
-
-import com.yworks.yshrink.ant.ClassSection;
-import com.yworks.yshrink.ant.FieldSection;
-import com.yworks.yshrink.ant.MethodSection;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * ANT entryPoint section
- */
-public class EntryPointsSection extends Exclude {
-
- private List methodSections = new ArrayList( 5 );
- private List classSections = new ArrayList( 5 );
- private List fieldSections = new ArrayList( 5 );
- private List attributesSections = new ArrayList( 1 );
-
- /**
- * Instantiates a new Entry points section.
- *
- * @param task the task
- */
- public EntryPointsSection( YGuardBaseTask task ) {
- super( task );
- }
-
- /**
- * Add configured method.
- *
- * @param ms the ms
- */
- public void addConfiguredMethod( MethodSection ms ) {
- this.methodSections.add( ms );
- }
-
- /**
- * Add configured class.
- *
- * @param cs the cs
- */
- public void addConfiguredClass( ClassSection cs ) {
- this.classSections.add( cs );
- }
-
- /**
- * Add configured field.
- *
- * @param fs the fs
- */
- public void addConfiguredField( FieldSection fs ) {
- this.fieldSections.add( fs );
- }
-
- /**
- * Add configured attribute.
- *
- * @param as the as
- */
- public void addConfiguredAttribute( AttributesSection as ) {
- this.attributesSections.add( as );
- }
-
- /**
- * Gets method sections.
- *
- * @return the method sections
- */
- public List getMethodSections() {
- return methodSections;
- }
-
- /**
- * Gets class sections.
- *
- * @return the class sections
- */
- public List getClassSections() {
- return classSections;
- }
-
- /**
- * Gets field sections.
- *
- * @return the field sections
- */
- public List getFieldSections() {
- return fieldSections;
- }
-
- /**
- * Gets attributes sections.
- *
- * @return the attributes sections
- */
- public List getAttributesSections() {
- return attributesSections;
- }
-
-
-}
diff --git a/src/main/java/com/yworks/common/ant/Exclude.java b/src/main/java/com/yworks/common/ant/Exclude.java
index e9ee1d99..78b8de44 100644
--- a/src/main/java/com/yworks/common/ant/Exclude.java
+++ b/src/main/java/com/yworks/common/ant/Exclude.java
@@ -1,7 +1,7 @@
package com.yworks.common.ant;
/**
- * Stores which byte code attributes to keep when renaming or shrinking.
+ * Stores which byte code attributes to keep when renaming.
* @author Michael Schroeder, yWorks GmbH http://www.yworks.com
*/
public abstract class Exclude {
@@ -22,30 +22,6 @@ public abstract class Exclude {
* Stores whether to keep the local variable type table attribute.
*/
protected boolean lttable = false;
- /**
- * Stores whether to keep the runtime visible annotations.
- */
- protected boolean rvAnn = true;
- /**
- * Stores whether to keep the runtime visible type annotations.
- */
- protected boolean rvTypeAnn = true;
- /**
- * Stores whether to keep the runtime invisible annotations.
- */
- protected boolean riAnn = false;
- /**
- * Stores whether to keep the runtime invisible type annotations.
- */
- protected boolean riTypeAnn = false;
- /**
- * Stores whether to keep the runtime visible parameter annotations.
- */
- protected boolean rvPann = true;
- /**
- * Stores whether to keep the runtime invisible parameter annotations.
- */
- protected boolean riPann = false;
/**
* Stores whether to keep the source debug extension attribute.
*/
@@ -91,60 +67,6 @@ public void setLinenumbertable(boolean lt) {
this.ltable = lt;
}
- /**
- * Sets whether to keep the runtime visible annotations.
- * @param v if true, runtime visible annotations are
- * kept when renaming or shrinking, otherwise they are removed.
- */
- public void setRuntimeVisibleAnnotations(boolean v) {
- this.rvAnn = v;
- }
-
- /**
- * Sets whether to keep the runtime visible type annotations.
- * @param v if true, runtime visible type annotations are
- * kept when renaming or shrinking, otherwise they are removed.
- */
- public void setRuntimeVisibleTypeAnnotations(boolean v) {
- this.rvTypeAnn = v;
- }
-
- /**
- * Sets whether to keep the runtime invisible annotations.
- * @param v if true, runtime invisible annotations are
- * kept when renaming or shrinking, otherwise they are removed.
- */
- public void setRuntimeInvisibleAnnotations(boolean v) {
- this.riAnn = v;
- }
-
- /**
- * Sets whether to keep the runtime invisible type annotations.
- * @param v if true, runtime invisible type annotations are
- * kept when renaming or shrinking, otherwise they are removed.
- */
- public void setRuntimeInvisibleTypeAnnotations(boolean v) {
- this.riTypeAnn = v;
- }
-
- /**
- * Sets whether to keep the runtime visible parameter annotations.
- * @param v if true, runtime visible parameter annotations are
- * kept when renaming or shrinking, otherwise they are removed.
- */
- public void setRuntimeVisibleParameterAnnotations(boolean v) {
- this.rvPann = v;
- }
-
- /**
- * Sets whether to keep the runtime invisible parameter annotations.
- * @param v if true, runtime invisible parameter annotations are
- * kept when renaming or shrinking, otherwise they are removed.
- */
- public void setRuntimeInvisibleParameterAnnotations(boolean v) {
- this.riPann = v;
- }
-
/**
* Sets whether to keep the local variable type table attribute.
* @param lt if true, local variable type table attributes are
@@ -199,60 +121,6 @@ public boolean isLttable() {
return lttable;
}
- /**
- * Determines whether to keep the runtime visible annotations.
- * @return true if runtime visible annotations have to be
- * kept when renaming or shrinking, false otherwise.
- */
- public boolean isRvAnn() {
- return rvAnn;
- }
-
- /**
- * Determines whether to keep the runtime invisible annotations.
- * @return true if runtime invisible annotations have to be
- * kept when renaming or shrinking, false otherwise.
- */
- public boolean isRiAnn() {
- return riAnn;
- }
-
- /**
- * Determines whether to keep the runtime visible parameter annotations.
- * @return true if runtime visible parameter annotations have to
- * be kept when renaming or shrinking, false otherwise.
- */
- public boolean isRvPann() {
- return rvPann;
- }
-
- /**
- * Determines whether to keep the runtime invisible parameter annotations.
- * @return true if runtime invisible parameter annotations have
- * to be kept when renaming or shrinking, false otherwise.
- */
- public boolean isRiPann() {
- return riPann;
- }
-
- /**
- * Determines whether to keep the runtime visible type annotations.
- * @return true if runtime visible type annotations have
- * to be kept when renaming or shrinking, false otherwise.
- */
- public boolean isRvTypeAnn() {
- return rvTypeAnn;
- }
-
- /**
- * Determines whether to keep the runtime invisible type annotations.
- * @return true if runtime invisible type annotations have
- * to be kept when renaming or shrinking, false otherwise.
- */
- public boolean isRiTypeAnn() {
- return riTypeAnn;
- }
-
/**
* Determines whether to keep the source debug extension attribute.
* @return true if source debug extension attributes have to be
diff --git a/src/main/java/com/yworks/common/ant/InOutPair.java b/src/main/java/com/yworks/common/ant/InOutPair.java
index dd33ce82..37e4e593 100644
--- a/src/main/java/com/yworks/common/ant/InOutPair.java
+++ b/src/main/java/com/yworks/common/ant/InOutPair.java
@@ -1,6 +1,5 @@
package com.yworks.common.ant;
-import com.yworks.common.ResourcePolicy;
import com.yworks.common.ShrinkBag;
import org.apache.tools.ant.BuildException;
@@ -12,48 +11,30 @@
* @author Michael Schroeder, yWorks GmbH http://www.yworks.com
*/
public class InOutPair implements ShrinkBag {
- private File inFile;
- private File outFile;
-
- /**
- * The Resources.
- */
- ResourcePolicy resources = ResourcePolicy.COPY;
-
- public void setIn( final File file ) {
- this.inFile = file;
- }
-
- public void setOut( final File file ) {
- this.outFile = file;
- }
-
- public File getIn() {
- return inFile;
- }
-
- public File getOut() {
- return outFile;
- }
-
- public boolean isEntryPointJar() {
- return false;
- }
-
- public void setResources( String resourcesStr ) {
-
- try {
- resources = ResourcePolicy.valueOf( resourcesStr.trim().toUpperCase() );
- } catch ( IllegalArgumentException e ) {
- throw new BuildException( "Invalid resource policy: " + resourcesStr );
- }
- }
-
- public ResourcePolicy getResources() {
- return resources;
- }
-
- public String toString() {
- return "in: " + inFile + "; out: " + outFile;
- }
+ private File inFile;
+ private File outFile;
+
+ public void setIn( final File file ) {
+ this.inFile = file;
+ }
+
+ public void setOut( final File file ) {
+ this.outFile = file;
+ }
+
+ public File getIn() {
+ return inFile;
+ }
+
+ public File getOut() {
+ return outFile;
+ }
+
+ public boolean isEntryPointJar() {
+ return false;
+ }
+
+ public String toString() {
+ return "in: " + inFile + "; out: " + outFile;
}
+}
diff --git a/src/main/java/com/yworks/common/ant/YGuardBaseTask.java b/src/main/java/com/yworks/common/ant/YGuardBaseTask.java
index 9b10232a..5e45c7fe 100644
--- a/src/main/java/com/yworks/common/ant/YGuardBaseTask.java
+++ b/src/main/java/com/yworks/common/ant/YGuardBaseTask.java
@@ -1,7 +1,6 @@
package com.yworks.common.ant;
import com.yworks.common.ShrinkBag;
-import com.yworks.common.ResourcePolicy;
import com.yworks.yguard.ant.Property;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.DirectoryScanner;
@@ -186,21 +185,6 @@ public void addConfiguredProperty(Property p){
public static final class InOutPairSection {
private FileSet set;
private Mapper mapper;
- private ResourcePolicy resources = ResourcePolicy.COPY;
-
- /**
- * Sets resources.
- *
- * @param resourcesStr the resources str
- */
- public void setResources( String resourcesStr ) {
-
- try {
- resources = ResourcePolicy.valueOf( resourcesStr.trim().toUpperCase() );
- } catch ( IllegalArgumentException e ) {
- throw new BuildException( "Invalid resource policy: " + resourcesStr );
- }
- }
/**
* Instantiates a new In out pair section.
@@ -251,7 +235,6 @@ public List createShrinkBags(Project project){
throw new BuildException("Cannot obfuscate " + inFile +" using that mapping");
}
InOutPair pair = new InOutPair();
- pair.resources = resources;
pair.setIn(FileUtils.newFileUtils().resolveFile(directoryScanner.getBasedir(), inFile));
pair.setOut(FileUtils.newFileUtils().resolveFile(directoryScanner.getBasedir(), outFile[0]));
result.add(pair);
diff --git a/src/main/java/com/yworks/logging/ConsoleLogger.java b/src/main/java/com/yworks/logging/ConsoleLogger.java
index fbb64a5c..2b97d17b 100644
--- a/src/main/java/com/yworks/logging/ConsoleLogger.java
+++ b/src/main/java/com/yworks/logging/ConsoleLogger.java
@@ -29,10 +29,6 @@ public void doWarn( final String s ) {
public void doWarnToLog( String s ) {
}
- public void doShrinkLog( String s ) {
- System.out.println( s );
- }
-
public void doErr( String s, Throwable ex ) {
System.out.println( s );
ex.printStackTrace();
diff --git a/src/main/java/com/yworks/logging/Logger.java b/src/main/java/com/yworks/logging/Logger.java
index 970b3c2c..5eb79afd 100644
--- a/src/main/java/com/yworks/logging/Logger.java
+++ b/src/main/java/com/yworks/logging/Logger.java
@@ -9,26 +9,6 @@
* @author Michael Schroeder, yWorks GmbH http://www.yworks.com
*/
public abstract class Logger {
-
-
- /**
- * The enum Shrink type.
- */
- public enum ShrinkType {
- /**
- * Class shrink type.
- */
- CLASS,
- /**
- * Method shrink type.
- */
- METHOD,
- /**
- * Field shrink type.
- */
- FIELD }
-
-
private static List instances;
/**
@@ -117,19 +97,6 @@ public static void warnToLog( final String s ) {
}
}
- /**
- * Shrink log.
- *
- * @param s the s
- */
- public static void shrinkLog( final String s ) {
- if ( null != instances ) {
- for ( Logger logger : instances ) {
- logger.doShrinkLog( s );
- }
- }
- }
-
/**
* Do log.
*
@@ -158,13 +125,6 @@ public static void shrinkLog( final String s ) {
*/
public abstract void doWarnToLog( String s );
- /**
- * Do shrink log.
- *
- * @param s the s
- */
- public abstract void doShrinkLog( String s );
-
/**
* Do err.
*
diff --git a/src/main/java/com/yworks/logging/XmlLogger.java b/src/main/java/com/yworks/logging/XmlLogger.java
index 470cd906..4d578dcd 100644
--- a/src/main/java/com/yworks/logging/XmlLogger.java
+++ b/src/main/java/com/yworks/logging/XmlLogger.java
@@ -52,12 +52,7 @@ public void doWarnToLog( String s ) {
pw.println( "" );
}
- public void doShrinkLog( String s ) {
- pw.println( s );
- }
-
public void close() {
- pw.println("");
pw.println();
pw.close();
unregister();
diff --git a/src/main/java/com/yworks/yguard/ObfuscatorTask.java b/src/main/java/com/yworks/yguard/ObfuscatorTask.java
index 501e2de0..73c11ff5 100644
--- a/src/main/java/com/yworks/yguard/ObfuscatorTask.java
+++ b/src/main/java/com/yworks/yguard/ObfuscatorTask.java
@@ -1,7 +1,14 @@
package com.yworks.yguard;
-import com.yworks.util.CollectionFilter;
+import com.yworks.common.ShrinkBag;
import com.yworks.common.ant.ZipScannerTool;
+import com.yworks.common.ant.AttributesSection;
+import com.yworks.common.ant.Exclude;
+import com.yworks.common.ant.InOutPair;
+import com.yworks.common.ant.TypePatternSet;
+import com.yworks.common.ant.YGuardBaseTask;
+import com.yworks.util.CollectionFilter;
+import com.yworks.util.Version;
import com.yworks.yguard.ant.ClassSection;
import com.yworks.yguard.ant.ExposeSection;
import com.yworks.yguard.ant.FieldSection;
@@ -9,13 +16,6 @@
import com.yworks.yguard.ant.Mappable;
import com.yworks.yguard.ant.MethodSection;
import com.yworks.yguard.ant.PackageSection;
-import com.yworks.common.ShrinkBag;
-import com.yworks.common.ant.AttributesSection;
-import com.yworks.common.ant.EntryPointsSection;
-import com.yworks.common.ant.Exclude;
-import com.yworks.common.ant.InOutPair;
-import com.yworks.common.ant.TypePatternSet;
-import com.yworks.common.ant.YGuardBaseTask;
import com.yworks.yguard.obf.Cl;
import com.yworks.yguard.obf.Cl.ClassResolver;
import com.yworks.yguard.obf.ClassTree;
@@ -26,12 +26,10 @@
import com.yworks.yguard.obf.NameMakerFactory;
import com.yworks.yguard.obf.NoSuchMappingException;
import com.yworks.yguard.obf.ResourceHandler;
-import com.yworks.util.Version;
import com.yworks.yguard.obf.YGuardRule;
import com.yworks.yguard.obf.classfile.LineNumberInfo;
import com.yworks.yguard.obf.classfile.LineNumberTableAttrInfo;
import com.yworks.yguard.obf.classfile.Logger;
-import com.yworks.yshrink.YShrinkInvoker;
import com.yworks.yshrink.YShrinkModel;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
@@ -104,10 +102,6 @@ public class ObfuscatorTask extends YGuardBaseTask
protected PatchSection patch = null;
//private Path resourceClassPath;
- // shrinking attributes
- private boolean doShrink = false;
- protected EntryPointsSection entryPoints = null;
- private File shrinkLog = null;
private boolean useExposeAsEntryPoints = true;
private static final String LOG_TITLE_PRE_VERSION = " yGuard Bytecode Obfuscator, v";
@@ -829,17 +823,6 @@ protected ExposeSection newExposeSection( ObfuscatorTask ot ) {
return new ExposeSection( ot );
}
- /**
- * Add excludes.
- *
- * @param entryPoints the entry points
- */
- public void addExcludes( EntryPointsSection entryPoints ) {
- if ( null == this.expose ) {
- createExpose();
- }
- }
-
public Exclude createKeep() {
return createExpose();
}
@@ -893,37 +876,6 @@ public void addConfiguredExpose(ExposeSection ex){
this.expose = ex;
}
- /**
- * Create entry points entry points section.
- *
- * @return the entry points section
- */
- public EntryPointsSection createEntryPoints() {
- return newEntryPointsSection( this );
- }
-
- /**
- * Instantiates an entry points section,
- * subclasses may provide custom implementations.
- *
- * @return the new entry points section
- */
- protected EntryPointsSection newEntryPointsSection( YGuardBaseTask bt ) {
- return new EntryPointsSection( bt );
- }
-
- /**
- * Used by ant to handle the nested entrypoints element.
- *
- * @param eps the eps
- */
- public void addConfiguredEntryPoints( EntryPointsSection eps ) {
- if ( this.entryPoints != null ) {
- throw new IllegalArgumentException( "Only one entrypoints element allowed!" );
- }
- this.entryPoints = eps;
- }
-
/**
* Used by ant to handle the nested map element.
*
@@ -1049,12 +1001,6 @@ public void execute() throws BuildException
TaskLogger taskLogger = new TaskLogger();
- if ( ! ( mode == MODE_STANDALONE ) ) {
- doShrink = false;
- }
-
- if( doShrink ) doShrink();
-
ResourceCpResolver resolver = null;
if (resourceClassPath != null){
resolver = new ResourceCpResolver(resourceClassPath, this);
@@ -1231,14 +1177,6 @@ public void execute() throws BuildException
db.close();
Cl.setClassResolver(null);
- if( doShrink ) {
- for ( int i = 0; i < tempJars.length; i++ ) {
- if ( null != tempJars[ i ] ) {
- tempJars[ i ].delete();
- }
- }
- }
-
if ( !Logger.getInstance().isAllResolved() ) {
Logger.getInstance().warning( "Not all dependencies could be resolved. Please see the logfile for details." );
}
@@ -1298,76 +1236,6 @@ protected ResourceAdjuster newResourceAdjuster(GuardDB db) {
return new ResourceAdjuster(db);
}
- private void doShrink() {
- YShrinkInvoker yShrinkInvoker = null;
-
- try {
- yShrinkInvoker = (YShrinkInvoker) Class.forName("com.yworks.yshrink.YShrinkInvokerImpl").newInstance();
- } catch ( InstantiationException e ) {
- throw new BuildException( NO_SHRINKING_SUPPORT, e );
- } catch ( IllegalAccessException e ) {
- throw new BuildException( NO_SHRINKING_SUPPORT, e );
- } catch ( ClassNotFoundException e ) {
- throw new BuildException( NO_SHRINKING_SUPPORT, e );
- }
-
- if ( null == yShrinkInvoker ) return;
-
- yShrinkInvoker.setContext( (Task)this );
-
- tempJars = new File[ pairs.size() ];
- File[] outJars = new File[ pairs.size() ];
-
- for ( int i = 0; i < tempJars.length; i++ ) {
- try {
- tempJars[ i ] = File.createTempFile( "tempJar_", "_shrinked.jar", new File(((InOutPair) pairs.get( i )).getOut().getParent()));
- } catch ( IOException e ) {
- getProject().log( "Could not create tempfile for shrinking " + tempJars[ i ] + ".", Project.MSG_ERR );
- tempJars[ i ] = null;
- }
-
- if ( null != tempJars[ i ] ) {
- System.out.println( "temp-jar: " + tempJars[ i ] );
- ShrinkBag pair = ((ShrinkBag) pairs.get( i ));
- outJars[ i ] = pair.getOut();
- pair.setOut( tempJars[ i ] );
- yShrinkInvoker.addPair( pair );
- }
- }
-
- yShrinkInvoker.setResourceClassPath( resourceClassPath );
-
- if ( shrinkLog != null ) {
- yShrinkInvoker.setLogFile( shrinkLog );
- }
-
- if ( null != entryPoints ) {
- yShrinkInvoker.setEntyPoints( entryPoints );
- }
-
- if ( null != expose && useExposeAsEntryPoints ) {
- for ( ClassSection cs : (List) expose.getClasses()) {
- yShrinkInvoker.addClassSection( cs );
- }
- for ( MethodSection ms : (List) expose.getMethods()) {
- yShrinkInvoker.addMethodSection( ms );
- }
- for ( FieldSection fs : (List) expose.getFields() ) {
- yShrinkInvoker.addFieldSection( fs );
- }
- }
-
- yShrinkInvoker.execute();
-
- for ( int i = 0; i < tempJars.length; i++ ) {
- if( null != tempJars[ i ] ) {
- InOutPair pair = ((InOutPair) pairs.get( i ));
- pair.setIn( tempJars[ i ] );
- pair.setOut( outJars[ i ] );
- }
- }
- }
-
/**
* Add inheritance entries.
*
@@ -1434,29 +1302,6 @@ public void addInheritanceEntries( Collection entries ) throws IOException {
}
}
- /**
- * Sets shrink.
- *
- * @param doShrink the do shrink
- */
- public void setShrink( boolean doShrink ) {
- if ( mode == MODE_STANDALONE ) {
- this.doShrink = doShrink;
- } else {
- throw new BuildException(
- "The shrink attribute is not supported when the obfuscate task is nested inside a yguard task.\n Use a separate nested shrink task instead." );
- }
- }
-
- /**
- * Sets shrink log.
- *
- * @param shrinkLog the shrink log
- */
- public void setShrinkLog( File shrinkLog ) {
- this.shrinkLog = shrinkLog;
- }
-
/**
* Sets use expose as entry points.
*
diff --git a/src/main/java/com/yworks/yguard/YGuardTask.java b/src/main/java/com/yworks/yguard/YGuardTask.java
index c6705384..79d229ec 100644
--- a/src/main/java/com/yworks/yguard/YGuardTask.java
+++ b/src/main/java/com/yworks/yguard/YGuardTask.java
@@ -4,7 +4,6 @@
import com.yworks.common.ShrinkBag;
import com.yworks.common.ant.*;
import com.yworks.common.ant.AttributesSection;
-import com.yworks.yshrink.ant.ShrinkTask;
import com.yworks.logging.Logger;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
@@ -12,8 +11,6 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
/**
@@ -64,23 +61,6 @@ public void execute() throws BuildException {
// }
// }
- // execute ShrinkTask first
-
-
-
- Collections.sort(
- subTasks,
- new Comparator() {
- public int compare( YGuardBaseTask o1, YGuardBaseTask o2 ) {
- if ( o1 instanceof ShrinkTask ) {
- return 0;
- }
- return 1;
- }
- }
- );
-
-
// execute
int taskNum = 0;
File[] outFiles = new File[ pairs.size() ];
@@ -148,28 +128,6 @@ private File getTempFile( File origFile ) {
}
}
- /**
- * Create shrink shrink task.
- *
- * @return the shrink task
- */
- public ShrinkTask createShrink() {
- ShrinkTask shrinkTask = newShrinkTask( YGuardBaseTask.MODE_NESTED );
- configureSubTask(shrinkTask);
- subTasks.add( shrinkTask );
- return shrinkTask;
- }
-
- /**
- * Instantiates a shrink task,
- * subclasses may provide custom implementations.
- *
- * @return the new shrink task
- */
- protected ShrinkTask newShrinkTask( boolean mode ) {
- return new ShrinkTask( mode );
- }
-
/**
* Create rename obfuscator task.
*
diff --git a/src/main/java/com/yworks/yguard/ant/ExposeSection.java b/src/main/java/com/yworks/yguard/ant/ExposeSection.java
index 2dbbf717..ab50ca04 100644
--- a/src/main/java/com/yworks/yguard/ant/ExposeSection.java
+++ b/src/main/java/com/yworks/yguard/ant/ExposeSection.java
@@ -215,24 +215,6 @@ public Collection createEntries( Collection srcJars ) throws IOException {
if ( lttable ) {
entries.add( new YGuardRule( YGuardRule.TYPE_ATTR, ClassConstants.ATTR_LocalVariableTypeTable ) );
}
- if ( rvAnn ) {
- entries.add( new YGuardRule( YGuardRule.TYPE_ATTR, ClassConstants.ATTR_RuntimeVisibleAnnotations ) );
- }
- if ( rvTypeAnn ) {
- entries.add( new YGuardRule( YGuardRule.TYPE_ATTR, ClassConstants.ATTR_RuntimeVisibleTypeAnnotations ) );
- }
- if ( riAnn ) {
- entries.add( new YGuardRule( YGuardRule.TYPE_ATTR, ClassConstants.ATTR_RuntimeInvisibleAnnotations ) );
- }
- if ( riTypeAnn ) {
- entries.add( new YGuardRule( YGuardRule.TYPE_ATTR, ClassConstants.ATTR_RuntimeInvisibleTypeAnnotations ) );
- }
- if ( rvPann ) {
- entries.add( new YGuardRule( YGuardRule.TYPE_ATTR, ClassConstants.ATTR_RuntimeVisibleParameterAnnotations ) );
- }
- if ( riPann ) {
- entries.add( new YGuardRule( YGuardRule.TYPE_ATTR, ClassConstants.ATTR_RuntimeInvisibleParameterAnnotations ) );
- }
// if ( debugExtension ) {
// entries.add( new YGuardRule( YGuardRule.TYPE_ATTR, ClassConstants.ATTR))
// }
diff --git a/src/main/java/com/yworks/yshrink/YShrink.java b/src/main/java/com/yworks/yshrink/YShrink.java
deleted file mode 100644
index 862c727a..00000000
--- a/src/main/java/com/yworks/yshrink/YShrink.java
+++ /dev/null
@@ -1,250 +0,0 @@
-package com.yworks.yshrink;
-
-import com.yworks.common.ShrinkBag;
-import com.yworks.yshrink.ant.filters.AllMainMethodsFilter;
-import com.yworks.yshrink.ant.filters.EntryPointFilter;
-import com.yworks.yshrink.core.Analyzer;
-import com.yworks.yshrink.core.ClassResolver;
-import com.yworks.yshrink.core.Writer;
-import com.yworks.yshrink.core.Shrinker;
-import com.yworks.yshrink.model.AbstractDescriptor;
-import com.yworks.yshrink.model.ClassDescriptor;
-import com.yworks.yshrink.model.FieldDescriptor;
-import com.yworks.yshrink.model.MethodDescriptor;
-import com.yworks.yshrink.model.Model;
-import com.yworks.logging.ConsoleLogger;
-import com.yworks.logging.Logger;
-import com.yworks.yshrink.util.Util;
-import com.yworks.logging.XmlLogger;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * How the Shrinker works:
- * - Initially, no node is marked as instantiated and all nodes are marked as obsolete.
- * - Using the global entrypoint-node as the startnode, a dfs is run on the dependency graph.
- * - Edges are traversed under the following conditions:
- * - If the target node is a class or field node, the edge may always be traversed.
- * - An edge to a method node may be traversed if it is not a RESOLVE edge and:
- * - The target method is a invoke dynamic or
- * - The target method is static or
- * - The edge represents a super call or
- * - The target node is the NEW-node of a class or
- * - The target method is a constructor or
- * - The target method is private or
- * - The target method is a regular method and the class the method belongs to is marked as instantiated or
- * - The target method is needed, i.e. a child class of the class the method belongs to is instantiated and does not override the method.
- * - If an edge is allowed to be traversed and the target node is a NEW-node, the corresponding class is marked as instantiated.
- * - As long as the amount of classes marked as instantiated increases, rerun the dfs.
- * - If the amount of classes marked as instantiated does not increase between two dfs-rounds, a last dfs is run in order to mark all reachable nodes as non-obsolete. Also, the RESOLVE edges that target methods are allowed to be traversed in this last round in order to mark the target methods as needed for resolving (that is, only a stub of these methods is needed).
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class YShrink {
-
- private static final String CENTER_CLASS = "";//"y/view/NodeLabel";
- private static final String CENTER_METHOD_NAME = "";//"setOffsetDirty";
- private static final String CENTER_METHOD_DESC = "";
-
- //private boolean showGraph = false;
- private final boolean createStubs;
-
- private String digests;
-
- /**
- * Instantiates a new Y shrink.
- */
- public YShrink() {
- this.createStubs = true;
- }
-
- /**
- * Instantiates a new Y shrink.
- *
- * @param createStubs the create stubs
- * @param digests the digests
- */
- public YShrink( boolean createStubs, String digests ) {
- this.createStubs = createStubs;
- this.digests = digests;
- }
-
- /**
- * Basic steps
- * - Init model: create nodes for each class, method and field. Additionally, create a single entrypoint-node and one NEW-node for each class.
- * - Mark all entrypoints: using a composite EntryPointFilter, mark/log every entrypoint-node in the model.
- * - Create all dependency edges using the com.yworks.yshrink.core.Analyzer.
- * - Create additional entrypoint-edges between the entrypoint-node and each entrypoint that doesn't represent an ordinary method (non-abstract,non-static,non-constructor).
- * - Mark all obsolete classes, methods and fields using the com.yworks.yshrink.core.Shrinker.
- * - Write out all non-obsolete classes using the com.yworks.yshrink.core.Writer.
- *
- * @param pairs the pairs
- * @param epf the epf
- * @param resolver the resolver
- * @throws IOException the io exception
- */
- public void doShrinkPairs( List pairs, EntryPointFilter epf, ClassResolver resolver ) throws
- IOException {
-
- final Analyzer analyzer = new Analyzer();
-
- Model model = new Model();
-
- if ( null != resolver ) model.setClassResolver( resolver );
-
- // create nodes
- if ( ! model.isSimpleModelSet() ) {
- analyzer.initModel( model, pairs );
- }
-
- // mark entrypoints
- List entryPoints = markEntryPoints( model, epf );
-
- // create edges
- if ( model.isSimpleModelSet() ) {
- analyzer.createDependencyEdges( model );
- } else {
- analyzer.createEdges( model );
- }
- model.createEntryPointEdges( entryPoints );
-
- final Shrinker shrinker = new Shrinker();
- shrinker.shrink( model );
-
- final Writer writer = new Writer(createStubs, digests );
-
- for ( ShrinkBag bag : pairs ) {
- if ( ! bag.isEntryPointJar() ) {
- writer.write( model, bag );
- }
- }
-
- if ( !model.isAllResolved() ) {
- Logger.warn( "Not all dependencies could be resolved. Please see the logfile for details." );
- }
- }
-
- /**
- * If a constructor is an entrypoint, the synthetic new-node of its class is also marked as an entrypoint.
- *
- *
- * @param model
- *
- * @param epFilter
- */
- private List markEntryPoints( final Model model,
- final EntryPointFilter epFilter ) {
-
- StringBuilder buf = new StringBuilder();
- buf.append( "\n" );
-
- final List entryPoints = new ArrayList();
-
- for ( ClassDescriptor cd : model.getAllClassDescriptors() ) {
-
- epFilter.setRetainAttribute( cd );
-
- if ( epFilter.isEntryPointClass( model, cd ) ) {
- buf.append( "\t\n" );
- entryPoints.add( cd );
- cd.setEntryPoint( true );
- model.markNotObsolete( cd.getNode() );
- }
- for ( MethodDescriptor md : cd.getMethods() ) {
- if ( epFilter.isEntryPointMethod( model, cd, md ) ) {
- buf.append(
- "\t\n" );
-
- entryPoints.add( md );
- md.setEntryPoint( true );
-
- if ( md.getName().equals( Model.CONSTRUCTOR_NAME ) ) {
- AbstractDescriptor newNodeDesc = model.getDescriptor( cd.getNewNode() );
- if ( ! newNodeDesc.isEntryPoint() ) {
- newNodeDesc.setEntryPoint( true );
- entryPoints.add( newNodeDesc );
- }
- }
- }
- }
- for ( FieldDescriptor fd : cd.getFields() ) {
- if ( epFilter.isEntryPointField( model, cd, fd ) ) {
- buf.append( "\t\n" );
- entryPoints.add( fd );
- fd.setEntryPoint( true );
- }
- }
- }
-
- buf.append( "\n" );
- Logger.shrinkLog( buf.toString() );
-
- return entryPoints;
- }
-
- /**
- * Main.
- *
- * @param args the args
- */
- public static void main( final String[] args ) {
-
- new ConsoleLogger();
-
- try {
-
- boolean showGraph = false;
-
- File in = null;
- File out = null;
-
- if ( args.length > 0 ) {
- in = new File( args[ 0 ] );
- }
-
- if ( null == in ) {
- in = new File( ClassLoader.getSystemResource( "yshrink.jar" ).getFile() );
- }
-
- if ( args.length > 1 ) {
- out = new File( args[ 1 ] );
- }
-
- if ( null == out ) {
- out = new File( System.getProperty( "user.dir" ) + "/out.jar" );
- }
-
- if ( args.length > 2 ) {
- showGraph = Boolean.parseBoolean( args[ 2 ] );
- }
-
- final URL[] externalLibs = new URL[]{
- //ClassLoader.getSystemResource( "asm-2.2.2.jar" ),
- //ClassLoader.getSystemResource( "y.jar" ),
- ClassLoader.getSystemResource( "external.jar" )
- };
-
- final YShrink yshrink = new YShrink();
-
- final EntryPointFilter epf = new AllMainMethodsFilter();
-
- } catch ( Exception e ) {
- Logger.err( "An Exception occured.", e );
- }
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/YShrinkInvoker.java b/src/main/java/com/yworks/yshrink/YShrinkInvoker.java
deleted file mode 100644
index c993b899..00000000
--- a/src/main/java/com/yworks/yshrink/YShrinkInvoker.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.yworks.yshrink;
-
-import com.yworks.common.ant.EntryPointsSection;
-import com.yworks.common.ShrinkBag;
-import com.yworks.yguard.ant.MethodSection;
-import com.yworks.yguard.ant.ClassSection;
-import com.yworks.yguard.ant.FieldSection;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-
-import java.io.File;
-
-/**
- * The interface Y shrink invoker.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public interface YShrinkInvoker {
-
- /**
- * Execute.
- */
- public void execute();
-
- /**
- * Add pair.
- *
- * @param pair the pair
- */
- public void addPair( ShrinkBag pair );
-
- /**
- * Sets resource class path.
- *
- * @param path the path
- */
- public void setResourceClassPath( Path path );
-
- /**
- * Add class section.
- *
- * @param cs the cs
- */
- public void addClassSection( ClassSection cs );
-
- /**
- * Add method section.
- *
- * @param ms the ms
- */
- void addMethodSection( MethodSection ms );
-
- /**
- * Add field section.
- *
- * @param fs the fs
- */
- void addFieldSection( FieldSection fs );
-
- /**
- * Sets enty points.
- *
- * @param eps the eps
- */
- void setEntyPoints( EntryPointsSection eps );
-
- /**
- * Sets log file.
- *
- * @param shrinkLog the shrink log
- */
- void setLogFile( File shrinkLog );
-
- /**
- * Sets context.
- *
- * @param task the task
- */
- void setContext(Task task);
-}
diff --git a/src/main/java/com/yworks/yshrink/YShrinkInvokerImpl.java b/src/main/java/com/yworks/yshrink/YShrinkInvokerImpl.java
deleted file mode 100644
index b2cb51a8..00000000
--- a/src/main/java/com/yworks/yshrink/YShrinkInvokerImpl.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package com.yworks.yshrink;
-
-import com.yworks.yguard.ant.PatternMatchedClassesSection;
-import com.yworks.common.ShrinkBag;
-import com.yworks.common.ant.EntryPointsSection;
-import com.yworks.common.ant.TypePatternSet;
-import com.yworks.yguard.obf.YGuardRule;
-import com.yworks.yshrink.ant.ClassSection;
-import com.yworks.yshrink.ant.FieldSection;
-import com.yworks.yshrink.ant.MethodSection;
-import com.yworks.common.ant.PatternMatchedSection;
-import com.yworks.yshrink.ant.ShrinkTask;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.PatternSet;
-
-import java.io.File;
-
-/**
- * The type Y shrink invoker.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class YShrinkInvokerImpl implements YShrinkInvoker {
-
- /**
- * The Shrink task.
- */
- final ShrinkTask shrinkTask;
-
- /**
- * The Eps.
- */
- EntryPointsSection eps;
-
- /**
- * Instantiates a new Y shrink invoker.
- */
- public YShrinkInvokerImpl() {
- shrinkTask = new ShrinkTask();
- eps = new EntryPointsSection( shrinkTask );
- }
-
- public void setEntyPoints( EntryPointsSection eps ) {
- this.eps = eps;
- }
-
- public void setLogFile( File shrinkLog ) {
- shrinkTask.setLogFile( shrinkLog );
- }
-
- public void setContext(Task task) {
- shrinkTask.setProject(task.getProject());
- shrinkTask.setOwningTarget(task.getOwningTarget());
- shrinkTask.setTaskName(task.getTaskName());
- shrinkTask.setLocation(task.getLocation());
- shrinkTask.setDescription(task.getDescription());
- shrinkTask.init();
- }
-
- public void execute() {
- shrinkTask.setEntryPointsExternally( eps );
- shrinkTask.execute();
- }
-
- public void addPair( ShrinkBag pair ) {
- shrinkTask.addConfiguredInOutPair( pair );
- }
-
- public void setResourceClassPath( Path path ) {
- shrinkTask.setResourceClassPath( path );
- }
-
- public void addClassSection( com.yworks.yguard.ant.ClassSection cs ) {
-
- ClassSection yShrinkCS = new ClassSection();
-
- addPatternSets( cs, yShrinkCS, "name" );
-
- yShrinkCS.setClasses( YShrinkInvokerImpl.convertAccess( cs.getClassMode() ).name() );
- yShrinkCS.setFields( YShrinkInvokerImpl.convertAccess( cs.getFieldMode() ).name() );
- yShrinkCS.setMethods( YShrinkInvokerImpl.convertAccess( cs.getMethodMode() ).name() );
-
- if ( null != cs.getName() ) {
- yShrinkCS.setName( cs.getName() );
- }
- eps.addConfiguredClass( yShrinkCS );
- }
-
- public void addMethodSection( com.yworks.yguard.ant.MethodSection ms ) {
-
- MethodSection yShrinkMS = new MethodSection();
-
- addPatternSets( ms, yShrinkMS, "class" );
-
- yShrinkMS.setName( ms.getName() );
- yShrinkMS.setClass( ms.getClassName() );
-
- eps.addConfiguredMethod( yShrinkMS );
- }
-
- public void addFieldSection( com.yworks.yguard.ant.FieldSection fs ) {
-
- FieldSection yShrinkFS = new FieldSection();
-
- addPatternSets( fs, yShrinkFS, "class" );
-
- yShrinkFS.setName( fs.getName() );
- yShrinkFS.setClass( fs.getClassName() );
-
- eps.addConfiguredField( yShrinkFS );
- }
-
- private void addPatternSets( PatternMatchedClassesSection yGuardSection,
- com.yworks.common.ant.PatternMatchedSection yShrinkSection, String type ) {
- if ( null != yGuardSection.getPatternSets() ) {
- for ( PatternSet ps : (Iterable extends PatternSet>) yGuardSection.getPatternSets() ) {
- TypePatternSet tps = new TypePatternSet();
- tps.append( ps, shrinkTask.getProject() );
- tps.setType( type );
- yShrinkSection.addPatternSet( tps, tps.getType() );
- }
- }
- }
-
- private static PatternMatchedSection.Access convertAccess( int yGuardAccess ) {
-
- switch ( yGuardAccess ) {
- case YGuardRule.LEVEL_PRIVATE:
- return PatternMatchedSection.Access.PRIVATE;
- case YGuardRule.LEVEL_FRIENDLY:
- return PatternMatchedSection.Access.FRIENDLY;
- case YGuardRule.LEVEL_PROTECTED:
- return PatternMatchedSection.Access.PROTECTED;
- case YGuardRule.LEVEL_PUBLIC:
- return PatternMatchedSection.Access.PUBLIC;
- default:
- return PatternMatchedSection.Access.NONE;
- }
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/AntLogger.java b/src/main/java/com/yworks/yshrink/ant/AntLogger.java
deleted file mode 100644
index eb7a7e17..00000000
--- a/src/main/java/com/yworks/yshrink/ant/AntLogger.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.yworks.yshrink.ant;
-
-import com.yworks.logging.Logger;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-
-/**
- * The type Ant logger.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class AntLogger extends Logger {
-
- private final Task task;
- private final Project project;
-
- /**
- * Instantiates a new Ant logger.
- *
- * @param project the project
- * @param task the task
- */
- public AntLogger( final Project project, final Task task ) {
- this.project = project;
- this.task = task;
- register();
- }
-
- public void doLog( final String s ) {
- project.log( task, s, Project.MSG_INFO );
- }
-
- public void doErr( final String s ) {
- project.log( task, "ERROR: "+s, Project.MSG_ERR );
- }
-
- public void doWarn( String s ) {
- //project.log( task, "WARNING: "+s, Project.MSG_WARN );
- }
-
- public void doWarnToLog( String s ) {
- }
-
- public void doShrinkLog( String s ) {
-// project.log( s, Project.MSG_INFO );
- }
-
- public void doErr( String s, Throwable ex ) {
- project.log( task, "ERROR: "+s + "\n" + ex.getMessage(), Project.MSG_ERR );
- }
-
- public void close() {
- unregister();
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/ClassSection.java b/src/main/java/com/yworks/yshrink/ant/ClassSection.java
deleted file mode 100644
index 90881652..00000000
--- a/src/main/java/com/yworks/yshrink/ant/ClassSection.java
+++ /dev/null
@@ -1,185 +0,0 @@
-package com.yworks.yshrink.ant;
-
-import com.yworks.common.ant.TypePatternSet;
-import com.yworks.common.ant.PatternMatchedSection;
-import com.yworks.yshrink.util.Util;
-
-import java.util.EnumSet;
-
-/**
- * The type Class section.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public final class ClassSection extends PatternMatchedSection {
-
- private String name;
- private String extendsType;
- private String implementsType;
- private Access classAccess = Access.NONE;
- private Access methodAccess = Access.NONE;
- private Access fieldAccess = Access.NONE;
-
- {
- types = EnumSet.of(
- TypePatternSet.Type.NAME // , EXTENDS
-
- );
- }
-
- /**
- * Gets name.
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets name.
- *
- * @param name the name
- */
- public void setName( String name ) {
- this.name = Util.toInternalClass( name );
- }
-
- /**
- * Gets extends.
- *
- * @return the extends
- */
- public String getExtends() {
- return extendsType;
- }
-
- /**
- * Sets extends.
- *
- * @param extendsType the extends type
- */
- public void setExtends( String extendsType ) {
- this.extendsType = Util.toInternalClass( extendsType );
- }
-
- /**
- * Gets implements.
- *
- * @return the implements
- */
- public String getImplements() {
- return implementsType;
- }
-
- /**
- * Sets implements.
- *
- * @param implementsType the implements type
- */
- public void setImplements( String implementsType ) {
- this.implementsType = Util.toInternalClass( implementsType );
- }
-
- @Override
- public void setAccess( String access ) {
- super.setAccess( access );
- setClassAccess( access );
- setMethodAccess( access );
- setFieldAccess( access );
- }
-
- /**
- * Gets class access.
- *
- * @return the class access
- */
- public Access getClassAccess() {
- return classAccess;
- }
-
- /**
- * Sets class access.
- *
- * @param classAccessStr the class access str
- */
- public void setClassAccess( String classAccessStr ) {
- Access acc = accessValue( classAccessStr );
-
- if ( null != acc ) {
- this.classAccess = acc;
- }
- }
-
- /**
- * Gets method access.
- *
- * @return the method access
- */
- public Access getMethodAccess() {
- return methodAccess;
- }
-
- /**
- * Sets method access.
- *
- * @param methodAccessStr the method access str
- */
- public void setMethodAccess( String methodAccessStr ) {
- Access acc = accessValue( methodAccessStr );
-
- if ( null != acc ) {
- this.methodAccess = acc;
- }
- }
-
- /**
- * Sets classes.
- *
- * @param classAccess the class access
- */
- public void setClasses( String classAccess ) {
- setClassAccess( classAccess );
- }
-
- /**
- * Sets methods.
- *
- * @param methodAccess the method access
- */
- public void setMethods( String methodAccess ) {
- setMethodAccess( methodAccess );
- }
-
- /**
- * Gets field access.
- *
- * @return the field access
- */
- public Access getFieldAccess() {
- return fieldAccess;
- }
-
- /**
- * Sets field access.
- *
- * @param fieldAccessStr the field access str
- */
- public void setFieldAccess( String fieldAccessStr ) {
-
- Access acc = accessValue( fieldAccessStr );
-
- if ( null != acc ) {
- this.fieldAccess = acc;
- }
- }
-
- /**
- * Sets fields.
- *
- * @param fieldAccess the field access
- */
- public void setFields( String fieldAccess ) {
- setFieldAccess( fieldAccess );
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/FieldSection.java b/src/main/java/com/yworks/yshrink/ant/FieldSection.java
deleted file mode 100644
index e6a672e3..00000000
--- a/src/main/java/com/yworks/yshrink/ant/FieldSection.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package com.yworks.yshrink.ant;
-
-import com.yworks.common.ant.TypePatternSet;
-import com.yworks.common.ant.PatternMatchedSection;
-import com.yworks.yshrink.util.Util;
-
-import java.util.EnumSet;
-
-/**
- * The type Field section.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class FieldSection extends PatternMatchedSection {
-
- private String name;
- private String className;
- private String type;
-
- {
- types = EnumSet.of(
- TypePatternSet.Type.NAME,
- TypePatternSet.Type.CLASS
- );
- }
-
- /**
- * Gets name.
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets name.
- *
- * @param name the name
- */
- public void setName( String name ) {
- this.name = name;
- }
-
- /**
- * Gets class name.
- *
- * @return the class name
- */
- public String getClassName() {
- return className;
- }
-
- /**
- * Sets class.
- *
- * @param className the class name
- */
- public void setClass( String className ) {
- this.className = Util.toInternalClass( className );
- }
-
- /**
- * Gets type.
- *
- * @return the type
- */
- public String getType() {
- return type;
- }
-
- /**
- * Sets type.
- *
- * @param type the type
- */
- public void setType( String type ) {
- this.type = Util.toInternalClass( type );
- }
-
- @Override
- public TypePatternSet createPatternSet() {
- TypePatternSet typePatternSet = newTypePatternSet();
- typePatternSet.setType( "class" );
- addPatternSet( typePatternSet, typePatternSet.getType() );
- return typePatternSet;
- }
-
- /**
- * Instantiates a type pattern set,
- * subclasses may provide custom implementations.
- *
- * @return the new type pattern set
- */
- protected TypePatternSet newTypePatternSet() {
- return new TypePatternSet();
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/MethodSection.java b/src/main/java/com/yworks/yshrink/ant/MethodSection.java
deleted file mode 100644
index 3724abdd..00000000
--- a/src/main/java/com/yworks/yshrink/ant/MethodSection.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package com.yworks.yshrink.ant;
-
-import com.yworks.common.ant.TypePatternSet;
-import com.yworks.common.ant.PatternMatchedSection;
-import com.yworks.yshrink.util.Util;
-import org.objectweb.asm.Type;
-
-import java.util.EnumSet;
-
-/**
- * Used by ant to handle the method element.
- */
-public class MethodSection extends PatternMatchedSection {
-
- private String signature;
- private String name;
- private String className;
- private String returnType;
- private String args;
- private String throwsClause;
-
-
- {
- types = EnumSet.of(
- TypePatternSet.Type.NAME,
- TypePatternSet.Type.CLASS
- );
- }
-
- /**
- * Gets signature.
- *
- * @return the signature
- */
- public String getSignature() {
- return signature;
- }
-
- /**
- * Sets signature.
- *
- * @param signature the signature
- */
- public void setSignature( String signature ) {
- this.signature = signature;
- String[] methodArr = Util.toNativeMethod( signature );
- String methodName = methodArr[ 0 ];
- String methodDesc = methodArr[ 1 ];
- setName( methodName );
- setReturnType( Util.toJavaType( Type.getReturnType( methodDesc ).getDescriptor() ) );
-
- setArgs( Util.getArgumentString( Type.getArgumentTypes( methodDesc ) ) );
- }
-
- /**
- * Gets args.
- *
- * @return the args
- */
- public String getArgs() {
- return args;
- }
-
- /**
- * Sets args.
- *
- * @param args the args
- */
- public void setArgs( String args ) {
- this.args = args;
- }
-
- /**
- * Sets name.
- *
- * @param name the name
- */
- public void setName( String name ) {
-
- // in yGuard, the name-attribute is the signature.
- if ( name.trim().indexOf( ' ' ) != -1 ) {
- setSignature( name );
- } else {
- this.name = name;
- }
- }
-
- /**
- * Sets class.
- *
- * @param name the name
- */
- public void setClass( String name ) {
- this.className = Util.toInternalClass( name );
- }
-
- /**
- * Gets name.
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Gets class name.
- *
- * @return the class name
- */
- public String getClassName() {
- return className;
- }
-
- /**
- * Gets return type.
- *
- * @return the return type
- */
- public String getReturnType() {
- return returnType;
- }
-
- /**
- * Sets return type.
- *
- * @param returnType the return type
- */
- public void setReturnType( String returnType ) {
- this.returnType = Util.toInternalClass( returnType );
- }
-
- /**
- * Gets throws.
- *
- * @return the throws
- */
- public String getThrows() {
- return throwsClause;
- }
-
- /**
- * Sets throws.
- *
- * @param throwsClause the throws clause
- */
- public void setThrows( String throwsClause ) {
- this.throwsClause = throwsClause;
- }
-
- @Override
- public TypePatternSet createPatternSet() {
- System.out.println( "MethodSection.createPatternSet" );
- TypePatternSet typePatternSet = newTypePatternSet();
- typePatternSet.setType( "class" );
- addPatternSet( typePatternSet, typePatternSet.getType() );
- return typePatternSet;
- }
-
- /**
- * Instantiates a type pattern set,
- * subclasses may provide custom implementations.
- *
- * @return the new type pattern set
- */
- protected TypePatternSet newTypePatternSet() {
- return new TypePatternSet();
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/ShrinkTask.java b/src/main/java/com/yworks/yshrink/ant/ShrinkTask.java
deleted file mode 100644
index c6e8ada8..00000000
--- a/src/main/java/com/yworks/yshrink/ant/ShrinkTask.java
+++ /dev/null
@@ -1,384 +0,0 @@
-package com.yworks.yshrink.ant;
-
-import com.yworks.common.ShrinkBag;
-import com.yworks.common.ant.*;
-import com.yworks.common.ant.AttributesSection;
-import com.yworks.util.Version;
-import com.yworks.yguard.obf.classfile.ClassConstants;
-import com.yworks.yshrink.YShrink;
-import com.yworks.yshrink.ant.filters.*;
-import com.yworks.logging.Logger;
-import com.yworks.logging.XmlLogger;
-import com.yworks.yshrink.util.MultiReleaseException;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.PatternSet;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * The type Shrink task.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class ShrinkTask extends YGuardBaseTask {
-
- private File logFile = new File( "yshrinklog.xml" );
-
- private boolean createStubs = false;
-
- private String digests = "SHA-1,MD5";
-
- protected EntryPointsSection entryPointsSection;
-
- /**
- * Instantiates a new Shrink task.
- */
- public ShrinkTask() {
- super();
- }
-
- /**
- * Instantiates a new Shrink task.
- *
- * @param mode the mode
- */
- public ShrinkTask( boolean mode ) {
- super( mode );
- }
-
- @Override
- public void execute() throws BuildException {
- getProject().log(this,"yGuard Shrinker v" + Version.getVersion() + " - http://www.yworks.com/products/yguard", Project.MSG_INFO);
-
- super.execute();
-
- Logger xmlLogger = new XmlLogger( getLogWriter() );
- Logger antLogger = new AntLogger(getProject(), this);
-
- final EntryPointFilters epfs = new EntryPointFilters();
-
- List attributesSections = entryPointsSection != null ? entryPointsSection.getAttributesSections() : this.attributesSections;
-
- if ( entryPointsSection != null ) {
-
- epfs.setExclude( entryPointsSection );
-
- List methodSections = entryPointsSection.getMethodSections();
- List fieldSections = entryPointsSection.getFieldSections();
- List classSections = entryPointsSection.getClassSections();
-
- if ( methodSections.size() > 0 ) {
- MethodFilter mf = new MethodFilter( getProject() );
- for ( MethodSection ms : methodSections ) {
- mf.addMethodSection( ms );
- }
- epfs.addEntryPointFilter( mf );
- }
-
- if ( fieldSections.size() > 0 ) {
- FieldFilter ff = new FieldFilter( getProject() );
- for ( FieldSection fs : fieldSections ) {
- ff.addFieldSection( fs );
- }
- epfs.addEntryPointFilter( ff );
- }
-
- if ( classSections.size() > 0 ) {
- ClassFilter cf = new ClassFilter( getProject() );
- for ( ClassSection cs : classSections ) {
- cf.addClassSection( cs );
- }
- epfs.addEntryPointFilter( cf );
- }
-
- AttributeFilter attributeFilter = new AttributeFilter(getProject());
- if (entryPointsSection.isRiAnn()){
- addAttributesSection(attributeFilter, ClassConstants.ATTR_RuntimeInvisibleAnnotations);
- }
- if (entryPointsSection.isRiPann()){
- addAttributesSection(attributeFilter, ClassConstants.ATTR_RuntimeInvisibleParameterAnnotations);
- }
- if (entryPointsSection.isRvAnn()){
- addAttributesSection(attributeFilter, ClassConstants.ATTR_RuntimeVisibleAnnotations);
- }
- if (entryPointsSection.isRvPann()){
- addAttributesSection(attributeFilter, ClassConstants.ATTR_RuntimeVisibleParameterAnnotations);
- }
- if (entryPointsSection.isRvTypeAnn()){
- addAttributesSection(attributeFilter, ClassConstants.ATTR_RuntimeVisibleTypeAnnotations);
- }
- if (entryPointsSection.isRiTypeAnn()){
- addAttributesSection(attributeFilter, ClassConstants.ATTR_RuntimeInvisibleTypeAnnotations);
- }
- if (entryPointsSection.isSource()) {
- addAttributesSection(attributeFilter, ClassConstants.ATTR_SourceFile);
- }
- if (entryPointsSection.isLtable()) {
- addAttributesSection(attributeFilter, ClassConstants.ATTR_LineNumberTable);
- }
- if (entryPointsSection.isLttable()) {
- addAttributesSection(attributeFilter, ClassConstants.ATTR_LocalVariableTypeTable);
- }
- if (entryPointsSection.isVtable()) {
- addAttributesSection(attributeFilter, ClassConstants.ATTR_LocalVariableTable);
- }
- if (entryPointsSection.isDebugExtension()) {
- addAttributesSection(attributeFilter, ClassConstants.ATTR_SourceDebug);
- }
- epfs.addEntryPointFilter(attributeFilter);
-
- // Never remove package-info annotation class
- ClassFilter classFilter = new ClassFilter(getProject());
- ClassSection classSection = new ClassSection();
- PatternSet patternSet = new PatternSet();
- patternSet.setIncludes("**/package-info");
- classSection.addPatternSet(patternSet, TypePatternSet.Type.NAME);
- classFilter.addClassSection(classSection);
-
- epfs.addEntryPointFilter(classFilter);
- }
-
- if ( null != attributesSections && attributesSections.size() > 0 ) {
- AttributeFilter af = new AttributeFilter( getProject() );
- for ( com.yworks.common.ant.AttributesSection as : attributesSections ) {
- af.addAttributesSection( as );
- }
- epfs.addEntryPointFilter( af );
- }
-
- if ( pairs == null ) {
- throw new BuildException( "no files to shrink" );
- } else {
- boolean containsInOutPair = false;
- boolean containsEntryPointJar = false;
- for ( ShrinkBag shrinkBag : pairs ) {
- if ( shrinkBag.isEntryPointJar() ) {
-
- EntryPointJarFilter epjf = new EntryPointJarFilter( (EntryPointJar) shrinkBag );
- epfs.addEntryPointFilter( epjf );
-
- containsEntryPointJar = true;
- } else {
- containsInOutPair = true;
- }
- }
-
- if ( ! containsInOutPair ) {
- throw new BuildException( "no files to shrink" );
- }
-
- if ( ( ! containsEntryPointJar ) && ( null == entryPointsSection ) ) {
- Logger.log( "no entrypoints given - using class access public and protected on all inoutpairs." );
- entryPointsSection = new EntryPointsSection( this );
- ClassFilter cf = new ClassFilter( getProject() );
- ClassSection cs = new ClassSection();
- cs.setAccess( "protected" );
- cf.addClassSection( cs );
- epfs.addEntryPointFilter( cf );
- epfs.setExclude( entryPointsSection );
- }
- }
-
- ResourceCpResolver resolver = null;
-
- if ( resourceClassPath != null ) {
- resolver = new ResourceCpResolver( resourceClassPath, this );
- }
-
- if (properties.containsKey("digests")) {
- setDigests((String) properties.get("digests"));
- }
-
- final YShrink yShrink = new YShrink( createStubs, digests );
-
- //epfs.addEntryPointFilter( new SerializationFilter( getProject() ) );
-
- try {
-
- yShrink.doShrinkPairs( pairs, epfs, resolver );
- } catch ( MultiReleaseException mre ) {
- throw mre;
- } catch ( RuntimeException rte ) {
- if ( rte.getMessage() != null ) {
- Logger.err( rte.getMessage(), rte );
- }
- throw new BuildException( "yShrink encountered an unknown problem!", rte );
- } catch ( Throwable e ) {
- if ( e.getMessage() != null ) {
- Logger.err( e.getMessage(), e );
- } else {
- Logger.err(e.getClass().getName(), e);
- }
- throw new BuildException( "yShrink encountered an unknown severe problem!", e );
-
- } finally {
- try {
- resolver.close();
- } catch (Exception e) {
- // can't do nothing about it
- }
- xmlLogger.close();
- antLogger.close();
- }
- }
-
- private PrintWriter getLogWriter() {
- PrintWriter log = null;
- if ( logFile != null ) {
- try {
- if ( logFile.getName().endsWith( ".gz" ) ) {
- log = new PrintWriter(
- new BufferedWriter(
- new OutputStreamWriter(
- new GZIPOutputStream(
- new FileOutputStream( logFile )
- )
- )
- )
- );
- } else {
- log = new PrintWriter( new BufferedWriter( new FileWriter( logFile ) ) );
- }
- } catch ( IOException ioe ) {
- getProject().log( this, "Could not create logfile: " + ioe, Project.MSG_ERR );
- log = new PrintWriter( System.out );
- }
- } else {
- log = new PrintWriter( System.out );
- }
- return log;
- }
-
- /**
- * Gets create stubs.
- *
- * @return the create stubs
- */
- public boolean getCreateStubs() {
- return createStubs;
- }
-
- /**
- * Sets create stubs.
- *
- * @param createStubs the create stubs
- */
- public void setCreateStubs( boolean createStubs ) {
- this.createStubs = createStubs;
- }
-
- /**
- * Gets digests.
- *
- * @return the digests
- */
- public String getDigests() {
- return digests;
- }
-
- /**
- * Sets digests.
- *
- * @param digests the digests
- */
- public void setDigests( String digests ) {
- this.digests = digests;
- }
-
- /**
- * Sets log file.
- *
- * @param file the file
- */
- public void setLogFile( File file ) {
- this.logFile = file;
- }
-
- /**
- * Used by ant to handle the nested entryPoint element.
- *
- * @return an EntryPointsSection instance
- */
- public EntryPointsSection createEntryPoints() {
- if ( this.entryPointsSection != null ) {
- throw new IllegalArgumentException( "Only one entrypoints or expose element allowed!" );
- }
- this.entryPointsSection = newEntryPointsSection( this );
- return entryPointsSection;
- }
-
- /**
- * Instantiates the nested entryPoint element,
- * subclasses may provide custom implementations.
- *
- * @return a new EntryPointsSection instance
- */
- protected EntryPointsSection newEntryPointsSection( YGuardBaseTask bt ) {
- return new EntryPointsSection( bt );
- }
-
- /**
- * not for ant, used if the ShrinkTask is created 'artificially'.
- *
- * @param eps the eps
- */
- public void setEntryPointsExternally( EntryPointsSection eps ) {
- this.entryPointsSection = eps;
- }
-
- /**
- * Create expose entry points section.
- *
- * @return the entry points section
- */
- public EntryPointsSection createExpose() {
- return createEntryPoints();
- }
-
- public Exclude createKeep() {
- return createExpose();
- }
-
- public void addAttributesSections( List attributesSections ) {
- if ( null != entryPointsSection ) {
- for ( com.yworks.common.ant.AttributesSection attributesSection : attributesSections ) {
- entryPointsSection.addConfiguredAttribute( attributesSection );
- }
- } else {
- if( null != this.attributesSections ) {
- this.attributesSections.addAll(attributesSections);
- } else {
- this.attributesSections = attributesSections;
- }
- }
- }
-
- /**
- * Add configured entrypointjar.
- *
- * @param entrypointjar the entrypointjar
- */
- public void addConfiguredEntrypointjar( final EntryPointJar entrypointjar ) {
- if ( pairs == null ) pairs = new ArrayList();
- pairs.add( entrypointjar );
- }
-
-
- private static void addAttributesSection(
- final AttributeFilter attributeFilter, final String name
- ) {
- AttributesSection as = new AttributesSection();
- as.setName(name);
- attributeFilter.addAttributesSection(as);
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/filters/AbstractEntryPointFilter.java b/src/main/java/com/yworks/yshrink/ant/filters/AbstractEntryPointFilter.java
deleted file mode 100644
index d20f8ae6..00000000
--- a/src/main/java/com/yworks/yshrink/ant/filters/AbstractEntryPointFilter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.yworks.yshrink.ant.filters;
-
-import com.yworks.yshrink.model.ClassDescriptor;
-import com.yworks.yshrink.model.FieldDescriptor;
-import com.yworks.yshrink.model.MethodDescriptor;
-import com.yworks.yshrink.model.Model;
-
-/**
- * The type Abstract entry point filter.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class AbstractEntryPointFilter implements EntryPointFilter {
-
- public boolean isEntryPointClass( final Model model, final ClassDescriptor cd ) {
- return false;
- }
-
- public boolean isEntryPointMethod( final Model model, final ClassDescriptor cd, final MethodDescriptor md ) {
- return false;
- }
-
- public boolean isEntryPointField( final Model model, final ClassDescriptor cd, final FieldDescriptor fd ) {
- return false;
- }
-
- public void setRetainAttribute( final ClassDescriptor cd ) {
- //
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/filters/AllMainMethodsFilter.java b/src/main/java/com/yworks/yshrink/ant/filters/AllMainMethodsFilter.java
deleted file mode 100644
index ebfeb1a1..00000000
--- a/src/main/java/com/yworks/yshrink/ant/filters/AllMainMethodsFilter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.yworks.yshrink.ant.filters;
-
-import com.yworks.yshrink.model.ClassDescriptor;
-import com.yworks.yshrink.model.MethodDescriptor;
-import com.yworks.yshrink.model.Model;
-import com.yworks.logging.Logger;
-
-/**
- * marks all main methods as entry points
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class AllMainMethodsFilter extends AbstractEntryPointFilter {
-
- /**
- * The Main desc.
- */
- static String MAIN_DESC = "([Ljava/lang/String;)V";
-
- @Override
- public boolean isEntryPointMethod( final Model model, final ClassDescriptor cd, final MethodDescriptor md ) {
-
- if ( "main".equals( md.getName() ) ) {
- Logger.log( "MainMethodFilter: main found in " + cd.getName() );
- return true;
- } else {
- return false;
- }
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/filters/AttributeFilter.java b/src/main/java/com/yworks/yshrink/ant/filters/AttributeFilter.java
deleted file mode 100644
index c5faeb3a..00000000
--- a/src/main/java/com/yworks/yshrink/ant/filters/AttributeFilter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.yworks.yshrink.ant.filters;
-
-import com.yworks.common.ant.AttributesSection;
-import com.yworks.yshrink.model.ClassDescriptor;
-import com.yworks.yshrink.util.Util;
-import com.yworks.common.ant.TypePatternSet;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import org.apache.tools.ant.Project;
-
-/**
- * The type Attribute filter.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class AttributeFilter extends PatternMatchedFilter {
-
- private List sections = new ArrayList( );
-
- /**
- * Instantiates a new Attribute filter.
- *
- * @param p the p
- */
- public AttributeFilter( Project p ) {
- super( p );
- }
-
- /**
- * Add attributes section.
- *
- * @param as the as
- */
- public void addAttributesSection( AttributesSection as ) {
- sections.add( as );
- }
-
- public void setRetainAttribute( ClassDescriptor cd ) {
-
- String className = cd.getName();
- String javaClassName = Util.toJavaClass( cd.getName() );
-
- for ( AttributesSection section : sections ) {
- if ( match( TypePatternSet.Type.NAME, javaClassName, section ) ||
- match( TypePatternSet.Type.NAME, className, section ) ) {
-
- for ( String attr : section.getAttributes() ) {
- cd.setRetainAttribute( attr );
- }
- }
- }
- }
-
-
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/filters/ClassFilter.java b/src/main/java/com/yworks/yshrink/ant/filters/ClassFilter.java
deleted file mode 100644
index 93542c54..00000000
--- a/src/main/java/com/yworks/yshrink/ant/filters/ClassFilter.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package com.yworks.yshrink.ant.filters;
-
-import com.yworks.common.ant.PatternMatchedSection;
-import com.yworks.common.ant.TypePatternSet;
-import com.yworks.yshrink.ant.ClassSection;
-import com.yworks.yshrink.model.ClassDescriptor;
-import com.yworks.yshrink.model.FieldDescriptor;
-import com.yworks.yshrink.model.MethodDescriptor;
-import com.yworks.yshrink.model.Model;
-import com.yworks.yshrink.util.Util;
-import org.apache.tools.ant.Project;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * The type Class filter.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class ClassFilter extends PatternMatchedFilter {
-
- private List sections;
-
- /**
- * Instantiates a new Class filter.
- *
- * @param project the project
- */
- public ClassFilter( Project project ) {
- super( project );
- }
-
- @Override
- public boolean isEntryPointClass( final Model model, final ClassDescriptor cd ) {
- boolean r = false;
- for ( ClassSection cs : sections ) {
- if (matches(cs, model, cd)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean matches( final ClassSection cs, final Model model, final ClassDescriptor cd ) {
-
- String className = cd.getName();
-
- boolean r = true;
-
- // name, access
-// r &= isEntryPointClass( model, cd );
-
- // access
- if ( null != cs.getClassAccess() && ( cs.getName() == null || cs.getName() == "" ) && ( !cs.getClassAccess().equals( PatternMatchedSection.Access.NONE ) ) )
- {
- r &= cs.getClassAccess().isAccessLevel( cd.getAccess() );
- }
-
- // name
- String entryClassName = cs.getName();
- if ( null == entryClassName || entryClassName.length() == 0 ) {
- r &= ( match( TypePatternSet.Type.NAME, Util.toJavaClass( className ), cs )
- ||
- match( TypePatternSet.Type.NAME, className, cs ) );
- } else {
- r &= entryClassName.equals( className );
- }
-
- // extends
- if ( null != cs.getExtends() ) {
- boolean self = cs.getExtends().equals( cd.getName() );
- if ( !self ) {
- Collection ancestors = cd.getAllAncestorClasses( model );
- r &= ancestors.contains( cs.getExtends() );
- } else {
- r &= self;
- }
- }
-
- // implements
- if ( null != cs.getImplements() ) {
- boolean self = cs.getImplements().equals( cd.getName() );
- if ( !self ) {
- Collection interfaces = cd.getAllImplementedInterfaces( model );
- r &= interfaces.contains( cs.getImplements() );
- } else {
- r &= self;
- }
- }
-
- return r;
- }
-
- private List getAllMatchingClassSections( final Model model, final ClassDescriptor cd ) {
-
- List matchingSections = new ArrayList();
-
- for ( ClassSection cs : sections ) {
- if ( matches( cs, model, cd ) ) {
- matchingSections.add( cs );
- }
- }
-
- return matchingSections;
- }
-
- @Override
- public boolean isEntryPointField( final Model model, final ClassDescriptor cd, final FieldDescriptor fd ) {
-
- for ( ClassSection cs : getAllMatchingClassSections( model, cd ) ) {
-
- boolean r = false;
-
- PatternMatchedSection.Access acc = cs.getFieldAccess();
- if ( null != acc ) {
- r = acc.isAccessLevel( fd.getAccess() );
- }
-
- if ( r ) {
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public boolean isEntryPointMethod( final Model model, final ClassDescriptor cd, final MethodDescriptor md ) {
-
- for ( ClassSection cs : getAllMatchingClassSections( model, cd ) ) {
-
- boolean r = true;
-
- PatternMatchedSection.Access acc = cs.getMethodAccess();
- if ( null != acc ) {
- r = r && acc.isAccessLevel( md.getAccess() );
- }
-
- if ( r ) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Add class section.
- *
- * @param cs the cs
- */
- public void addClassSection( ClassSection cs ) {
- if ( null == sections ) {
- sections = new ArrayList( 5 );
- }
- sections.add( cs );
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/filters/EntryPointFilter.java b/src/main/java/com/yworks/yshrink/ant/filters/EntryPointFilter.java
deleted file mode 100644
index 3d3acddc..00000000
--- a/src/main/java/com/yworks/yshrink/ant/filters/EntryPointFilter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.yworks.yshrink.ant.filters;
-
-import com.yworks.yshrink.model.ClassDescriptor;
-import com.yworks.yshrink.model.FieldDescriptor;
-import com.yworks.yshrink.model.MethodDescriptor;
-import com.yworks.yshrink.model.Model;
-
-/**
- * The interface Entry point filter.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public interface EntryPointFilter {
-
- /**
- * Is entry point class boolean.
- *
- * @param model the model
- * @param cd the cd
- * @return the boolean
- */
- public boolean isEntryPointClass( final Model model, final ClassDescriptor cd );
-
- /**
- * Is entry point method boolean.
- *
- * @param model the model
- * @param cd the cd
- * @param md the md
- * @return the boolean
- */
- public boolean isEntryPointMethod( final Model model, final ClassDescriptor cd, final MethodDescriptor md );
-
- /**
- * Is entry point field boolean.
- *
- * @param model the model
- * @param cd the cd
- * @param fd the fd
- * @return the boolean
- */
- public boolean isEntryPointField( final Model model, final ClassDescriptor cd, final FieldDescriptor fd );
-
- /**
- * Sets retain attribute.
- *
- * @param cd the cd
- */
- public void setRetainAttribute( final ClassDescriptor cd );
-
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/filters/EntryPointFilters.java b/src/main/java/com/yworks/yshrink/ant/filters/EntryPointFilters.java
deleted file mode 100644
index 7b0a8579..00000000
--- a/src/main/java/com/yworks/yshrink/ant/filters/EntryPointFilters.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.yworks.yshrink.ant.filters;
-
-import com.yworks.common.ant.Exclude;
-import com.yworks.yshrink.model.ClassDescriptor;
-import com.yworks.yshrink.model.FieldDescriptor;
-import com.yworks.yshrink.model.MethodDescriptor;
-import com.yworks.yshrink.model.Model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The type Entry point filters.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class EntryPointFilters extends AbstractEntryPointFilter {
-
- /**
- * The Filters.
- */
- List filters;
-
- private Exclude exclude;
-
- /**
- * Instantiates a new Entry point filters.
- */
- public EntryPointFilters() {
- this.filters = new ArrayList();
- }
-
- /**
- * Sets exclude.
- *
- * @param exclude the exclude
- */
- public void setExclude( Exclude exclude ) {
- this.exclude = exclude;
- }
-
- /**
- * Add entry point filter.
- *
- * @param entryPointFilter the entry point filter
- */
- public void addEntryPointFilter( final EntryPointFilter entryPointFilter ) {
- filters.add( entryPointFilter );
- }
-
- public boolean isEntryPointClass( final Model model, final ClassDescriptor cd ) {
- for ( EntryPointFilter entryPointFilter : filters ) {
- if ( entryPointFilter.isEntryPointClass( model, cd ) ) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isEntryPointMethod( final Model model, final ClassDescriptor cd, final MethodDescriptor md ) {
- for ( EntryPointFilter entryPointFilter : filters ) {
- if ( entryPointFilter.isEntryPointMethod( model, cd, md ) ) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isEntryPointField( final Model model, final ClassDescriptor cd, final FieldDescriptor fd ) {
- for ( EntryPointFilter entryPointFilter : filters ) {
- if ( entryPointFilter.isEntryPointField( model, cd, fd ) ) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public void setRetainAttribute( final ClassDescriptor cd ) {
- for ( EntryPointFilter entryPointFilter : filters ) {
- entryPointFilter.setRetainAttribute( cd );
- }
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/filters/EntryPointJarFilter.java b/src/main/java/com/yworks/yshrink/ant/filters/EntryPointJarFilter.java
deleted file mode 100644
index c5126e39..00000000
--- a/src/main/java/com/yworks/yshrink/ant/filters/EntryPointJarFilter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.yworks.yshrink.ant.filters;
-
-import com.yworks.common.ant.EntryPointJar;
-import com.yworks.yshrink.model.ClassDescriptor;
-import com.yworks.yshrink.model.FieldDescriptor;
-import com.yworks.yshrink.model.MethodDescriptor;
-import com.yworks.yshrink.model.Model;
-
-/**
- * The type Entry point jar filter.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class EntryPointJarFilter extends AbstractEntryPointFilter {
-
- private final EntryPointJar entryPointJar;
-
- /**
- * Instantiates a new Entry point jar filter.
- *
- * @param entryPointJar the entry point jar
- */
- public EntryPointJarFilter( EntryPointJar entryPointJar ) {
- this.entryPointJar = entryPointJar;
- }
-
- @Override
- public boolean isEntryPointClass( final Model model, final ClassDescriptor cd ) {
- return cd.getSourceJar().equals( entryPointJar.getIn() );
- }
-
- @Override
- public boolean isEntryPointMethod( final Model model, final ClassDescriptor cd, final MethodDescriptor md ) {
- return md.getSourceJar().equals( entryPointJar.getIn() );
- }
-
- @Override
- public boolean isEntryPointField( final Model model, final ClassDescriptor cd, final FieldDescriptor fd ) {
- return fd.getSourceJar().equals( entryPointJar.getIn() );
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/filters/FieldFilter.java b/src/main/java/com/yworks/yshrink/ant/filters/FieldFilter.java
deleted file mode 100644
index 63d4964e..00000000
--- a/src/main/java/com/yworks/yshrink/ant/filters/FieldFilter.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package com.yworks.yshrink.ant.filters;
-
-import com.yworks.common.ant.TypePatternSet;
-import com.yworks.yshrink.ant.FieldSection;
-import com.yworks.yshrink.model.ClassDescriptor;
-import com.yworks.yshrink.model.FieldDescriptor;
-import com.yworks.yshrink.model.Model;
-import com.yworks.yshrink.util.Util;
-import org.apache.tools.ant.Project;
-import org.objectweb.asm.Type;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The type Field filter.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class FieldFilter extends PatternMatchedFilter {
-
- private List sections;
-
- /**
- * Instantiates a new Field filter.
- *
- * @param project the project
- */
- public FieldFilter( final Project project ) {
- super( project );
- }
-
- /**
- * Add field section.
- *
- * @param fieldSection the field section
- */
- public void addFieldSection( FieldSection fieldSection ) {
- if ( null == sections ) {
- sections = new ArrayList( 5 );
- }
- sections.add( fieldSection );
- }
-
- @Override
- public boolean isEntryPointField( final Model model, final ClassDescriptor cd, final FieldDescriptor fd ) {
-
- String className = cd.getName();
- String fieldName = fd.getName();
-
- for ( FieldSection fs : sections ) {
-
- boolean r = true;
-
- String entryFieldClass = fs.getClassName();
- String entryFieldName = fs.getName();
-
- // type
- if ( null != fs.getType() ) {
- Type requiredType = Type.getType( Util.verboseToNativeType( fs.getType() ) );
- r &= ( requiredType.equals( fd.getDesc() ) );
- }
-
- // access
- if ( null != fs.getAccess() ) {
- r &= fs.getAccess().isAccessLevel( fd.getAccess() );
- }
-
- // class
- if ( null == entryFieldClass || entryFieldClass.length() == 0 ) {
- r &= match( TypePatternSet.Type.CLASS, className, fs ) ||
- match( TypePatternSet.Type.CLASS, Util.toJavaClass( className ), fs );
- } else {
- r &= entryFieldClass.equals( className );
- }
-
- // name
- if ( null == entryFieldName || entryFieldName.length() == 0 ) {
- r &= match( TypePatternSet.Type.NAME, fieldName, fs );
- } else {
- r &= entryFieldName.equals( fieldName );
- }
-
- if ( r ) {
- return r;
- }
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/filters/MethodFilter.java b/src/main/java/com/yworks/yshrink/ant/filters/MethodFilter.java
deleted file mode 100644
index f7f6e0e4..00000000
--- a/src/main/java/com/yworks/yshrink/ant/filters/MethodFilter.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package com.yworks.yshrink.ant.filters;
-
-import com.yworks.common.ant.TypePatternSet;
-import com.yworks.yshrink.ant.MethodSection;
-import com.yworks.yshrink.model.ClassDescriptor;
-import com.yworks.yshrink.model.MethodDescriptor;
-import com.yworks.yshrink.model.Model;
-import com.yworks.yshrink.util.Util;
-import org.apache.tools.ant.Project;
-import org.objectweb.asm.Type;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * The type Method filter.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class MethodFilter extends PatternMatchedFilter {
-
- private List sections;
-
- /**
- * Instantiates a new Method filter.
- *
- * @param project the project
- */
- public MethodFilter( Project project ) {
- super( project );
- }
-
- /**
- * Add method section.
- *
- * @param methodSection the method section
- */
- public void addMethodSection( MethodSection methodSection ) {
- if ( null == sections ) {
- sections = new ArrayList( 5 );
- }
- sections.add( methodSection );
- }
-
- @Override
- public boolean isEntryPointMethod( final Model model, final ClassDescriptor cd, final MethodDescriptor md ) {
-
- String className = cd.getName();
- String methodName = md.getName();
-
- for ( MethodSection ms : sections ) {
-
- String entryMethodName = ms.getName();
- String entryMethodClass = ms.getClassName();
-
- boolean r = true;
-
- // returnType
- if ( null != ms.getReturnType() ) {
- Type requiredReturnType = Type.getType( Util.verboseToNativeType( ms.getReturnType() ) );
- r &= ( requiredReturnType.equals( md.getReturnType() ) );
- }
-
- // arguments
- if ( null != ms.getArgs() ) {
- String[] requiredArgTypes = ms.getArgs().split( "\\s*,\\s*" );
- if ( requiredArgTypes.length == 1 && requiredArgTypes[ 0 ].length() == 0 ) { // args=""
- requiredArgTypes = new String[0];
- }
- Type[] argTypes = md.getArgumentTypes();
-
- if ( requiredArgTypes.length == argTypes.length ) {
- for ( int i = 0; i < argTypes.length; i++ ) {
- Type argType = argTypes[ i ];
- Type requiredArgType = Type.getType( Util.verboseToNativeType( requiredArgTypes[ i ].trim() ) );
-
- r &= argType.equals( requiredArgType );
- }
- } else {
- r = false;
- }
- }
-
- // access
- if ( null != ms.getAccess() ) {
- r &= ms.getAccess().isAccessLevel( md.getAccess() );
- }
-
- // class
- if ( null == entryMethodClass || entryMethodClass.length() == 0 ) {
- r &= match( TypePatternSet.Type.CLASS, className, ms ) ||
- match( TypePatternSet.Type.CLASS, Util.toJavaClass( className ), ms );
- } else {
- r &= entryMethodClass.equals( className );
- }
-
- // throws
- if ( null != ms.getThrows() ) {
-
- StringTokenizer tokenizer = new StringTokenizer( ms.getThrows(), "," );
-
- while ( tokenizer.hasMoreTokens() ) {
- String exception = Util.toInternalClass( tokenizer.nextToken().trim() );
-
-
-
- boolean found = false;
-
- if ( null != md.getExceptions() ) {
- for ( String exception2 : md.getExceptions() ) {
- if ( exception2.equals( exception ) ) {
- found = true;
- }
- }
- }
-
- r &= found;
-
- }
- }
-
- // name
- if ( null == entryMethodName || entryMethodName.length() == 0 ) {
- r &= match( TypePatternSet.Type.NAME, methodName, ms );
- } else {
- r &= entryMethodName.equals( methodName );
- }
-
- if ( r ) {
- return r;
- }
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/filters/PatternMatchedFilter.java b/src/main/java/com/yworks/yshrink/ant/filters/PatternMatchedFilter.java
deleted file mode 100644
index d5b835dd..00000000
--- a/src/main/java/com/yworks/yshrink/ant/filters/PatternMatchedFilter.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.yworks.yshrink.ant.filters;
-
-import com.yworks.common.ant.TypePatternSet;
-import com.yworks.common.ant.PatternMatchedSection;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.PatternSet;
-import org.apache.tools.ant.types.selectors.SelectorUtils;
-
-/**
- * The type Pattern matched filter.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class PatternMatchedFilter extends AbstractEntryPointFilter {
-
- private Project project;
-
- /**
- * Instantiates a new Pattern matched filter.
- *
- * @param p the p
- */
- public PatternMatchedFilter( final Project p ) {
- project = p;
- }
-
- /**
- * Match boolean.
- *
- * @param type the type
- * @param str the str
- * @param section the section
- * @return the boolean
- */
- protected boolean match( TypePatternSet.Type type, String str, PatternMatchedSection section ) {
-
- PatternSet patternSet = section.getPatternSet( type );
-
- if ( patternSet != null ) {
-
- String[] excludePatterns = patternSet.getExcludePatterns( project );
- if ( null != excludePatterns ) {
- for ( String excludePattern : excludePatterns ) {
- if ( SelectorUtils.match( excludePattern, str ) ) {
- return false;
- }
- }
- }
-
- String[] includePatterns = patternSet.getIncludePatterns( project );
- if ( null != includePatterns ) {
- for ( String includePattern : includePatterns ) {
- if ( SelectorUtils.match( includePattern, str ) ) {
- return true;
- }
- }
- } else {
- return true; // no include given: include all
- }
- } else {
- return true; // no patternset for type given: include all
- }
- return false; // str wasnt contained in includes / excludes
- }
-
-
-}
diff --git a/src/main/java/com/yworks/yshrink/ant/filters/SerializationFilter.java b/src/main/java/com/yworks/yshrink/ant/filters/SerializationFilter.java
deleted file mode 100644
index e9d9ae25..00000000
--- a/src/main/java/com/yworks/yshrink/ant/filters/SerializationFilter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.yworks.yshrink.ant.filters;
-
-import org.apache.tools.ant.Project;
-import com.yworks.yshrink.ant.MethodSection;
-import com.yworks.yshrink.model.Model;
-import com.yworks.yshrink.model.ClassDescriptor;
-import com.yworks.yshrink.model.MethodDescriptor;
-
-import java.util.Collection;
-
-/**
- * The type Serialization filter.
- *
- * @author Michael Schroeder, yWorks GmbH http://www.yworks.com
- */
-public class SerializationFilter extends MethodFilter {
-
- /**
- * Instantiates a new Serialization filter.
- *
- * @param project the project
- */
- public SerializationFilter( Project project ) {
- super( project );
-
- MethodSection msWrite = new MethodSection();
- msWrite.setSignature( "void writeObject(java.io.ObjectOutputStream)" );
- msWrite.setAccess( "private" );
- addMethodSection( msWrite );
-
- MethodSection msRead = new MethodSection();
- msRead.setSignature( "void readObject(java.io.ObjectInputStream)" );
- msRead.setAccess( "private" );
- addMethodSection( msRead );
-
- }
-
- @Override
- public boolean isEntryPointMethod( final Model model, final ClassDescriptor cd, final MethodDescriptor md ) {
-
- boolean r = false;
-
- Collection interfaces = cd.getAllImplementedInterfaces( model );
- if ( interfaces.contains( "java/io/Serializable" ) ) {
- r = true;
- }
-
- return r && super.isEntryPointMethod( model, cd, md );
- }
-}
diff --git a/src/main/java/com/yworks/yshrink/core/Analyzer.java b/src/main/java/com/yworks/yshrink/core/Analyzer.java
index 66dcdb49..163ee600 100644
--- a/src/main/java/com/yworks/yshrink/core/Analyzer.java
+++ b/src/main/java/com/yworks/yshrink/core/Analyzer.java
@@ -41,16 +41,6 @@ public class Analyzer {
private static final String SYNTHETIC_DOT_CLASS_FIELD_START = "class$";
private static final String CLASS_DESC = "Ljava/lang/Class;";
- /**
- * Create edges.
- *
- * @param model the model
- */
- public void createEdges( Model model ) {
- createInheritanceEdges( model );
- createDependencyEdges( model );
- }
-
/**
* Create all nodes needed for dependency analysis using a ModelVisitor. Also creates artificial
* <clinit> nodes for each (non-inner) class if not already present.
@@ -159,100 +149,6 @@ public void createInheritanceEdges( final Model model ) {
model.setSimpleModelSet();
}
- /**
- * Create all kinds of dependency edges for the whole model.
- *
- * @param model the model
- */
- public void createDependencyEdges( final Model model ) {
-
- for ( ClassDescriptor cd : model.getAllClassDescriptors() ) {
-
- createAnnotationEdges(cd, model);
-
- model.createDependencyEdge( cd.getNewNode(), cd.getNode(), EdgeType.MEMBER_OF );
-
- createInnerClassEdges( model, cd );
- createAssumeEdges( model, cd );
-
- for ( MethodDescriptor md : cd.getMethods() ) {
-
- createAnnotationEdges(md, model);
-
- model.createDependencyEdge( md, cd, EdgeType.MEMBER_OF );
-
- createReferenceEdges( model, md );
- createMethodSignatureEdges( model, md );
- createInvokeEdges( model, cd, md );
- createTypeInstructionEdges( model, md );
- }
- for ( FieldDescriptor fd : cd.getFields() ) {
- createAnnotationEdges(fd, model);
- model.createDependencyEdge( fd, cd, EdgeType.MEMBER_OF );
-
- // resolve edge for field type
- // not required for verification, but obfuscator will complain if the type is not found.
- String fieldTypeName = Util.getTypeNameFromDescriptor(fd.getDesc());
- if (model.isClassModeled(fieldTypeName)) {
- ClassDescriptor fieldType = model.getClassDescriptor(fieldTypeName);
- model.createDependencyEdge(fd, fieldType, EdgeType.RESOLVE);
- }
-
- }
- }
- }
-
- private void createAnnotationEdges(AbstractDescriptor cd, Model model) {
- for (AnnotationUsage annotationUsage : cd.getAnnotations()) {
- if (model.isClassModeled(annotationUsage.getDescriptor())) {
- ClassDescriptor annotationClassDescriptor = model.getClassDescriptor(annotationUsage.getDescriptor());
- model.createDependencyEdge(cd, annotationClassDescriptor, EdgeType.REFERENCES);
-
- for (String field : annotationUsage.getFieldUsages()) {
- for (MethodDescriptor methodDescriptor : annotationClassDescriptor.getMethods()) {
- if (methodDescriptor.getName().equals(field)) {
- model.createDependencyEdge(cd, methodDescriptor, EdgeType.RESOLVE);
- break;
- }
- }
- }
- }
- }
- }
-
- /**
- * Create RESOLVE edges from md to the runtime type of type instructions ANEWARRAY, MULTIANEWARRAY,
- * INSTANCEOF, CHECKCAST and LDC (if class version >= 49.0). Create CREATES edges for NEW instructions from
- * md to the NEW-node of the given runtime type.
- */
- private void createTypeInstructionEdges( final Model model, final MethodDescriptor md ) {
- for ( AbstractMap.SimpleEntry