diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2022-08-13 22:46:45 +0200 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2022-08-13 23:07:49 +0200 |
commit | 208eafba3245da6e3eed1b22269e13c6f9920544 (patch) | |
tree | a932fcd881c3923e795e8adb885ffc48427fb6ef /bcel-builder/src | |
parent | aeb598cda1165c076eae78c12b9a69405b5d59a2 (diff) | |
download | aspectj-208eafba3245da6e3eed1b22269e13c6f9920544.tar.gz aspectj-208eafba3245da6e3eed1b22269e13c6f9920544.zip |
Improve condy (constant dynamic) support
Relates to #170. Fixes the "Unknown constant type 17" problem.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'bcel-builder/src')
-rw-r--r-- | bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java | 2 | ||||
-rw-r--r-- | bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java | 22 |
2 files changed, 22 insertions, 2 deletions
diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java index 3c1c12daf..6c2240b9d 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java @@ -185,7 +185,7 @@ public interface Constants { String[] CONSTANT_NAMES = { "", "CONSTANT_Utf8", "", "CONSTANT_Integer", "CONSTANT_Float", "CONSTANT_Long", "CONSTANT_Double", "CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref", "CONSTANT_Methodref", - "CONSTANT_InterfaceMethodref", "CONSTANT_NameAndType","","","CONSTANT_MethodHandle","CONSTANT_MethodType","","CONSTANT_InvokeDynamic", + "CONSTANT_InterfaceMethodref", "CONSTANT_NameAndType","","","CONSTANT_MethodHandle","CONSTANT_MethodType","CONSTANT_Dynamic","CONSTANT_InvokeDynamic", // J9: "CONSTANT_Module", "CONSTANT_Package"}; diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java index 2066b4569..f8894def4 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/classfile/ConstantPool.java @@ -212,6 +212,10 @@ public class ConstantPool implements Node { ConstantInvokeDynamic cID = ((ConstantInvokeDynamic)c); return "#"+cID.getBootstrapMethodAttrIndex()+"."+constantToString(cID.getNameAndTypeIndex(), Constants.CONSTANT_NameAndType); + case Constants.CONSTANT_Dynamic: + ConstantDynamic cD = ((ConstantDynamic)c); + return "#"+cD.getBootstrapMethodAttrIndex()+"."+constantToString(cD.getNameAndTypeIndex(), Constants.CONSTANT_NameAndType); + case Constants.CONSTANT_MethodHandle: ConstantMethodHandle cMH = ((ConstantMethodHandle)c); return cMH.getReferenceKind()+":"+constantToString(cMH.getReferenceIndex(),Constants.CONSTANT_Methodref); @@ -326,7 +330,7 @@ public class ConstantPool implements Node { StringBuilder buf = new StringBuilder(); for (int i = 1; i < poolSize; i++) - buf.append(i + ")" + pool[i] + "\n"); + buf.append(i).append(") ").append(pool[i]).append("\n"); return buf.toString(); } @@ -632,6 +636,16 @@ public class ConstantPool implements Node { return addInvokeDynamic(index1,index2); } + case Constants.CONSTANT_Dynamic: { + ConstantDynamic cd = (ConstantDynamic)c; + int index1 = cd.getBootstrapMethodAttrIndex(); + ConstantNameAndType cnat = (ConstantNameAndType)constants[cd.getNameAndTypeIndex()]; + ConstantUtf8 name = (ConstantUtf8) constants[cnat.getNameIndex()]; + ConstantUtf8 signature = (ConstantUtf8) constants[cnat.getSignatureIndex()]; + int index2 = addNameAndType(name.getValue(), signature.getValue()); + return addConstantDynamic(index1,index2); + } + case Constants.CONSTANT_MethodHandle: ConstantMethodHandle cmh = (ConstantMethodHandle)c; return addMethodHandle(cmh.getReferenceKind(),addConstant(constants[cmh.getReferenceIndex()],cp)); @@ -725,6 +739,12 @@ public class ConstantPool implements Node { pool[poolSize++] = new ConstantInvokeDynamic(bootstrapMethodIndex, constantNameAndTypeIndex); return ret; } + public int addConstantDynamic(int bootstrapMethodIndex, int constantNameAndTypeIndex) { + adjustSize(); + int ret = poolSize; + pool[poolSize++] = new ConstantDynamic(bootstrapMethodIndex, constantNameAndTypeIndex); + return ret; + } public int addInterfaceMethodref(String class_name, String method_name, String signature) { int ret = lookupInterfaceMethodref(class_name, method_name, signature); |