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

Commit

Permalink
#83
Browse files Browse the repository at this point in the history
  • Loading branch information
4ra1n committed Feb 8, 2023
1 parent 3241fce commit aa75a01
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,5 @@ Others:

## 1.1

todo
更新内容:
- [improve] 限制JAR包大小防止加载过多过大的文件 #83
4 changes: 3 additions & 1 deletion src/main/java/com/chaitin/jar/analyzer/form/CommonForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<children>
<scrollpane id="21799" binding="commonScroll">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="1" use-parent-layout="false">
<minimum-size width="800" height="500"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void mouseClicked(MouseEvent evt) {
commonPanel = new JPanel();
commonPanel.setLayout(new GridLayoutManager(2, 1, new Insets(5, 5, 5, 5), -1, -1));
commonScroll = new JScrollPane();
commonPanel.add(commonScroll, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
commonPanel.add(commonScroll, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, new Dimension(800, 500), null, null, 1, false));
commonTable = new JTable();
commonTable.setEnabled(true);
commonScroll.setViewportView(commonTable);
Expand Down
25 changes: 25 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 @@ -152,7 +152,26 @@ public class JarAnalyzerForm {
}
}

private boolean checkJarSize() {
try {
int total = 0;
for (String path : jarPathList) {
Path cPath = Paths.get(path);
int mb = (int) (Files.size(cPath) / 1024 / 1024);
total += mb;
}
if (total < 300) {
return true;
}
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return false;
}

private void loadJarInternal(String absPath) {
jarPathList.clear();
totalJars++;
progress.setValue(0);
new Thread(() -> {
Expand All @@ -166,6 +185,12 @@ private void loadJarInternal(String absPath) {
} else {
jarPathList.add(absPath);
}

if (!checkJarSize()) {
JOptionPane.showMessageDialog(jarAnalyzerPanel, "输入的Jar包过大");
return;
}

progress.setValue(20);
classFileList.addAll(CoreUtil.getAllClassesFromJars(jarPathList));

Expand Down

0 comments on commit aa75a01

Please sign in to comment.