Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

CodeAnalyzerTest.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package javassist.bytecode;
  2. import java.util.zip.*;
  3. import java.util.Enumeration;
  4. import java.util.List;
  5. import java.io.*;
  6. @SuppressWarnings({"rawtypes","resource"})
  7. public class CodeAnalyzerTest {
  8. public static void main(String[] args) throws Exception {
  9. ZipFile zfile = new ZipFile(args[0]);
  10. Enumeration e = zfile.entries();
  11. while (e.hasMoreElements()) {
  12. ZipEntry zip = (ZipEntry)e.nextElement();
  13. if (zip.getName().endsWith(".class"))
  14. test(zfile.getInputStream(zip));
  15. }
  16. }
  17. static void test(InputStream is) throws Exception {
  18. is = new BufferedInputStream(is);
  19. ClassFile cf = new ClassFile(new DataInputStream(is));
  20. is.close();
  21. List list = cf.getMethods();
  22. int n = list.size();
  23. for (int i = 0; i < n; ++i) {
  24. MethodInfo minfo = (MethodInfo)list.get(i);
  25. CodeAttribute ca = minfo.getCodeAttribute();
  26. if (ca != null) {
  27. try {
  28. int max = ca.getMaxStack();
  29. int newMax = ca.computeMaxStack();
  30. if (max != newMax)
  31. System.out.println(max + " -> " + newMax +
  32. " for " + minfo.getName() + " (" +
  33. minfo.getDescriptor() + ") in " +
  34. cf.getName());
  35. }
  36. catch (BadBytecode e) {
  37. System.out.println(e.getMessage() +
  38. " for " + minfo.getName() + " (" +
  39. minfo.getDescriptor() + ") in " +
  40. cf.getName());
  41. }
  42. }
  43. }
  44. }
  45. }