-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Exception thrown by SolidityFunctionWrapper when "double" as function name #658
Comments
double is reserved word it can't be used as function or variable name. |
Yes, I know that double is a reserved word. But, it's reserved in Java: the Solidity code that I submitted to reproduce is compiled without any problem by Solidity compiler. Why should we introduce a Java restriction into Solidity contracts? programmers of smart contracts can't take into account the limitations of all languages dealing in some form with their Solidity programs. I would suggest to prefix the name of a function by underscore (or anything else) when the function name is a Java reserved word. That would be the burden on Java side for a proper call, not on Solidity side. (Additiionally, for somebody collecting existing ABIs from existing contracts on the Ethereum, no chance to contact the programmer to ask him to change the name of his function) |
@conor10 thoughts on this? I think prefix with an underscore is sensible in this case. It could also be suffix with an underscore to preserve the ordering of methods when using intellij... |
Generating com.gomo.ethchain.contract.FountainTokenUpgrade ... Exception in thread "main" java.lang.IllegalArgumentException: not a valid name: |
Closing as this issue was fixed by #766 @sywuestc please open a new issue if there is still a bug. It will be useful to have a failing contract so I can replicate and fix. |
Hi,
"double" as function name makes class SolidityFunctionWrapper throw an exception. See stack trace below.
Solidity code to reproduce:
pragma solidity ^0.4.24;
contract TestEthCall {
function double(int a) pure public returns(int) {
return 2*a;
}
}
Best,
Didier
java.lang.IllegalArgumentException: not a valid name: double
at com.squareup.javapoet.Util.checkArgument(Util.java:64)
at com.squareup.javapoet.MethodSpec$Builder.(MethodSpec.java:296)
at com.squareup.javapoet.MethodSpec$Builder.(MethodSpec.java:281)
at com.squareup.javapoet.MethodSpec.methodBuilder(MethodSpec.java:175)
at org.web3j.codegen.SolidityFunctionWrapper.buildFunction(SolidityFunctionWrapper.java:591)
at org.web3j.codegen.SolidityFunctionWrapper.buildFunctionDefinitions(SolidityFunctionWrapper.java:251)
at org.web3j.codegen.SolidityFunctionWrapper.generateJavaFiles(SolidityFunctionWrapper.java:130)
at org.web3j.codegen.SolidityFunctionWrapper.generateJavaFiles(SolidityFunctionWrapper.java:111)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.generate(SolidityFunctionWrapperGenerator.java:123)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.main(SolidityFunctionWrapperGenerator.java:87)
at io.recognichain.core.SolidityCompiler.generateJavaWrapper(SolidityCompiler.java:45)
at io.recognichain.test.TestEthCall.compileEthCall(TestEthCall.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:42)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:83)
at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:74)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
The text was updated successfully, but these errors were encountered: