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

ConstantMethodRef cannot be cast to class java.lang.String #64

Open
YiZero10 opened this issue Sep 11, 2023 · 3 comments
Open

ConstantMethodRef cannot be cast to class java.lang.String #64

YiZero10 opened this issue Sep 11, 2023 · 3 comments

Comments

@YiZero10
Copy link

I have been blocked...
I want to compile Java smart contract, is there any sample?
And the Picture is my code, I want to complie it to wasm. And happen following exceptions:

Exception in thread "main" de.inetsoftware.jwebassembly.WasmException: java.lang.ClassCastException: class de.inetsoftware.classparser.ConstantMethodRef cannot be cast to class java.lang.String (de.inetsoftware.classparser.ConstantMethodRef is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
at MyBank.createAccount(MyBank.java:19)
at de.inetsoftware.jwebassembly.WasmException.create(WasmException.java:145)
at de.inetsoftware.jwebassembly.WasmException.create(WasmException.java:118)
at de.inetsoftware.jwebassembly.WasmException.create(WasmException.java:99)
at de.inetsoftware.jwebassembly.module.JavaMethodWasmCodeBuilder.writeCode(JavaMethodWasmCodeBuilder.java:767)
at de.inetsoftware.jwebassembly.module.JavaMethodWasmCodeBuilder.buildCode(JavaMethodWasmCodeBuilder.java:99)
at de.inetsoftware.jwebassembly.module.ModuleGenerator.createInstructions(ModuleGenerator.java:586)
at de.inetsoftware.jwebassembly.module.ModuleGenerator.scanFunctions(ModuleGenerator.java:242)
at de.inetsoftware.jwebassembly.module.ModuleGenerator.prepareFinish(ModuleGenerator.java:325)
at de.inetsoftware.jwebassembly.JWebAssembly.compile(JWebAssembly.java:368)
at de.inetsoftware.jwebassembly.JWebAssembly.compileToText(JWebAssembly.java:279)
at de.inetsoftware.jwebassembly.JWebAssembly.compileToText(JWebAssembly.java:263)
at de.inetsoftware.jwebassembly.JWebAssembly.compileToText(JWebAssembly.java:229)
at Test.main(Test.java:31)
Caused by: java.lang.ClassCastException: class de.inetsoftware.classparser.ConstantMethodRef cannot be cast to class java.lang.String (de.inetsoftware.classparser.ConstantMethodRef is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
at de.inetsoftware.classparser.BootstrapMethod.(BootstrapMethod.java:58)
at de.inetsoftware.classparser.ClassFile.getBootstrapMethod(ClassFile.java:234)
at de.inetsoftware.jwebassembly.module.JavaMethodWasmCodeBuilder.writeCode(JavaMethodWasmCodeBuilder.java:662)
... 9 more

image
@Horcrux7
Copy link
Member

Horcrux7 commented Sep 17, 2023

  • Do you have use Java 8? Currently for the most cases it work only with the Java 8 runtime.

  • Which version of JWebAssembly do you have use? Try the current snapshot version. It include many bug fixes.

  • How can I reproduce it? Please attache an sample.

@wlusergithub
Copy link

I have been blocked... I want to compile Java smart contract, is there any sample? And the Picture is my code, I want to complie it to wasm. And happen following exceptions:

Exception in thread "main" de.inetsoftware.jwebassembly.WasmException: java.lang.ClassCastException: class de.inetsoftware.classparser.ConstantMethodRef cannot be cast to class java.lang.String (de.inetsoftware.classparser.ConstantMethodRef is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap') at MyBank.createAccount(MyBank.java:19) at de.inetsoftware.jwebassembly.WasmException.create(WasmException.java:145) at de.inetsoftware.jwebassembly.WasmException.create(WasmException.java:118) at de.inetsoftware.jwebassembly.WasmException.create(WasmException.java:99) at de.inetsoftware.jwebassembly.module.JavaMethodWasmCodeBuilder.writeCode(JavaMethodWasmCodeBuilder.java:767) at de.inetsoftware.jwebassembly.module.JavaMethodWasmCodeBuilder.buildCode(JavaMethodWasmCodeBuilder.java:99) at de.inetsoftware.jwebassembly.module.ModuleGenerator.createInstructions(ModuleGenerator.java:586) at de.inetsoftware.jwebassembly.module.ModuleGenerator.scanFunctions(ModuleGenerator.java:242) at de.inetsoftware.jwebassembly.module.ModuleGenerator.prepareFinish(ModuleGenerator.java:325) at de.inetsoftware.jwebassembly.JWebAssembly.compile(JWebAssembly.java:368) at de.inetsoftware.jwebassembly.JWebAssembly.compileToText(JWebAssembly.java:279) at de.inetsoftware.jwebassembly.JWebAssembly.compileToText(JWebAssembly.java:263) at de.inetsoftware.jwebassembly.JWebAssembly.compileToText(JWebAssembly.java:229) at Test.main(Test.java:31) Caused by: java.lang.ClassCastException: class de.inetsoftware.classparser.ConstantMethodRef cannot be cast to class java.lang.String (de.inetsoftware.classparser.ConstantMethodRef is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap') at de.inetsoftware.classparser.BootstrapMethod.(BootstrapMethod.java:58) at de.inetsoftware.classparser.ClassFile.getBootstrapMethod(ClassFile.java:234) at de.inetsoftware.jwebassembly.module.JavaMethodWasmCodeBuilder.writeCode(JavaMethodWasmCodeBuilder.java:662) ... 9 more

image

请问下您这是在将java编译成wasm智能合约吗

@Horcrux7
Copy link
Member

Horcrux7 commented Dec 7, 2023

I repeat the questions:

  • Do you have use Java 8? Currently for the most cases it work only with the Java 8 runtime.

  • Which version of JWebAssembly do you have use? Try the current snapshot version. It include many bug fixes.

  • How can I reproduce it? Please attache an sample.

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

3 participants