1666 }
1667
1668 /**
1669 * Emit a bogus method that just loads some string constants. This is to get the constants into the constant pool
1670 * for debugging purposes.
1671 */
1672 private void bogusMethod(ClassBuilder clb, Object os) {
1673 if (dumper().isEnabled()) {
1674 clb.withMethod("dummy", MTD_void, ACC_STATIC, new MethodBody(new Consumer<CodeBuilder>() {
1675 @Override
1676 public void accept(CodeBuilder cob) {
1677 cob.loadConstant(os.toString());
1678 cob.pop();
1679 cob.return_();
1680 }
1681 }));
1682 }
1683 }
1684
1685 static ClassDesc classDesc(Class<?> cls) {
1686 // assert(VerifyAccess.isTypeVisible(cls, Object.class)) : cls.getName();
1687 return cls.isPrimitive() ? Wrapper.forPrimitiveType(cls).basicClassDescriptor()
1688 : cls == MethodHandle.class ? CD_MethodHandle
1689 : cls == DirectMethodHandle.class ? CD_DirectMethodHandle
1690 : cls == Object.class ? CD_Object
1691 : ReferenceClassDescImpl.ofValidated(cls.descriptorString());
1692 }
1693
1694 static MethodTypeDesc methodDesc(MethodType mt) {
1695 var params = new ClassDesc[mt.parameterCount()];
1696 for (int i = 0; i < params.length; i++) {
1697 params[i] = classDesc(mt.parameterType(i));
1698 }
1699 return MethodTypeDescImpl.ofValidated(classDesc(mt.returnType()), params);
1700 }
1701 }
|
1666 }
1667
1668 /**
1669 * Emit a bogus method that just loads some string constants. This is to get the constants into the constant pool
1670 * for debugging purposes.
1671 */
1672 private void bogusMethod(ClassBuilder clb, Object os) {
1673 if (dumper().isEnabled()) {
1674 clb.withMethod("dummy", MTD_void, ACC_STATIC, new MethodBody(new Consumer<CodeBuilder>() {
1675 @Override
1676 public void accept(CodeBuilder cob) {
1677 cob.loadConstant(os.toString());
1678 cob.pop();
1679 cob.return_();
1680 }
1681 }));
1682 }
1683 }
1684
1685 static ClassDesc classDesc(Class<?> cls) {
1686 assert(VerifyAccess.ensureTypeVisible(cls, Object.class)) : cls.getName();
1687 return cls.isPrimitive() ? Wrapper.forPrimitiveType(cls).basicClassDescriptor()
1688 : cls == MethodHandle.class ? CD_MethodHandle
1689 : cls == DirectMethodHandle.class ? CD_DirectMethodHandle
1690 : cls == Object.class ? CD_Object
1691 : ReferenceClassDescImpl.ofValidated(cls.descriptorString());
1692 }
1693
1694 static MethodTypeDesc methodDesc(MethodType mt) {
1695 var params = new ClassDesc[mt.parameterCount()];
1696 for (int i = 0; i < params.length; i++) {
1697 params[i] = classDesc(mt.parameterType(i));
1698 }
1699 return MethodTypeDescImpl.ofValidated(classDesc(mt.returnType()), params);
1700 }
1701 }
|