From 699b301badf2f6746d091df3094d99444fa3fdd8 Mon Sep 17 00:00:00 2001 From: Rich Bolen Date: Tue, 27 Aug 2019 07:45:10 -0400 Subject: Incorporate feedback from the PR --- src/main/javassist/bytecode/Bytecode.java | 19 ------------- src/main/javassist/bytecode/ClassFileWriter.java | 18 ------------ src/main/javassist/bytecode/ConstPool.java | 2 +- src/test/javassist/bytecode/BytecodeTest.java | 36 ------------------------ 4 files changed, 1 insertion(+), 74 deletions(-) (limited to 'src') diff --git a/src/main/javassist/bytecode/Bytecode.java b/src/main/javassist/bytecode/Bytecode.java index 193e3f8a..37a6d127 100644 --- a/src/main/javassist/bytecode/Bytecode.java +++ b/src/main/javassist/bytecode/Bytecode.java @@ -1240,25 +1240,6 @@ public class Bytecode extends ByteVector implements Cloneable, Opcode { growStack(Descriptor.dataSize(desc)); // assume ConstPool#REF_invokeStatic } - /** - * Appends DYNAMIC. - * - * @param bootstrap an index into the bootstrap_methods array - * of the bootstrap method table. - * @param name the method name. - * @param desc the method descriptor. - * @see Descriptor#ofMethod(CtClass,CtClass[]) - * @since 3.17 - */ - public void addDynamic(int bootstrap, String name, String desc) { - int nt = constPool.addNameAndTypeInfo(name, desc); - int dyn = constPool.addDynamicInfo(bootstrap, nt); - add(INVOKEDYNAMIC); - addIndex(dyn); - add(0, 0); - growStack(Descriptor.dataSize(desc)); // assume ConstPool#REF_invokeStatic - } - /** * Appends LDC or LDC_W. The pushed item is a String * object. diff --git a/src/main/javassist/bytecode/ClassFileWriter.java b/src/main/javassist/bytecode/ClassFileWriter.java index 03650b75..966767af 100644 --- a/src/main/javassist/bytecode/ClassFileWriter.java +++ b/src/main/javassist/bytecode/ClassFileWriter.java @@ -700,24 +700,6 @@ public class ClassFileWriter { return num++; } - /** - * Adds a new CONSTANT_InvokeDynamic_info - * structure. - * - * @param bootstrap bootstrap_method_attr_index. - * @param nameAndTypeInfo name_and_type_index. - * @return the index of the added entry. - * - * @since 3.17.1 - */ - public int addDynamicInfo(int bootstrap, - int nameAndTypeInfo) { - output.write(DynamicInfo.tag); - output.writeShort(bootstrap); - output.writeShort(nameAndTypeInfo); - return num++; - } - /** * Adds a new CONSTANT_String_info * structure. diff --git a/src/main/javassist/bytecode/ConstPool.java b/src/main/javassist/bytecode/ConstPool.java index 08985089..bd521001 100644 --- a/src/main/javassist/bytecode/ConstPool.java +++ b/src/main/javassist/bytecode/ConstPool.java @@ -1242,7 +1242,7 @@ public final class ConstPool } /** - * Adds a new CONSTANT_InvokeDynamic_info structure. + * Adds a new CONSTANT_Dynamic_info structure. * * @param bootstrap bootstrap_method_attr_index. * @param nameAndType name_and_type_index. diff --git a/src/test/javassist/bytecode/BytecodeTest.java b/src/test/javassist/bytecode/BytecodeTest.java index ec754b56..5ddf5d5b 100644 --- a/src/test/javassist/bytecode/BytecodeTest.java +++ b/src/test/javassist/bytecode/BytecodeTest.java @@ -827,42 +827,6 @@ public class BytecodeTest extends TestCase { assertEquals("(I)V", cPool2.getUtf8Info(cPool2.getMethodTypeInfo(mtIndex))); } -// public void testDynamicInfo() throws Exception { -// ClassFile cf = new ClassFile(false, "test4.Dyn", null); -// cf.setInterfaces(new String[] { "java.lang.Cloneable" }); -// ConstPool cp = cf.getConstPool(); -// -// Bytecode code = new Bytecode(cp, 0, 1); -// code.addAload(0); -// code.addIconst(9); -// code.addLdc("nine"); -// code.addDynamic(0, "call", "I"); -// code.addOpcode(Opcode.SWAP); -// code.addOpcode(Opcode.POP); -// code.addOpcode(Opcode.IRETURN); -// -// FieldInfo fieldInfo = new FieldInfo(cp, "test", "S"); -// fieldInfo.setAccessFlags(AccessFlag.PUBLIC); -// cf.addField(fieldInfo); -// -// String desc -// = "(Ljava/lang/String;)I"; -// int mri = cp.addMethodrefInfo(cp.addClassInfo("Dyn"), "boot", desc); -// int mhi = cp.addMethodHandleInfo(ConstPool.REF_invokeStatic, mri); -// int[] args = new int[0]; -// BootstrapMethodsAttribute.BootstrapMethod[] bms -// = new BootstrapMethodsAttribute.BootstrapMethod[1]; -// bms[0] = new BootstrapMethodsAttribute.BootstrapMethod(mhi, args); -// -// cf.addAttribute(new BootstrapMethodsAttribute(cp, bms)); -// -// cf.write(new DataOutputStream(new FileOutputStream("test4/Dyn.class"))); -// -// Object obj = make(cf.getName()); -// -// assertNotNull(obj); -// } - public static Test suite() { TestSuite suite = new TestSuite("Bytecode Tests"); suite.addTestSuite(BytecodeTest.class); -- cgit v1.2.3