Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用合约lambda表达式写法报错 #88

Open
glowwormX opened this issue Aug 3, 2020 · 2 comments
Open

调用合约lambda表达式写法报错 #88

glowwormX opened this issue Aug 3, 2020 · 2 comments

Comments

@glowwormX
Copy link

glowwormX commented Aug 3, 2020

demo每次调用合约需要新写一个类,尝试lambda表达式写法,org.apache.bcel.util报找不到类错误

         //调用 注册
        //Transaction transaction1 = new Transaction.HVMBuilder(account.getAddress()).invoke(contractAddress, new InvokeStudentReg()).build();
        //使用lambda表达式,避免新写一个类
        BaseInvoke<String, IStudent> register = iStudent ->
                iStudent.registerStudent(Arrays.asList(new Student("id1", "name1", 20), new Student("id2", "name2", 20)));
        Transaction transaction1 = new Transaction.HVMBuilder(account.getAddress()).invoke(contractAddress, register).build();
        transaction1.sign(account);
        ReceiptResponse receiptResponse1 = contractService.invoke(transaction1).send().polling();
        String decodeHVM1 = Decoder.decodeHVM(receiptResponse1.getRet(), String.class);
        System.out.println("decode: " + decodeHVM1);
        System.out.println(receiptResponse1.getRet());

报错:

java.lang.RuntimeException: java.lang.ClassNotFoundException: TestStudent$$Lambda$9/18179709 not found.

	at cn.hyperchain.sdk.common.utils.Encoder.encodeInvokeBeanJava(Encoder.java:97)
	at cn.hyperchain.sdk.transaction.Transaction$HVMBuilder.invoke(Transaction.java:173)
	at TestStudent.invoke(TestStudent.java:62)
@taoyq1988
Copy link
Collaborator

This problem is because Lambda expressions will generate additional classes. If you write Lambda expressions in InvokeBean, the class information may not be found, and the encoding fails. You can use other methods to replace Lambda, sorry. @glowwormX

@glowwormX glowwormX changed the title 调用合约正则表达式写法报错 调用合约lambda表达式写法报错 Sep 23, 2020
@glowwormX
Copy link
Author

sdk最好支持此种写法,未来有计划支持么

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants