Help with adding a native method
tom.rodriguez at oracle.com
Wed Mar 21 10:48:41 PDT 2012
One issue is you've duplicated a signature with a different name which may cause unexpected problems:
do_signature(compareAndSwapObject_signature, "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z") \
+ do_signature(myCompareAndSwapObject_signature, "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z") \
There's a mapping between Symbol* and enumeration values and duplicating Symbols will break that though I'm not sure what exactly will go wrong.
Additionally I think you need to register your new method using a separate RegisterMethods call. Otherwise your JVM won't be able to bootstrap when run with a JDK that is missing the Unsafe method. I suspect that's what's happening here. Errors during bootstrap lead to mysterious failures.
On Mar 21, 2012, at 8:18 AM, Ilya Mirsky wrote:
> Following my post from a week ago, I'm trying to add a native method to the unsafe class.
> For a start I'm trying to duplicate an existing method (CompareAndSwap).
> I added the new method, and registered it in the unsafe.cpp file and in vmSymbols.hpp (a patch is attached).
> When I'm compiling the jdk I get the following error from test_gamma:
> cd linux_i486_compiler2/product && ./test_gamma
> java full version "1.6.0_22-b22"
> Using java runtime at: /usr/lib/jvm/java-6-openjdk/jre
> Error occurred during initialization of VM
> at java.util.Hashtable.put(Hashtable.java:411)
> at java.lang.System.initProperties(Native Method)
> at java.lang.System.initializeSystemClass(System.java:1069)
> What am I doing wrong?
> Any help will be highly appreciated
> Best Regards,
> Ilya Mirsky
More information about the hotspot-dev