Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
#65
Browse files Browse the repository at this point in the history
  • Loading branch information
4ra1n committed Jan 22, 2023
1 parent b8ddaf9 commit c3b300c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Others:

小更新,修改并重新编译某些依赖库代码以支持`Java 8- Java 19`所有版本

加入了简单的表达式搜素(beta)功能:
加入了简单的表达式搜索(beta)功能:

```java
#method
Expand Down Expand Up @@ -168,3 +168,5 @@ Others:
- [important] 解决在非JDK11-14中字体的BUG #64
- [important] 支持拖入Jar文件加载 #61
- [important] 表达式搜索 #62
- [important] 方法精确定位算法优化 #65
- [improve] 方法定位算法优化 #65
5 changes: 2 additions & 3 deletions build/build-nojre.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
<path>%JAVA_HOME%;%PATH%</path>
<requiresJdk>false</requiresJdk>
<requires64Bit>false</requires64Bit>
<minVersion>11</minVersion>
<maxVersion>14</maxVersion>
<opt>--add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED</opt>
<minVersion>1.8</minVersion>
<maxVersion>19</maxVersion>
</jre>
</launch4jConfig>
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

<repositories>
<repository>
<id>local</id>
<name>local</name>
<id>my-local-lib</id>
<name>my-local-lib</name>
<url>file://${basedir}/lib</url>
</repository>
<repository>
Expand Down Expand Up @@ -91,6 +91,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>initialize</phase>
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/chaitin/jar/analyzer/form/JarAnalyzerForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,14 @@ public int find(String total, String methodName, int paramNum) {
// 认为找到的方法的定义
if (total.charAt(i - 1) == ' ' &&
total.charAt(i + methodName.length()) == '(') {
// 前第二位是空格这是方法调用
if (i - 2 > 0 && total.charAt(i - 2) == ' ') {
continue;
}
int curNum = 1;
List<Character> temp = new ArrayList<>();
for (int j = i + methodName.length() + 1; ; j++) {
temp.add(total.charAt(j));
// 遇到结尾
if (total.charAt(j) == ')') {
// 参数为0个的情况
Expand All @@ -862,6 +868,28 @@ public int find(String total, String methodName, int paramNum) {
// 参数匹配认为找到了
if (curNum == paramNum) {
return i;
} else {
if (paramNum > curNum) {
int atNum = 0;
int rightNum = -1;
for (Character character : temp) {
if (character == '@') {
atNum++;
}
if (character == ')') {
rightNum++;
}
}
if (atNum == 0) {
break;
} else {
if (rightNum == atNum) {
return i;
} else if (atNum > rightNum) {
continue;
}
}
}
}
break;
} else if (total.charAt(j) == ',') {
Expand Down

0 comments on commit c3b300c

Please sign in to comment.