Closed ossdev07 closed 4 years ago
Hi @gnodet
Can you please look into the changes, and let us know if anything else is required from our side.
Seeing the package supporting the shared pointer would be a delight.
@gnodet Is there any update regarding the progress of this activity? Eagerly waiting for shared pointer support.
Hi @ossdev07 and @gnodet
As an Arm user, I have an interest in seeing this work landed. I've checked out the code, but it is unclear to me how to test. Can you advise how I can execute the test suite to test this functionality?
@gnodet please let me know if I can help with testing this PR
@rhenwood-arm SHARED_PTR
is a FIELD FLAG
We added the support in a hawtJNI generator to parse this field and generate the corresponding JNI.
To test this flag we have defined a variable CheckStr
with the SHARED_PTR field flag
,
We can see, when the hawtjni runs the test case, for variable CheckStr
JNI gets generated.
If you have any more queries, let me know. I will be more than to happy to explain it.
Thanks @ossdev07
One further question: what are the steps I need to go through to test this new functionality on a AArch64 machine?
@rhenwood-arm You just need to install all the dependencies and test the package
We can achieve it by the command mvn clean test
By this command, all the dependencies get to install, test cases get to run and we could see the result on console.
I'll try to review the PR this week.
Thanks @ossdev07. The self-test passes in my Java AArch64 container:
root@4066ed129600:/tmp/hawtjni# java --version
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment (build 11.0.2+9-Debian-3bpo91)
OpenJDK 64-Bit Server VM (build 11.0.2+9-Debian-3bpo91, mixed mode)
root@4066ed129600:/tmp/hawtjni# uname -a
Linux 4066ed129600 4.10.0-38-generic #42~16.04.1-Ubuntu SMP Tue Oct 10 16:33:57 UTC 2017 aarch64 GNU/Linux
root@4066ed129600:/tmp/hawtjni# mvn clean test
.
.
.
[INFO] ------------------------------------------------------------------------
[INFO] Building HawtJNI Example 1.17-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ hawtjni-example ---
[INFO] Deleting /tmp/hawtjni/hawtjni-example/target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ hawtjni-example ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /tmp/hawtjni/hawtjni-example/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ hawtjni-example ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /tmp/hawtjni/hawtjni-example/target/classes
[INFO]
[INFO] --- hawtjni-maven-plugin:1.17-SNAPSHOT:generate (default) @ hawtjni-example ---
[INFO] Analyzing classes...
[INFO] Generating...
[INFO] Wrote: /tmp/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example.cpp
[INFO] Wrote: /tmp/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_stats.h
[INFO] Wrote: /tmp/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_stats.cpp
[INFO] Wrote: /tmp/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_structs.h
[INFO] Wrote: /tmp/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_structs.cpp
[INFO] Wrote: /tmp/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni.h
[INFO] Wrote: /tmp/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni.c
[INFO] Wrote: /tmp/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-callback.c
[INFO] Wrote: /tmp/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/windows/stdint.h
[INFO] Done.
[INFO] executing: /bin/sh -c ./autogen.sh
[INFO]
[INFO] --- hawtjni-maven-plugin:1.17-SNAPSHOT:build (default) @ hawtjni-example ---
[INFO] executing: /bin/sh -c ./configure --disable-ccache --prefix=/tmp/hawtjni/hawtjni-example/target/native-build/target --libdir=/tmp/hawtjni/hawtjni-example/target/native-build/target/lib
[INFO] executing: /bin/sh -c make install
[INFO] Adding test resource root: /tmp/hawtjni/hawtjni-example/target/generated-sources/hawtjni/lib
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ hawtjni-example ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /tmp/hawtjni/hawtjni-example/src/test/resources
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:testCompile (default-testCompile) @ hawtjni-example ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /tmp/hawtjni/hawtjni-example/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.20:test (default-test) @ hawtjni-example ---
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.20/surefire-junit4-2.20.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.20/surefire-junit4-2.20.pom (4 KB at 4.6 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-providers/2.20/surefire-providers-2.20.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-providers/2.20/surefire-providers-2.20.pom (3 KB at 132.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.20/surefire-junit4-2.20.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.20/surefire-junit4-2.20.jar (81 KB at 758.6 KB/sec)
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running test.ExampleTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.24 s - in test.ExampleTest
[WARNING] Corrupted stdin stream in forked JVM 1. See the dump file /tmp/hawtjni/hawtjni-example/target/surefire-reports/2019-05-15T18-51-36_092-jvmRun1.dumpstream
[INFO] the JNIEnv is at: 88010b40
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] HawtJNI ............................................ SUCCESS [ 0.228 s]
[INFO] HawtJNI Runtime .................................... SUCCESS [ 5.061 s]
[INFO] HawtJNI Generator .................................. SUCCESS [ 4.018 s]
[INFO] HawtJNI Maven Plugin ............................... SUCCESS [ 5.343 s]
[INFO] HawtJNI Example .................................... SUCCESS [01:14 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:29 min
[INFO] Finished at: 2019-05-15T18:52:59+00:00
[INFO] Final Memory: 29M/560M
[INFO] ------------------------------------------------------------------------
@gnodet : have you had a chance to review this PR?
@gnodet Any update?
Any update on the comments ? I'd like to get rid of this PR. @ossdev07
Any update on the comments ? I'd like to get rid of this PR. @ossdev07
@gnodet please verify changes to support shared_ptr
@gnodet : have you had a chance to review this PR?
It does not seem to work for me:
[INFO] /bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I./src -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -arch x86_64 -arch i386 -g -O2 -I/usr/local/Cellar/adoptopenjdk-openjdk8/jdk8u172-b11/include -I/usr/local/Cellar/adoptopenjdk-openjdk8/jdk8u172-b11/include/darwin -c -o src/hawtjni-example_structs.lo src/hawtjni-example_structs.cpp
[INFO] libtool: compile: g++ -DHAVE_CONFIG_H -I. -I./src -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -arch x86_64 -arch i386 -g -O2 -I/usr/local/Cellar/adoptopenjdk-openjdk8/jdk8u172-b11/include -I/usr/local/Cellar/adoptopenjdk-openjdk8/jdk8u172-b11/include/darwin -c src/hawtjni-example_structs.cpp -fno-common -DPIC -o src/.libs/hawtjni-example_structs.o
[INFO] src/hawtjni-example_structs.cpp:78:19: error: no matching function for call to 'make_shared'
[INFO] set_sp(lpStruct, std::make_shared<intptr_t>(env->GetIntField(lpObject, barFc.CheckStr)));
[INFO] ^~~~~~~~~~~~~~~~~~~~~~~~~~
[INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:4734:1: note: candidate function [with _Tp = long, _A0 = int] not viable: expects an l-value for 1st argument
[INFO] make_shared(_A0& __a0)
[INFO] ^
[INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:4726:1: note: candidate function template not viable: requires 0 arguments, but 1 was provided
[INFO] make_shared()
[INFO] ^
[INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:4742:1: note: candidate function template not viable: requires 2 arguments, but 1 was provided
[INFO] make_shared(_A0& __a0, _A1& __a1)
[INFO] ^
[INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:4750:1: note: candidate function template not viable: requires 3 arguments, but 1 was provided
[INFO] make_shared(_A0& __a0, _A1& __a1, _A2& __a2)
[INFO] ^
[INFO] 1 error generated.
[INFO] make: *** [src/hawtjni-example_structs.lo] Error 1
[INFO] rc: 2
Also, the getter for the shared pointer is an int
, shouldn't it be a shared_ptr
somehow ?
Also, the getter for the shared pointer is an
int
, shouldn't it be ashared_ptr
somehow ?
@gnodet I was busy in some other assignment so sorry for late response .. modification done as per your suggestions .. please review ..
@ossdev07 this looks almost good to me but the example still fails to compile:
[INFO] src/foo.cpp:19:12: error: no viable conversion from returned value of type 'int' to function return type 'std::shared_ptr<intptr_t>' (aka 'shared_ptr<long>')
[INFO] return 0;
[INFO] ^
I think the return value needs to be changed to something else: https://github.com/fusesource/hawtjni/blob/44bb822466a1ae96bc2e406bc2766b6146d75d94/hawtjni-example/src/main/native-package/src/foo.cpp#L19
@ossdev07 this looks almost good to me but the example still fails to compile:
[INFO] src/foo.cpp:19:12: error: no viable conversion from returned value of type 'int' to function return type 'std::shared_ptr<intptr_t>' (aka 'shared_ptr<long>') [INFO] return 0; [INFO] ^
I think the return value needs to be changed to something else:
In our setup it is always pass , can you tell me how are you testing means command we ran "mvn clean install" and "mvn clean test" both are working properly
@ossdev07 this looks almost good to me but the example still fails to compile:
[INFO] src/foo.cpp:19:12: error: no viable conversion from returned value of type 'int' to function return type 'std::shared_ptr<intptr_t>' (aka 'shared_ptr<long>') [INFO] return 0; [INFO] ^
I think the return value needs to be changed to something else: https://github.com/fusesource/hawtjni/blob/44bb822466a1ae96bc2e406bc2766b6146d75d94/hawtjni-example/src/main/native-package/src/foo.cpp#L19
In our setup it is always pass , can you tell me how are you testing means command we ran "mvn clean install" and "mvn clean test" both are working properly
Just running mvn clean install
. I guess it depends on the native compiler somehow.
Here's a more complete log:
[INFO] ---------------< org.fusesource.hawtjni:hawtjni-example >---------------
[INFO] Building HawtJNI Example 1.18-SNAPSHOT [5/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ hawtjni-example ---
[INFO] Deleting /Users/gnodet/work/git/hawtjni/hawtjni-example/target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ hawtjni-example ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/gnodet/work/git/hawtjni/hawtjni-example/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ hawtjni-example ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/gnodet/work/git/hawtjni/hawtjni-example/target/classes
[INFO]
[INFO] --- hawtjni-maven-plugin:1.18-SNAPSHOT:generate (default) @ hawtjni-example ---
[INFO] Analyzing classes...
[INFO] Generating...
[INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example.cpp
[INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_stats.h
[INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_stats.cpp
[INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_structs.h
[INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_structs.cpp
[INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni.h
[INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni.c
[INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-callback.c
[INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/windows/stdint.h
[INFO] Done.
[INFO] executing: /bin/sh -c ./autogen.sh
[INFO]
[INFO] --- hawtjni-maven-plugin:1.18-SNAPSHOT:build (default) @ hawtjni-example ---
[INFO] executing: /bin/sh -c ./configure --disable-ccache --prefix=/Users/gnodet/work/git/hawtjni/hawtjni-example/target/native-build/target --libdir=/Users/gnodet/work/git/hawtjni/hawtjni-example/target/native-build/target/lib --with-universal
[INFO] executing: /bin/sh -c make install
[INFO] /bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I./src -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -arch i386 -g -O2 -I/Users/gnodet/.jenv/versions/1.8/include -I/Users/gnodet/.jenv/versions/1.8/include/darwin -c -o src/foo.lo src/foo.cpp
[INFO] libtool: compile: g++ -DHAVE_CONFIG_H -I. -I./src -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -arch i386 -g -O2 -I/Users/gnodet/.jenv/versions/1.8/include -I/Users/gnodet/.jenv/versions/1.8/include/darwin -c src/foo.cpp -fno-common -DPIC -o src/.libs/foo.o
[INFO] In file included from src/foo.cpp:9:
[INFO] ./src/foo.h:42:27: warning: 'get_sp' has C-linkage specified, but returns incomplete type 'std::shared_ptr<intptr_t>' (aka 'shared_ptr<long>') which could be incompatible with C [-Wreturn-type-c-linkage]
[INFO] std::shared_ptr<intptr_t> get_sp(struct foo *arg);
[INFO] ^
[INFO] src/foo.cpp:19:12: error: no viable conversion from returned value of type 'int' to function return type 'std::shared_ptr<intptr_t>' (aka 'shared_ptr<long>')
[INFO] return 0;
[INFO] ^
[INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3757:23: note: candidate constructor not viable: no known conversion from 'int' to 'std::__1::nullptr_t' for 1st argument
[INFO] _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT;
[INFO] ^
[INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3771:5: note: candidate constructor not viable: no known conversion from 'int' to 'const std::__1::shared_ptr<long> &' for 1st argument
[INFO] shared_ptr(const shared_ptr& __r) _NOEXCEPT;
[INFO] ^
[INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3774:9: note: candidate template ignored: could not match 'shared_ptr<type-parameter-0-0>' against 'int'
[INFO] shared_ptr(const shared_ptr<_Yp>& __r,
[INFO] ^
[INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3793:9: note: candidate template ignored: could not match 'auto_ptr<type-parameter-0-0>' against 'int'
[INFO] shared_ptr(auto_ptr<_Yp> __r,
[INFO] ^
[INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3818:9: note: candidate template ignored: could not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'int'
[INFO] shared_ptr(unique_ptr<_Yp, _Dp>,
[INFO] ^
[INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3827:9: note: candidate template ignored: could not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'int'
[INFO] shared_ptr(unique_ptr<_Yp, _Dp>,
[INFO] ^
[INFO] src/foo.cpp:25:141: error: cannot pass non-POD object of type 'std::shared_ptr<intptr_t>' (aka 'shared_ptr<long>') to variadic function; expected type from format string was 'int' [-Wnon-pod-varargs]
[INFO] printf("foo@%p: { a: %d, b: %d, c: \"%s\", prev: @%p, d: %f, Checkstr: %d}\n", arg, arg->a, (int)arg->b, arg->c, arg->prev, get_d(arg), get_sp(arg));
[INFO] ~~ ^~~~~~~~~~~
[INFO] src/foo.cpp:52:46: warning: format specifies type 'unsigned int' but the argument has type 'JNIEnv *' (aka 'JNIEnv_ *') [-Wformat]
[INFO] printf("%s, the JNIEnv is at: %x\n", who, env);
[INFO] ~~ ^~~
[INFO] 2 warnings and 2 errors generated.
[INFO] make: *** [src/foo.lo] Error 1
[INFO] rc: 2
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for HawtJNI 1.18-SNAPSHOT:
[INFO]
[INFO] HawtJNI ............................................ SUCCESS [ 0.231 s]
[INFO] HawtJNI Runtime .................................... SUCCESS [ 4.887 s]
[INFO] HawtJNI Generator .................................. SUCCESS [ 1.431 s]
[INFO] HawtJNI Maven Plugin ............................... SUCCESS [ 1.897 s]
[INFO] HawtJNI Example .................................... FAILURE [ 21.991 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.772 s
[INFO] Finished at: 2019-11-14T09:42:09+01:00
[INFO] ------------------------------------------------------------------------
@ossdev07 this looks almost good to me but the example still fails to compile:
[INFO] src/foo.cpp:19:12: error: no viable conversion from returned value of type 'int' to function return type 'std::shared_ptr<intptr_t>' (aka 'shared_ptr<long>') [INFO] return 0; [INFO] ^
I think the return value needs to be changed to something else: https://github.com/fusesource/hawtjni/blob/44bb822466a1ae96bc2e406bc2766b6146d75d94/hawtjni-example/src/main/native-package/src/foo.cpp#L19
In our setup it is always pass , can you tell me how are you testing means command we ran "mvn clean install" and "mvn clean test" both are working properly
Just running
mvn clean install
. I guess it depends on the native compiler somehow.Here's a more complete log:
[INFO] ---------------< org.fusesource.hawtjni:hawtjni-example >--------------- [INFO] Building HawtJNI Example 1.18-SNAPSHOT [5/5] [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ hawtjni-example --- [INFO] Deleting /Users/gnodet/work/git/hawtjni/hawtjni-example/target [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ hawtjni-example --- [debug] execute contextualize [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/gnodet/work/git/hawtjni/hawtjni-example/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ hawtjni-example --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 2 source files to /Users/gnodet/work/git/hawtjni/hawtjni-example/target/classes [INFO] [INFO] --- hawtjni-maven-plugin:1.18-SNAPSHOT:generate (default) @ hawtjni-example --- [INFO] Analyzing classes... [INFO] Generating... [INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example.cpp [INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_stats.h [INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_stats.cpp [INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_structs.h [INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-example_structs.cpp [INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni.h [INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni.c [INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/hawtjni-callback.c [INFO] Wrote: /Users/gnodet/work/git/hawtjni/hawtjni-example/target/generated-sources/hawtjni/native-src/windows/stdint.h [INFO] Done. [INFO] executing: /bin/sh -c ./autogen.sh [INFO] [INFO] --- hawtjni-maven-plugin:1.18-SNAPSHOT:build (default) @ hawtjni-example --- [INFO] executing: /bin/sh -c ./configure --disable-ccache --prefix=/Users/gnodet/work/git/hawtjni/hawtjni-example/target/native-build/target --libdir=/Users/gnodet/work/git/hawtjni/hawtjni-example/target/native-build/target/lib --with-universal [INFO] executing: /bin/sh -c make install [INFO] /bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I./src -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -arch i386 -g -O2 -I/Users/gnodet/.jenv/versions/1.8/include -I/Users/gnodet/.jenv/versions/1.8/include/darwin -c -o src/foo.lo src/foo.cpp [INFO] libtool: compile: g++ -DHAVE_CONFIG_H -I. -I./src -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -arch i386 -g -O2 -I/Users/gnodet/.jenv/versions/1.8/include -I/Users/gnodet/.jenv/versions/1.8/include/darwin -c src/foo.cpp -fno-common -DPIC -o src/.libs/foo.o [INFO] In file included from src/foo.cpp:9: [INFO] ./src/foo.h:42:27: warning: 'get_sp' has C-linkage specified, but returns incomplete type 'std::shared_ptr<intptr_t>' (aka 'shared_ptr<long>') which could be incompatible with C [-Wreturn-type-c-linkage] [INFO] std::shared_ptr<intptr_t> get_sp(struct foo *arg); [INFO] ^ [INFO] src/foo.cpp:19:12: error: no viable conversion from returned value of type 'int' to function return type 'std::shared_ptr<intptr_t>' (aka 'shared_ptr<long>') [INFO] return 0; [INFO] ^ [INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3757:23: note: candidate constructor not viable: no known conversion from 'int' to 'std::__1::nullptr_t' for 1st argument [INFO] _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; [INFO] ^ [INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3771:5: note: candidate constructor not viable: no known conversion from 'int' to 'const std::__1::shared_ptr<long> &' for 1st argument [INFO] shared_ptr(const shared_ptr& __r) _NOEXCEPT; [INFO] ^ [INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3774:9: note: candidate template ignored: could not match 'shared_ptr<type-parameter-0-0>' against 'int' [INFO] shared_ptr(const shared_ptr<_Yp>& __r, [INFO] ^ [INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3793:9: note: candidate template ignored: could not match 'auto_ptr<type-parameter-0-0>' against 'int' [INFO] shared_ptr(auto_ptr<_Yp> __r, [INFO] ^ [INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3818:9: note: candidate template ignored: could not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'int' [INFO] shared_ptr(unique_ptr<_Yp, _Dp>, [INFO] ^ [INFO] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3827:9: note: candidate template ignored: could not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'int' [INFO] shared_ptr(unique_ptr<_Yp, _Dp>, [INFO] ^ [INFO] src/foo.cpp:25:141: error: cannot pass non-POD object of type 'std::shared_ptr<intptr_t>' (aka 'shared_ptr<long>') to variadic function; expected type from format string was 'int' [-Wnon-pod-varargs] [INFO] printf("foo@%p: { a: %d, b: %d, c: \"%s\", prev: @%p, d: %f, Checkstr: %d}\n", arg, arg->a, (int)arg->b, arg->c, arg->prev, get_d(arg), get_sp(arg)); [INFO] ~~ ^~~~~~~~~~~ [INFO] src/foo.cpp:52:46: warning: format specifies type 'unsigned int' but the argument has type 'JNIEnv *' (aka 'JNIEnv_ *') [-Wformat] [INFO] printf("%s, the JNIEnv is at: %x\n", who, env); [INFO] ~~ ^~~ [INFO] 2 warnings and 2 errors generated. [INFO] make: *** [src/foo.lo] Error 1 [INFO] rc: 2 [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for HawtJNI 1.18-SNAPSHOT: [INFO] [INFO] HawtJNI ............................................ SUCCESS [ 0.231 s] [INFO] HawtJNI Runtime .................................... SUCCESS [ 4.887 s] [INFO] HawtJNI Generator .................................. SUCCESS [ 1.431 s] [INFO] HawtJNI Maven Plugin ............................... SUCCESS [ 1.897 s] [INFO] HawtJNI Example .................................... FAILURE [ 21.991 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 30.772 s [INFO] Finished at: 2019-11-14T09:42:09+01:00 [INFO] ------------------------------------------------------------------------
I checked in 3 different systems and its getting passed , i think it's because of some compilation settings, my systems has default configurations of compilation flags ..
[INFO] executing: /bin/sh -c ./configure --disable-ccache --prefix=/Users/gnodet/work/git/hawtjni/hawtjni-example/target/native-build/target --libdir=/Users/gnodet/work/git/hawtjni/hawtjni-example/target/native-build/target/lib --with-universal
I found one difference in your setup is "--with-universal" flag in configure command .. [INFO] executing: /bin/sh -c ./configure --disable-ccache --prefix=/Users/gnodet/work/git/hawtjni/hawtjni-example/target/native-build/target --libdir=/Users/gnodet/work/git/hawtjni/hawtjni-example/target/native-build/target/lib --with-universal
My C++ compiler seems to be more strict. Any way you could improve the example to not return 0, but use real getters / setters to access a shared pointer ? That would give me some confidence that this thing is actually working...
also, if that's still related to https://github.com/fusesource/rocksdbjni/pull/10 and if that's the only driver for supporting shared pointers, you may really want to investigate the RocksDB JNI layer provided by rocksdb directly.
Hi @gnodet
We have made changes as per your review comments and now we are returning non-zero value (i.e. shared_ptr) We modified code generation kept noted that java doesn't know pointer and shared_ptr. Java deals with variables/objects only.
Please refer to latest commit at this pull request 57
@gnodet it's long pending PR almost chasing for last 1 year, Please have a look on modifications. thank you for your support
@gnodet require your further review for this change.
Hi @gnodet
We have made changes as per your review comments and now we are returning non-zero value (i.e. shared_ptr) We modified code generation kept noted that java doesn't know pointer and shared_ptr. Java deals with variables/objects only.
Please refer to latest commit at this pull request 57
@gnodet require your further review for this change.
Hi @gnodet
We have made changes as per your review comments and now we are returning non-zero value (i.e. shared_ptr) We modified code generation kept noted that java doesn't know pointer and shared_ptr. Java deals with variables/objects only.
Please refer to latest commit at this pull request 57
@gnodet , Require your review and valuable suggestions. Thanks.
After having fixed a bunch of issues in the example (see https://github.com/gnodet/hawtjni/commits/ossdev07-shared_ptr_support), the compiler still does not build: there's a conversion error in the generated native code:
[INFO] --- hawtjni-maven-plugin:1.18-SNAPSHOT:build (default) @ hawtjni-example ---
[INFO] executing: /bin/sh -c ./configure --disable-ccache --prefix=/Users/gnodet/work/git/hawtjni/hawtjni-example/target/native-build/target --libdir=/Users/gnodet/work/git/hawtjni/hawtjni-example/target/native-build/target/lib --with-universal
[INFO] executing: /bin/sh -c make install
[INFO] /bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I./src -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -arch i386 -g -O2 -I/Users/gnodet/.jenv/versions/1.8/include -I/Users/gnodet/.jenv/versions/1.8/include/darwin -c -o src/foo.lo src/foo.cpp
[INFO] libtool: compile: g++ -DHAVE_CONFIG_H -I. -I./src -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -arch i386 -g -O2 -I/Users/gnodet/.jenv/versions/1.8/include -I/Users/gnodet/.jenv/versions/1.8/include/darwin -c src/foo.cpp -fno-common -DPIC -o src/.libs/foo.o
[INFO] /bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I./src -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -arch i386 -g -O2 -I/Users/gnodet/.jenv/versions/1.8/include -I/Users/gnodet/.jenv/versions/1.8/include/darwin -c -o src/hawtjni-example_structs.lo src/hawtjni-example_structs.cpp
[INFO] libtool: compile: g++ -DHAVE_CONFIG_H -I. -I./src -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -arch x86_64 -arch i386 -g -O2 -I/Users/gnodet/.jenv/versions/1.8/include -I/Users/gnodet/.jenv/versions/1.8/include/darwin -c src/hawtjni-example_structs.cpp -fno-common -DPIC -o src/.libs/hawtjni-example_structs.o
[INFO] src/hawtjni-example_structs.cpp:78:2: error: no matching function for call to 'set_sp'
[INFO] set_sp(lpStruct, std::make_shared<jlong>(env->GetLongField(lpObject, barFc.CheckStr)));
[INFO] ^~~~~~
[INFO] ./src/foo.h:61:6: note: candidate function not viable: no known conversion from 'shared_ptr<long long>' to 'shared_ptr<intptr_t>' for 2nd argument
[INFO] void set_sp(struct foo *arg, std::shared_ptr<intptr_t>);
[INFO] ^
[INFO] 1 error generated.
[INFO] make: *** [src/hawtjni-example_structs.lo] Error 1
[INFO] rc: 2
Hi @gnodet
Thanks for your review and build attempt. However I am unable to reproduce above issue at my system.
I tried our branch and your branch, here both reported success for command mvn clean install
. (Refer my log here)
If you think, this could be due to any environmental change, then please suggest me how can I reproduce the same...
Could this build difference be due to compiler version/flag difference (like using more strict/advance compiler) ?
I'm on OSX. I've been able to build the branch by switching to a recent gcc version instead of using the one that comes by default with OSX.
I'm on OSX. I've been able to build the branch by switching to a recent gcc version instead of using the one that comes by default with OSX.
Well, I can't make it succeed again :-( I'll investigate.
Hi @gnodet
If review of my system environment info suggests anything regarding this:
ubuntu@1pthunderx1-137:~$ gcc --version
gcc (Ubuntu/Linaro 8.4.0-1ubuntu1~18.04) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ubuntu@1pthunderx1-137:~$ ldd --version
ldd (Ubuntu GLIBC 2.29-0ubuntu2) 2.29
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
ubuntu@1pthunderx1-137:~$ env
SHELL=/bin/bash
rvm_prefix=/home/ubuntu
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-arm64
GRADLE_HOME=/opt/gradle/gradle-5.0
MY_RUBY_HOME=/home/ubuntu/.rvm/rubies/ruby-2.6.3
ANT_HOME=/usr/local/ant
RUBY_VERSION=ruby-2.6.3
PWD=/home/ubuntu
LOGNAME=ubuntu
XDG_SESSION_TYPE=tty
rvm_version=1.29.9 (latest)
HOME=/home/ubuntu
LANG=en_US.UTF-8
rvm_bin_path=/home/ubuntu/.rvm/bin
GEM_PATH=/home/ubuntu/.rvm/gems/ruby-2.6.3:/home/ubuntu/.rvm/gems/ruby-2.6.3@global
GEM_HOME=/home/ubuntu/.rvm/gems/ruby-2.6.3
XDG_SESSION_CLASS=user
TERM=xterm
LIBVIRT_DEFAULT_URI=qemu:///system
USER=ubuntu
SHLVL=1
XDG_RUNTIME_DIR=/run/user/1000
S_COLORS=auto
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
PATH=/home/ubuntu/.rvm/gems/ruby-2.6.3/bin:/home/ubuntu/.rvm/gems/ruby-2.6.3@global/bin:/home/ubuntu/.rvm/rubies/ruby-2.6.3/bin:/usr/lib/jvm/java-8-openjdk-arm64/bin:/opt/gradle/gradle-5.0/bin:/usr/local/ant/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/var/lib/snapd/snap/bin:/home/ubuntu/.rvm/bin
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
MAIL=/var/mail/ubuntu
SSH_TTY=/dev/pts/12
IRBRC=/home/ubuntu/.rvm/rubies/ruby-2.6.3/.irbrc
rvm_path=/home/ubuntu/.rvm
_=/usr/bin/env
I have not removed non-required info as well. If you require any more environment detail, then also please let me know.
Thanks.
on Mac, I'm getting the same error as @gnodet and really can't understand why this would have been closed. What was the solution?
on Mac, I'm getting the same error as @gnodet and really can't understand why this would have been closed. What was the solution?
I think I had to upgrade Xcode iirc.
As per the conversation in the PR #51 , provided the support of shared pointer along with an example.
Please consider the PR for the merge.