Skip to content

Conversation

@RemiNVG
Copy link

@RemiNVG RemiNVG commented May 24, 2022

No description provided.

RemiNVG added 2 commits May 24, 2022 12:54
The project would currently not build at all, as it already uses
1.7 features like the diamond operator.

Update to 1.8 so the project can build and reasonably recent features
can be used.
A common use-case for jarjar is to have rule with the format
my.package.name.**, or even my.package.name.MyClass with no wildcards.
Jarjar will convert that pattern to a regular expression and do regular
expression matching on every symbol it scans to determine if the rule
matches. This is very inefficient as most symbols will not match, and a
simple prefix match can rule out the match in most cases.

When parsing rules, extract the plain-text prefix of each rule, which is
everything before the first wildcard. Then index all rules by their
prefix in a prefix trie. This allows:
 - Avoiding slow regular expression matches in most cases, as jarjar
   can immediately observe that there is no matching prefix in the map.
 - Scaling in O(log(n)) with the number of rules when they have distinct
   prefixes (instead of O(n), as a matching prefix can be found from the
   trie instead of looping through all rules.

This was tested to make jarjar faster on the Android codebase (running
all jarjar rules to build a device back-to-back goes from 295s to 270s),
while keeping outputs byte-identical, and providing significant speedups
when many jarjar rules are used.
@SinOverCos
Copy link

SinOverCos commented Sep 7, 2023

@RemiNVG how did you get this to build? mvn package still doesn't work for me:

With your

    <property name="compile.source" value="1.8"/>
    <property name="compile.target" value="1.8"/>

change

Adding:

  <build>
    <sourceDirectory>src/main</sourceDirectory>
  </build>

to pom.xml gets me

~> mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.googlecode.jarjar:jarjar >--------------------
[INFO] Building Jar Jar Links 1.3
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ jarjar ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jarjar ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/tanwang/code/jarjar/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jarjar ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 40 source files to /home/tanwang/code/jarjar/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/AbstractDepHandler.java:[27,56] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/MainProcessor.java:[38,59] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/MainUtil.java:[59,45] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/util/ClassPathIterator.java:[56,52] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/RulesFileParser.java:[43,53] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/PackageRemapper.java:[32,61] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/KeepProcessor.java:[39,52] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/util/StandaloneJarProcessor.java:[37,39] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/DepFind.java:[40,49] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/Wildcard.java:[31,57] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/PatternElement.java:[34,46] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/util/IoUtil.java:[48,9] try-with-resources is not supported in -source 1.5
  (use -source 7 or higher to enable try-with-resources)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/util/IoUtil.java:[70,60] diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
[INFO] 13 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.840 s
[INFO] Finished at: 2023-09-07T15:38:05Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jarjar: Compilation failure: Compilation failure:
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/AbstractDepHandler.java:[27,56] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/MainProcessor.java:[38,59] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/MainUtil.java:[59,45] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/util/ClassPathIterator.java:[56,52] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/RulesFileParser.java:[43,53] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/PackageRemapper.java:[32,61] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/KeepProcessor.java:[39,52] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/util/StandaloneJarProcessor.java:[37,39] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/DepFind.java:[40,49] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/Wildcard.java:[31,57] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/PatternElement.java:[34,46] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/util/IoUtil.java:[48,9] try-with-resources is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable try-with-resources)
[ERROR] /home/tanwang/code/jarjar/src/main/com/tonicsystems/jarjar/util/IoUtil.java:[70,60] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants