hashgraph / hedera-sdk-java

Hedera™ Hashgraph SDK for Java
https://docs.hedera.com/guides/docs/sdks
Apache License 2.0
205 stars 114 forks source link

droid studio w java 8 hhsdk .7 contractCallResult.getString(); falls over #239

Closed johnda98 closed 4 years ago

johnda98 commented 4 years ago

droid studio w java 8 hh sdk .7 contractCallResult.getString(); falls over

curious as it seems to be lower in the stack.

It finds the SC ok #15552 and gas etc is fine.. it .execute ok.. but SC call to simple getter method falls

" java.lang.NoSuchMethodError: No virtual method position(I)Ljava/nio/ByteBuffer; in class Ljava/nio/ByteBuffer; or its super classes (declaration of 'java.nio.ByteBuffer' appears in /system/framework/core-oj.jar) at com.hedera.hashgraph.sdk.FunctionResult.getByteBuffer(FunctionResult.java:151)"

Welcome advice - thanks - full trace below

Increasing code cache capacity to 128KB I/System.out: baltemp4dec = 8821 balance = 6688219685 I/System.out: Gas used : 397 D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.leveridgesystems.johnsapp, PID: 23424 java.lang.NoSuchMethodError: No virtual method position(I)Ljava/nio/ByteBuffer; in class Ljava/nio/ByteBuffer; or its super classes (declaration of 'java.nio.ByteBuffer' appears in /system/framework/core-oj.jar) at com.hedera.hashgraph.sdk.FunctionResult.getByteBuffer(FunctionResult.java:151) at com.hedera.hashgraph.sdk.FunctionResult.getIntValueAt(FunctionResult.java:141) at com.hedera.hashgraph.sdk.FunctionResult.getInt(FunctionResult.java:109) at com.hedera.hashgraph.sdk.FunctionResult.getBytes(FunctionResult.java:71) at com.hedera.hashgraph.sdk.FunctionResult.getString(FunctionResult.java:64) at com.hedera.hashgraph.sdk.FunctionResult.getString(FunctionResult.java:59) at com.leveridgesystems.johnsapp.MainActivity$1.onClick(MainActivity.java:122) at android.view.View.performClick(View.java:6256) at android.view.View$PerformClick.run(View.java:24701) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6

abonander commented 4 years ago

That method should exist. Can you do a clean build and run it again?

johnda98 commented 4 years ago

Did a project Clean and rebuild .. welcome any other thoughts :) Screenshot from 2019-10-25 16-35-33

I/System.out: Gas used : 1011 D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.leveridgesystems.johnsapp, PID: 23432 java.lang.NoSuchMethodError: No virtual method position(I)Ljava/nio/ByteBuffer; in class Ljava/nio/ByteBuffer; or its super classes (declaration of 'java.nio.ByteBuffer' appears in /system/framework/core-oj.jar) at com.hedera.hashgraph.sdk.FunctionResult.getByteBuffer(FunctionResult.java:151)

johnda98 commented 4 years ago

Austin.. fairly believe its a Java 8 compatibility issue with this HH lib compiled with 9 or 10 even with compatibility mode set lower to 8. see https://github.com/sannies/mp4parser/issues/323
thanks - pls advise . cheers indeed. :) recompilation your side or re-cast .. whatever you guys did to make backward compat with java 8.. and recompile

include in FunctionResult .. import java.nio.Buffer;

and recast ?? ByteBuffer buff = ByteBuffer.xx ((Buffer)buff).xx

.. in FunctionResult.. private ByteBuffer getByteBuffer(int offset) { // NB .asReadOnlyByteBuffer() on a substring reads from the start of the parent, // not the substring (bug) return (ByteBuffer) getRawResult().asReadOnlyByteBuffer().position(offset); }

not sure on how you guys would do it .. will await advisement

johnda98 commented 4 years ago

the following help ? .. call byteBuffer.position(0) in JDK 8 calls method Buffer.position(I)LBuffer while in JDK 9+ calls method ByteBuffer.position(I)LByteBuffer. When a JVM 8 sees the latter it does not find it, hence the error.

JDK 9's javac produces the wrong bytecode even when specifying --release 8.

never seen javac produce the wrong bytecodes when given the proper --release flag. The wrong bytecodes issue seems to occur when one is using (for example) JDK 9 and using "javac -source 8 -target 8", which does let Java 9 library dependencies leak into Java 8 classes (and which issues a warning) and which results in this problem. Usually the problem seems to be that something in the build system is still using the -source 8 -target 8 technique and thus the problem persists.

abonander commented 4 years ago

It might be because the SDK is built separately as a library and so has to include Java 9 library code while building? Whereas a leaf build like your Android application can override with the classes from the Android SDK. I don't know for sure; I don't pretend to understand Java's build system.

Ideally we would build and publish the SDK with JDK 8 but the Maven build fails without printing any errors from the compiler. I'm going to investigate today why that is.

johnda98 commented 4 years ago

Good man ! :-)

John D Allen.

Leveridge Systems INC.

** Pls note New Mobile tel #

*T +1 417 849 0705 * CST | john.allen@leveridgesystems.com john.allen@leveridgesystems.com | https://www.leveridgesystems.com https://www.leveridgesystems.com | linkedin.com/in/johndallen1 http://linkedin.com/in/johndallen1 | skype john.allen_67 https://www.yourhashgraphtoken.com https://www.yourhashgraphtoken.com

This email is sent on behalf of Leveridge Systems INC. Reg.Ein 86-0905636.

The information contained in this email and any attached files is confidential and intended solely for the addressee(s). The email may be legally privileged or prohibited from disclosure and unauthorized use. If you are not the named addressee you may not use, copy, or disclose this information to any other person. If you received this message in error please notify the sender immediately and delete it from your system.

On Wed, Oct 30, 2019 at 1:12 PM Austin Bonander notifications@github.com wrote:

It might be because the SDK is built separately as a library and so has to include Java 9 library code while building? Whereas a leaf build like your Android application can override with the classes from the Android SDK. I don't pretend to understand Java's build system.

Ideally we would build and publish the SDK with JDK 8 but the Maven build fails without printing any errors from the compiler. I'm going to investigate today why that is.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hashgraph/hedera-sdk-java/issues/239?email_source=notifications&email_token=ADGDUXI5OVRXN5TINDCHIZTQRHFCNA5CNFSM4JFHYE5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECVH6AY#issuecomment-548044547, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDUXMLSZJAWFFC44SSWNTQRHFCNANCNFSM4JFHYE5A .

abonander commented 4 years ago

@johnda98 would you mind testing a fix?

johnda98 commented 4 years ago

I use gradle as standard with Android studio .. does that help ?

Gladly I will point my gradle config to .7.1 when its all set

pls advise

John D Allen.

Leveridge Systems INC.

** Pls note New Mobile tel #

*T +1 417 849 0705 * CST | john.allen@leveridgesystems.com john.allen@leveridgesystems.com | https://www.leveridgesystems.com https://www.leveridgesystems.com | linkedin.com/in/johndallen1 http://linkedin.com/in/johndallen1 | skype john.allen_67 https://www.yourhashgraphtoken.com https://www.yourhashgraphtoken.com

This email is sent on behalf of Leveridge Systems INC. Reg.Ein 86-0905636.

The information contained in this email and any attached files is confidential and intended solely for the addressee(s). The email may be legally privileged or prohibited from disclosure and unauthorized use. If you are not the named addressee you may not use, copy, or disclose this information to any other person. If you received this message in error please notify the sender immediately and delete it from your system.

On Wed, Oct 30, 2019 at 2:36 PM Austin Bonander notifications@github.com wrote:

@johnda98 https://github.com/johnda98 would you mind testing a fix?

  • clone this branch of the SDK: https://github.com/launchbadge/hedera-sdk-java/tree/ab/jdk-8-fix
  • change the version in pom.xml to 0.7.1-alpha.1 (so when we release 0.7.1 you can update without having to purge your local Maven repository)
  • run mvn install
  • update the SDK version in your Android project to 0.7.1-alpha.1 and try building.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashgraph/hedera-sdk-java/issues/239?email_source=notifications&email_token=ADGDUXOB4AAGTDPB6LUB5XDQRHO5JA5CNFSM4JFHYE5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECVQGQA#issuecomment-548078400, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDUXOLPGP4HPIHYTSNI4TQRHO5JANCNFSM4JFHYE5A .

johnda98 commented 4 years ago

Hi Austin.. just a checkin. Any movement your side on the Maven build fails with no compiler errs output ?

Best John.

John D Allen.

Leveridge Systems INC.

** Pls note New Mobile tel #

*T +1 417 849 0705 * CST | john.allen@leveridgesystems.com john.allen@leveridgesystems.com | https://www.leveridgesystems.com https://www.leveridgesystems.com | linkedin.com/in/johndallen1 http://linkedin.com/in/johndallen1 | skype john.allen_67 https://www.yourhashgraphtoken.com https://www.yourhashgraphtoken.com

This email is sent on behalf of Leveridge Systems INC. Reg.Ein 86-0905636.

The information contained in this email and any attached files is confidential and intended solely for the addressee(s). The email may be legally privileged or prohibited from disclosure and unauthorized use. If you are not the named addressee you may not use, copy, or disclose this information to any other person. If you received this message in error please notify the sender immediately and delete it from your system.

On Wed, Oct 30, 2019 at 1:12 PM Austin Bonander notifications@github.com wrote:

It might be because the SDK is built separately as a library and so has to include Java 9 library code while building? Whereas a leaf build like your Android application can override with the classes from the Android SDK. I don't pretend to understand Java's build system.

Ideally we would build and publish the SDK with JDK 8 but the Maven build fails without printing any errors from the compiler. I'm going to investigate today why that is.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hashgraph/hedera-sdk-java/issues/239?email_source=notifications&email_token=ADGDUXI5OVRXN5TINDCHIZTQRHFCNA5CNFSM4JFHYE5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECVH6AY#issuecomment-548044547, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDUXMLSZJAWFFC44SSWNTQRHFCNANCNFSM4JFHYE5A .

abonander commented 4 years ago

I have a working Android example in https://github.com/hashgraph/hedera-sdk-java/pull/246 which is waiting for review.

johnda98 commented 4 years ago

So you sense changes need making to the HH java sdk ? as it stands presently.

thanks John.

John D Allen.

Leveridge Systems INC.

** Pls note New Mobile tel #

*T +1 417 849 0705 * CST | john.allen@leveridgesystems.com john.allen@leveridgesystems.com | https://www.leveridgesystems.com https://www.leveridgesystems.com | linkedin.com/in/johndallen1 http://linkedin.com/in/johndallen1 | skype john.allen_67 https://www.yourhashgraphtoken.com https://www.yourhashgraphtoken.com

This email is sent on behalf of Leveridge Systems INC. Reg.Ein 86-0905636.

The information contained in this email and any attached files is confidential and intended solely for the addressee(s). The email may be legally privileged or prohibited from disclosure and unauthorized use. If you are not the named addressee you may not use, copy, or disclose this information to any other person. If you received this message in error please notify the sender immediately and delete it from your system.

On Fri, Nov 1, 2019 at 2:42 PM Austin Bonander notifications@github.com wrote:

I have a working Android example in #246 https://github.com/hashgraph/hedera-sdk-java/pull/246 which is waiting for review.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashgraph/hedera-sdk-java/issues/239?email_source=notifications&email_token=ADGDUXL6DQS7HDAYMAFDRK3QRSBDPA5CNFSM4JFHYE5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC3663Q#issuecomment-548925294, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDUXNAA6GTM54BRBR4P5TQRSBDPANCNFSM4JFHYE5A .

abonander commented 4 years ago

Yes, some breaking changes needed to be made for it to work on API 21, anything higher would exclude too many devices. There is the breaking change detailed in that PR and also one in #245 which shouldn't affect most users (an interface was renamed and changed to an abstract class).

mehcode commented 4 years ago

The changes have been released in 0.8.0

See https://github.com/hashgraph/hedera-sdk-java/releases/tag/v0.8.0 for more information

johnda98 commented 4 years ago

Austin.. RE #239.. not wishing to re-open or raise new java-hhsdk issue.. , :-) I already had the okhttp:1.24.0 version in the app gradle.. and I edited to yes 0.8.0 for hh sdk

cool..

did clean project and re-build .. re-run and got the exact same error on getByteBuffer

saved and closed, re-open of studio and re-build and re-ran...

Its the same .. yep .. String tokensymbol = contractCallResult.getString();

yep where contractCallResult is FunctionResult of ContractCallQuery(client )

Smart contract is out there.. I hit it and make the same call to it via Eclipse ..

I'm still on API 26 and source and target gradle config .. as Compatibility JavaVersion.VERSION_1_8

John D Allen.

Leveridge Systems INC.

** Pls note New Mobile tel #

*T +1 417 849 0705 * CST | john.allen@leveridgesystems.com john.allen@leveridgesystems.com | https://www.leveridgesystems.com https://www.leveridgesystems.com | linkedin.com/in/johndallen1 http://linkedin.com/in/johndallen1 | skype john.allen_67 https://www.yourhashgraphtoken.com https://www.yourhashgraphtoken.com

This email is sent on behalf of Leveridge Systems INC. Reg.Ein 86-0905636.

The information contained in this email and any attached files is confidential and intended solely for the addressee(s). The email may be legally privileged or prohibited from disclosure and unauthorized use. If you are not the named addressee you may not use, copy, or disclose this information to any other person. If you received this message in error please notify the sender immediately and delete it from your system.

On Fri, Nov 1, 2019 at 3:32 PM Austin Bonander notifications@github.com wrote:

Yes, some breaking changes needed to be made for it to work on API 21, anything higher would exclude too many devices. There is the breaking change detailed in that PR and also one in #245 https://github.com/hashgraph/hedera-sdk-java/pull/245 which shouldn't affect most users (an interface was renamed and changed to an abstract class).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashgraph/hedera-sdk-java/issues/239?email_source=notifications&email_token=ADGDUXOUSPQP7QVQ7EI56ZDQRSG7VA5CNFSM4JFHYE5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC4CXOY#issuecomment-548940731, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDUXPQBFH3TDJTG4FEBG3QRSG7VANCNFSM4JFHYE5A .

abonander commented 4 years ago

Hi again John,

We accidentally built and deployed with JDK 11 which produced the erroneous bytecode. We're setting this up so it doesn't happen again and deploying 0.8.1.

johnda98 commented 4 years ago

Good man :-)

thnks

John D Allen.

Leveridge Systems INC.

** Pls note New Mobile tel #

*T +1 417 849 0705 * CST | john.allen@leveridgesystems.com john.allen@leveridgesystems.com | https://www.leveridgesystems.com https://www.leveridgesystems.com | linkedin.com/in/johndallen1 http://linkedin.com/in/johndallen1 | skype john.allen_67 https://www.yourhashgraphtoken.com https://www.yourhashgraphtoken.com

This email is sent on behalf of Leveridge Systems INC. Reg.Ein 86-0905636.

The information contained in this email and any attached files is confidential and intended solely for the addressee(s). The email may be legally privileged or prohibited from disclosure and unauthorized use. If you are not the named addressee you may not use, copy, or disclose this information to any other person. If you received this message in error please notify the sender immediately and delete it from your system.

On Tue, Nov 5, 2019 at 2:00 PM Austin Bonander notifications@github.com wrote:

Hi again John,

