Categories:
Audio (13)
Biotech (29)
Bytecode (35)
Database (77)
Framework (7)
Game (7)
General (512)
Graphics (53)
I/O (32)
IDE (2)
JAR Tools (86)
JavaBeans (16)
JDBC (89)
JDK (337)
JSP (20)
Logging (103)
Mail (54)
Messaging (8)
Network (71)
PDF (94)
Report (7)
Scripting (83)
Security (32)
Server (119)
Servlet (17)
SOAP (24)
Testing (50)
Web (19)
XML (301)
Other Resources:
JarAnalyzer Source Code Files
Apache Ant Source Code Files are inside the JarAnalyzer source package
like JarAnalyzer-src-1.2.zip.
Unzip the source package and go to the "src" sub-directory,
you will see source code files.
Here is the list of Java source code files of the JarAnalyzer 1.2 in \Users\fyicenter\JarAnalyzer\src:
✍: FYIcenter.com
⏎ com/kirkk/analyzer/framework/bcel/PackageVisitor.java
package com.kirkk.analyzer.framework.bcel; import org.apache.bcel.classfile.*; import java.util.*; public class PackageVisitor extends EmptyVisitor { private JavaClass javaClass; private ArrayList imports; private ArrayList strings; public PackageVisitor(JavaClass javaClass) { this.javaClass = javaClass; //System.out.println("PackageVisitor constructor: " + javaClass.getClassName()); this.imports = new ArrayList(); this.strings = new ArrayList(); } public void visitConstantClass(ConstantClass cls) { //System.out.println("CONSTANTCLASS: " + cls.getBytes(this.pool)); String sCls = cls.getBytes(this.javaClass.getConstantPool()); if (sCls.indexOf("/") != -1) { //sCls = sCls.substring(0, sCls.lastIndexOf(".")); sCls = this.stripClassName(sCls); sCls = sCls.replace('/', '.'); sCls = this.cleanClass(sCls); if (!this.imports.contains(sCls) && (!this.javaClass.getPackageName().equals(sCls))) { this.imports.add(sCls); } } } public void visitConstantUtf8(ConstantUtf8 utf) { //System.out.println("UTF8: " + utf.getBytes()); //System.out.println("UTF8 Strng: " + utf.toString()); String utfString = utf.toString().substring(utf.toString().indexOf('"') + 1,utf.toString().lastIndexOf('"')); //System.out.println("FIXED: " + utfString); if (isValidJavaClass(utfString)) { if (!this.strings.contains(utfString)) { String[] classes = this.separateClasses(utfString); for (int i = 0; i < classes.length; i++) { if (classes[i] != null) { String cls = classes[i]; String packageName = this.stripClassName(cls); packageName = packageName.replace('/', '.'); String cleanedPackage = this.cleanClass(packageName); //System.out.println("UTF " + cls); if (!this.imports.contains(cleanedPackage) && (!this.javaClass.getPackageName().equals(cleanedPackage))) { this.imports.add(cleanedPackage); } } } } } } public void visitConstantString(ConstantString str) { //System.out.println("CONSTANTSTRING: " + str.getBytes(this.pool)); this.strings.add(str.getBytes(this.javaClass.getConstantPool()).toString()); } private boolean isValidJavaClass(String cls) { if (cls.indexOf("/") == -1) { return false; } if ( (!cls.startsWith("(")) && (!cls.startsWith("L")) ) { return false; } if ( (!cls.endsWith("V")) && (!cls.endsWith(";")) && (!cls.endsWith(")")) ) { return false; } return true; } private String[] separateClasses(String utfString) { StringTokenizer tokenizer = new StringTokenizer(utfString, ";"); String classes[] = new String[tokenizer.countTokens()]; int i = 0; while (tokenizer.hasMoreTokens()) { String cls = tokenizer.nextToken(); if (cls.indexOf('/') != -1) { classes[i] = cls; i++; } } return classes; } private String cleanClass(String cls) { int index = cls.lastIndexOf('L'); //int index = cls.indexOf('L'); String newCls = cls; if (index != -1) { newCls = cls.substring(index + 1); } return newCls; } private String stripClassName(String cls) { //String strippedName = cls.substring(0, cls.lastIndexOf(".")); String strippedName = cls.substring(0, cls.lastIndexOf("/")); return strippedName; } public List getAllImports() { return this.imports; } public List getImports(List ignorePackages) { Iterator i = this.imports.iterator(); ArrayList imports = new ArrayList(); while (i.hasNext()) { String pkg = (String) i.next(); //System.out.println("IMPORT: " + pkg); if (ignorePackages.isEmpty() == false) { Iterator filter = ignorePackages.iterator(); boolean filterPackage = false; while (filter.hasNext()) { String packageFilter = (String) filter.next(); if (pkg.startsWith(packageFilter)) { filterPackage = true; } } if (!filterPackage) { imports.add(pkg); } } else { imports.add(pkg); } } return imports; } }
⏎ com/kirkk/analyzer/framework/bcel/PackageVisitor.java
Â
Â
⇒ jarscan - JAR File Scanner
⇠Download JarAnalyzer Source Package
⇑ JarAnalyzer by Kirk Knoernschild
⇑⇑ Java/JAR Tools
2021-07-01, 2491👍, 0💬
Popular Posts:
JDK 11 java.base.jmod is the JMOD file for JDK 11 Base module. JDK 11 Base module compiled class fil...
JDK 11 jdk.internal.vm.compiler .jmodis the JMOD file for JDK 11 Internal VM Compiler module. JDK 11...
Apache Neethi provides general framework for the programmers to use WS Policy. It is compliant with ...
Jakarta Regexp is a 100% Pure Java Regular Expression package that was graciously donated to the Apa...
XStream is a simple library to serialize objects to XML and back again. JAR File Size and Download L...