equal
deleted
inserted
replaced
92 * @return {@code true} if the given class file is processed to lookup |
92 * @return {@code true} if the given class file is processed to lookup |
93 * references |
93 * references |
94 * @throws ConstantPoolException if an error of the constant pool |
94 * @throws ConstantPoolException if an error of the constant pool |
95 */ |
95 */ |
96 public boolean parse(ClassFile cf) throws ConstantPoolException { |
96 public boolean parse(ClassFile cf) throws ConstantPoolException { |
97 List<Integer> cprefs = new ArrayList<Integer>(); |
97 List<Integer> cprefs = new ArrayList<>(); |
98 int index = 1; |
98 int index = 1; |
99 for (ConstantPool.CPInfo cpInfo : cf.constant_pool.entries()) { |
99 for (ConstantPool.CPInfo cpInfo : cf.constant_pool.entries()) { |
100 if (cpInfo.accept(cpVisitor, cf.constant_pool)) { |
100 if (cpInfo.accept(cpVisitor, cf.constant_pool)) { |
101 cprefs.add(index); |
101 cprefs.add(index); |
102 } |
102 } |
106 if (cprefs.isEmpty()) { |
106 if (cprefs.isEmpty()) { |
107 return false; |
107 return false; |
108 } |
108 } |
109 |
109 |
110 for (Method m : cf.methods) { |
110 for (Method m : cf.methods) { |
111 Set<Integer> ids = new HashSet<Integer>(); |
111 Set<Integer> ids = new HashSet<>(); |
112 Code_attribute c_attr = (Code_attribute) m.attributes.get(Attribute.Code); |
112 Code_attribute c_attr = (Code_attribute) m.attributes.get(Attribute.Code); |
113 if (c_attr != null) { |
113 if (c_attr != null) { |
114 for (Instruction instr : c_attr.getInstructions()) { |
114 for (Instruction instr : c_attr.getInstructions()) { |
115 int idx = instr.accept(codeVisitor, cprefs); |
115 int idx = instr.accept(codeVisitor, cprefs); |
116 if (idx > 0) { |
116 if (idx > 0) { |
117 ids.add(idx); |
117 ids.add(idx); |
118 } |
118 } |
119 } |
119 } |
120 } |
120 } |
121 if (ids.size() > 0) { |
121 if (ids.size() > 0) { |
122 List<CPRefInfo> refInfos = new ArrayList<CPRefInfo>(ids.size()); |
122 List<CPRefInfo> refInfos = new ArrayList<>(ids.size()); |
123 for (int id : ids) { |
123 for (int id : ids) { |
124 refInfos.add(CPRefInfo.class.cast(cf.constant_pool.get(id))); |
124 refInfos.add(CPRefInfo.class.cast(cf.constant_pool.get(id))); |
125 } |
125 } |
126 visitor.visit(cf, m, refInfos); |
126 visitor.visit(cf, m, refInfos); |
127 } |
127 } |