Skip to content

Commit

Permalink
fix: Element value union for classes points to UTF8 desc, not a Class…
Browse files Browse the repository at this point in the history
… CP entry
  • Loading branch information
Col-E committed Feb 21, 2022
1 parent 96e552d commit dc7abd4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public ClassElementValue(char tag, int classIndex) {
}

/**
* @return Index of class constant.
* @return Index of a class's descriptor.
*/
public int getClassIndex() {
return classIndex;
}

/**
* @param classIndex
* Index of class constant.
* Index of a class's descriptor.
*/
public void setClassIndex(int classIndex) {
this.classIndex = classIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public IllegalStrippingTransformer(ClassFile clazz) {
super(clazz);
}

// TODO: Make it possible to track if calling transform did remove anything

@Override
public void transform() {
logger.info("Transforming '{}'", clazz.getName());
Expand Down Expand Up @@ -476,8 +478,8 @@ private void addElementValueValidation(AttributeHolder holder,
ElementValue elementValue) {
if (elementValue instanceof ClassElementValue) {
int classIndex = ((ClassElementValue) elementValue).getClassIndex();
expectedTypeMasks.put(classIndex, i -> i == ConstantPool.CLASS);
cpEntryValidators.put(classIndex, matchClassType());
expectedTypeMasks.put(classIndex, i -> i == ConstantPool.UTF8);
cpEntryValidators.put(classIndex, matchUtf8ClassType());
} else if (elementValue instanceof EnumElementValue) {
EnumElementValue enumElementValue = (EnumElementValue) elementValue;
expectedTypeMasks.put(enumElementValue.getNameIndex(), i -> i == ConstantPool.UTF8);
Expand Down

0 comments on commit dc7abd4

Please sign in to comment.