Skip to content

Commit

Permalink
fix: skip over contant pool entries when they are second half of CONS…
Browse files Browse the repository at this point in the history
…TANT_Long or CONSTANT_Doubles
  • Loading branch information
mebigfatguy committed Dec 21, 2023
1 parent b00b50f commit 6bff5ba
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.Set;

import org.apache.bcel.Constants;
import org.apache.bcel.classfile.Constant;
import org.apache.bcel.classfile.ConstantClass;
import org.apache.bcel.classfile.ConstantPool;
Expand Down Expand Up @@ -101,7 +102,14 @@ public void visitClassContext(ClassContext context) {
if (!isInternal(cls.getClassName())) {
ConstantPool pool = cls.getConstantPool();
int numItems = pool.getLength();

byte lastTag = Constants.CONSTANT_Class;
for (int i = 1; i < numItems; i++) {
if (lastTag == Constants.CONSTANT_Double || lastTag == Constants.CONSTANT_Long) {
lastTag = Constants.CONSTANT_Class;
continue;
}

Constant c = pool.getConstant(i);
if (c instanceof ConstantClass) {
String clsName = ((ConstantClass) c).getBytes(pool);
Expand All @@ -111,6 +119,7 @@ public void visitClassContext(ClassContext context) {
.addClass(cls).addString(clsName));
}
}
lastTag = c.getTag();
}
}
}
Expand Down

0 comments on commit 6bff5ba

Please sign in to comment.