资讯专栏INFORMATION COLUMN

replace java.lang.String.equals by Xbootclasspath

jzman / 3458人阅读

摘要:

env:
os:ubuntu 16.04 x64
openjdk8u

</>复制代码

  1. //java.lang.String
  2. package java.lang;
  3. import java.lang.StringDebugHelper;
  4. //...
  5. public final class String{
  6. final char value[];//remove private
  7. public boolean equals(Object anObject) {
  8. if (this == anObject) {
  9. return true;
  10. }
  11. if (anObject instanceof String) {
  12. // {replace begin
  13. String anotherString = (String)anObject;
  14. if(StringDebugHelper.Equals.isInAttention(this) || StringDebugHelper.Equals.isInAttention(anotherString)){
  15. //new Throwable().getStackTrace();//not crash
  16. //System.out.println("xxxxx");//not crash
  17. new Throwable("attention:"+this).printStackTrace();
  18. }
  19. //Thread.currentThread().getStackTrace();//crash
  20. //new Throwable().getStackTrace();//crash
  21. //new Exception("uuuuuuuuuu");//crash
  22. //new String("ffffdxx");//not crash
  23. //System.out.println("xxxxx");//crash
  24. int n = value.length;
  25. return StringDebugHelper.Equals.equals(this.value, anotherString.value);
  26. //replace end}
  27. }
  28. return false;
  29. }
  30. }

</>复制代码

  1. package java.lang;
  2. //import java.util.Set;
  3. public class StringDebugHelper{
  4. public static class Equals{
  5. public static String[] attention;
  6. public static boolean isInAttention(final String str){
  7. if(attention==null) return false;
  8. for(int i = 0; i < attention.length; i++){
  9. if(null != attention[i] && StringDebugHelper.Equals.equals(attention[i].value, str.value))
  10. return true;
  11. }
  12. return false;
  13. }
  14. public static boolean equals(final char [] thiz,final char [] anotherString) {
  15. int n = thiz.length;
  16. if (n == anotherString.length) {
  17. char v1[] = thiz;
  18. char v2[] = anotherString;
  19. int i = 0;
  20. while (n-- != 0) {
  21. if (v1[i] != v2[i])
  22. return false;
  23. i++;
  24. }
  25. return true;
  26. }
  27. return false;
  28. }
  29. }
  30. }

</>复制代码

  1. import java.util.HashSet;
  2. import java.util.Set;
  3. public class StringDebugHelperTest{
  4. public static void main(String[] args){
  5. // to this before boot app {
  6. String[] st = new String[5];
  7. st[0] = "java";
  8. st[1] = "tsogvilin";
  9. StringDebugHelper.Equals.attention = st;
  10. // }
  11. // app content:
  12. //"java".equals(new String("java"));
  13. "tsogvilin".equals(new String("tsogvilin"));
  14. }
  15. }

</>复制代码

  1. #compile
  2. javac -sourcepath main/src/ -d main/classes/ main/src/*.java
  3. javac -Xbootclasspath/p:main/classes -d test/classes/ test/src/*.java
  4. #run
  5. java -Xbootclasspath/p:main/classes -cp test/classes T
  6. java -Xbootclasspath/p:main/classes -cp test/classes StringDebugHelperTest

real exmaple :apktool:

</>复制代码

  1. #replace javac cmd:
  2. mv /usr/lib/jvm/java-8-openjdk-amd64/bin/javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac.real
  3. cat /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
  4. #!/bin/sh
  5. /usr/lib/jvm/java-8-openjdk-amd64/bin/javac.real -Xbootclasspath/p:/home/z/hg_openjdk_java_net/jdk8u_jdk8u/str.eq.dbg/main/classes/ "$@"

</>复制代码

  1. Apktool/build.gradle:
  2. tasks.withType(JavaCompile) {
  3. options.compilerArgs += ["-Xlint:-options"]
  4. // add this:
  5. options.bootClasspath = "/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar:/home/z/hg_openjdk_java_net/jdk8u_jdk8u/str.eq.dbg/main/classes/" //add this
  6. }

</>复制代码

  1. //Apktool/brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java:
  2. // to this before boot app {
  3. String[] st = new String[1];
  4. st[0] = "resources.arsc";
  5. //st[1] = "tsogvilin";
  6. StringDebugHelper.Equals.attention = st;
  7. System.out.println("rrrrrrrrrrrrrrrrrr");
  8. // }

</>复制代码

  1. java -Xbootclasspath/p:main/classes -cp /home/z/a/Apktool/brut.apktool/apktool-cli/build/libs/apktool-cli-all.jar -Duser.language=en -Dfile.encoding=UTF8 brut.apktool.Main d ~/a/game.v182815.apk -o ~/a/myoutdir

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/73154.html

相关文章

  • Java语法糖的编译结果分析(二)

    摘要:因此,对应地我们可以翻译这段二进制字节码为这样的代码注意,这段代码并不能通过编译,因为源码这一层是不允许直接继承的,这个继承过程只允许在编译器内部解语法糖的过程中被编译器添加,添加之后的类才会有的访问标识符。 语法糖(Syntactic Sugar)的出现是为了降低我们编写某些代码时陷入的重复或繁琐,这使得我们使用语法糖后可以写出简明而优雅的代码。在Java中不加工的语法糖代码运行时可...

    LeviDing 评论0 收藏0
  • 手写Spring之DI依赖注入

    摘要:如感兴趣,可移步手写之基于动态创建对象手写之基于注解动态创建对象今天将详细介绍如何手写依赖注入,在运行过程中如何动态地为对象的属性赋值。完成后在中会有相关的包出现进行注入前需要创建工厂,在运行时从工厂中取出对象为属性赋值。 前两篇文章介绍了关于手写Spring IOC控制反转,由Spring工厂在运行过程中动态地创建对象的两种方式。如感兴趣,可移步: 手写Spring之IOC基于xml...

    Cruise_Chan 评论0 收藏0
  • 手写Spring之IOC基于注解动态创建对象

    摘要:上一篇博客介绍了如何基于配置文件在运行时创建实例对象,这篇博客将介绍基于注解方式怎样实现对象的创建。方便测试,该类型分别创建两个单例和多例的类型。注意这种为对象注入属性值的方式耦合度较高,可根据情况使用。 上一篇博客介绍了如何基于xml配置文件在运行时创建实例对象,这篇博客将介绍基于注解方式怎样实现对象的创建。 废话不多说,直接上代码。 首先还是创建项目,由于这次不需要使用第三方的AP...

    Andrman 评论0 收藏0
  • 手写Spring之IOC基于xml动态创建对象

    Spring作为Java Web最为流行的框架之一,其功能之强大,封装细节之全面不用过多赘述。使用Spring的方式很简单,不需要关注细节,把对象的创建和对象之间的关系都交给框架来管理,仅仅做好配置文件和实现具体的业务逻辑即可。可以说Spring为我们在编写Java Web应用时省去了大量重复的代码,并且可以降低对象与对象之间的耦合度。但若只是知其然,而不知其所以然,在编程时也难免会遇到各种问题,...

    monw3c 评论0 收藏0
  • IntelliJ IDEA 2017.1 JDK 8 性能调优

    IntelliJ IDEA 问题描述 IntelliJ IDEA 在 多窗口、多项目协作开发时,MacBook Pro的散热风扇凶猛地转动,相关配置如下: MacBook Pro 配置 MacBook Pro (Retina, 15-inch, Mid 2015) 型号名称: MacBook Pro 型号标识符: MacBookPro11,4 处理器名称: Intel Core ...

    RobinQu 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<