We accidentally built and deployed with JDK 11 which produced the erroneous bytecode. We're setting this up so it doesn't happen again and deploying 0.8.1.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashgraph/hedera-sdk-java/issues/239?email_source=notifications&email_token=ADGDUXLYTHNOQE47VW7KMW3QSHGHJA5CNFSM4JFHYE5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDEEA6Y#issuecomment-549994619, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDUXOQOENDECN4GMN3NVTQSHGHJANCNFSM4JFHYE5A .

johnda98 commented 4 years ago

Dallas HH HQ could hire me as QAQC ;)

:-))

John D Allen.

Leveridge Systems INC.

** Pls note New Mobile tel #

*T +1 417 849 0705 * CST | john.allen@leveridgesystems.com john.allen@leveridgesystems.com | https://www.leveridgesystems.com https://www.leveridgesystems.com | linkedin.com/in/johndallen1 http://linkedin.com/in/johndallen1 | skype john.allen_67 https://www.yourhashgraphtoken.com https://www.yourhashgraphtoken.com

This email is sent on behalf of Leveridge Systems INC. Reg.Ein 86-0905636.

The information contained in this email and any attached files is confidential and intended solely for the addressee(s). The email may be legally privileged or prohibited from disclosure and unauthorized use. If you are not the named addressee you may not use, copy, or disclose this information to any other person. If you received this message in error please notify the sender immediately and delete it from your system.

On Tue, Nov 5, 2019 at 2:00 PM Austin Bonander notifications@github.com wrote:

Hi again John,

We accidentally built and deployed with JDK 11 which produced the erroneous bytecode. We're setting this up so it doesn't happen again and deploying 0.8.1.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashgraph/hedera-sdk-java/issues/239?email_source=notifications&email_token=ADGDUXLYTHNOQE47VW7KMW3QSHGHJA5CNFSM4JFHYE5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDEEA6Y#issuecomment-549994619, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDUXOQOENDECN4GMN3NVTQSHGHJANCNFSM4JFHYE5A .

johnda98 commented 4 years ago

I remember the days when it was called machine code ;) google up a 'Research Machines 380Z' thats what I started out on.. and 8bit papertape on teletypes with acoustic couplers (a 300baud modem).. wild huh.

run me a msg when deployed - thanks mate.

Recommend Leemon hire me in .. I work remote with clients and have about 15hr a week to spare these days.

cheers again.

John D Allen.

Leveridge Systems INC.

** Pls note New Mobile tel #

*T +1 417 849 0705 * CST | john.allen@leveridgesystems.com john.allen@leveridgesystems.com | https://www.leveridgesystems.com https://www.leveridgesystems.com | linkedin.com/in/johndallen1 http://linkedin.com/in/johndallen1 | skype john.allen_67 https://www.yourhashgraphtoken.com https://www.yourhashgraphtoken.com

This email is sent on behalf of Leveridge Systems INC. Reg.Ein 86-0905636.

The information contained in this email and any attached files is confidential and intended solely for the addressee(s). The email may be legally privileged or prohibited from disclosure and unauthorized use. If you are not the named addressee you may not use, copy, or disclose this information to any other person. If you received this message in error please notify the sender immediately and delete it from your system.

On Tue, Nov 5, 2019 at 2:00 PM Austin Bonander notifications@github.com wrote:

Hi again John,

We accidentally built and deployed with JDK 11 which produced the erroneous bytecode. We're setting this up so it doesn't happen again and deploying 0.8.1.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashgraph/hedera-sdk-java/issues/239?email_source=notifications&email_token=ADGDUXLYTHNOQE47VW7KMW3QSHGHJA5CNFSM4JFHYE5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDEEA6Y#issuecomment-549994619, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGDUXOQOENDECN4GMN3NVTQSHGHJANCNFSM4JFHYE5A .

johnda98 commented 4 years ago

Screenshot from 2019-11-05 15-34-02

OK .. now we're cookin. all set. method call returned from contract.