JDK-8007748 : MacOSX build error : cast of type 'SEL' to 'uintptr_t' (aka 'unsigned long') is deprecated; use sel_getName instead
  • Type: Bug
  • Component: other-libs
  • Sub-Component: other
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2013-02-07
  • Updated: 2013-06-26
  • Resolved: 2013-02-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u40Fixed 8 b78Fixed
Description
JDK 7u on OS 10.8.2 with the latest public xcode
received the following error

     [exec] /Users/duke/src/java/jdk7u/jdk/src/macosx/native/jobjc/src/core/native/SEL.m:37:12: error: cast of type 'SEL' to 'uintptr_t' (aka 'unsigned long') is deprecated; use sel_getName instead [-Werror,-Wcast-of-sel-type]
     [exec]     return ptr_to_jlong(sel);
     [exec]            ^~~~~~~~~~~~~~~~~
     [exec] /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework/Headers/JNFJNI.h:42:44: note: expanded from macro 'ptr_to_jlong'
     [exec] #define ptr_to_jlong(a) ((jlong)(uintptr_t)(a))
     [exec]                                            ^~~
     [exec] 1 error generated.
     [exec]


---------------
The code that causes this error is the same in JDK 7 and JDK 8 :
    const SEL sel = sel_registerName(selNameAsChars);
    (*env)->ReleaseStringUTFChars(env, selName, selNameAsChars);
    return ptr_to_jlong(sel);


The error message seems to imply that users previously took advantage of the
returned pointer actually being the address of the string name, but now you
should call the getName function instead. That helpful message is going to
be wrong here since I believe we really *do* want the pointer and the correct fix is

-    return ptr_to_jlong(sel);
+    return ptr_to_jlong((void*)sel);

Can no one else in the world have tried building JDK7  with this latest xcode ?
Or is there something else likely to be the issue in his OS X envt ?

More details on the compilation environment in case that helps :

Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix

     [exec]
     [exec] CompileC /Users/duke/src/java/jdk7u/build/macosx-x86_64/JObjC.dst/Objects-normal/i386/SEL.o src/core/native/SEL.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
     [exec]     cd /Users/duke/src/java/jdk7u/jdk/src/macosx/native/jobjc
     [exec]     setenv LANG en_US.US-ASCII
     [exec] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch i386 -fmessage-length=0 -fobjc-gc -Wno-trigraphs -fpascal-strings -Os -Werror -Werror-implicit-function-declaration -Wno-missing-field-initializers -Wmissing-prototypes -Wreturn-type -Wno-implicit-atomic-properties -Wno-receiver-is-weak -Wformat -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-empty-body -Wuninitialized -Wunknown-pragmas -Wshadow -Wfour-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-enum-conversion -Wsign-compare -Wshorten-64-to-32 -Wpointer-sign -Wnewline-eof -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wno-deprecated-implementations -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -Wno-sign-conversion -I/Users/duke/src/java/jdk7u/build/macosx-x86_64/JObjC.dst/JObjC.hmap -I/Users/duke/src/java/jdk7u/build/macosx-x86_64/JObjC.dst/Debug/include -I/Users/duke/src/java/jdk7u/build/macosx-x86_64/JObjC.dst/Debug/src/jni_headers/core -I/Users/duke/src/java/jdk7u/build/macosx-x86_64/JObjC.build/src/jni_headers/core -I/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers -I/Users/duke/src/java/jdk7u/build/macosx-x86_64/JObjC.dst/DerivedSources/i386 -I/Users/duke/src/java/jdk7u/build/macosx-x86_64/JObjC.dst/DerivedSources -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -Wformat -Wformat-security -Wcast-align -Wwrite-strings -Wuninitialized -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wpointer-arith -Wall -F/Users/duke/src/java/jdk7u/build/macosx-x86_64/JObjC.dst/Debug -F/System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks -MMD -MT dependencies -MF /Users/duke/src/java/jdk7u/build/macosx-x86_64/JObjC.dst/Objects-normal/i386/SEL.d --serialize-diagnostics /Users/duke/src/java/jdk7u/build/macosx-x86_64/JObjC.dst/Objects-normal/i386/SEL.dia -c /Users/duke/src/java/jdk7u/jdk/src/macosx/native/jobjc/src/core/native/SEL.m -o /Users/duke/src/java/jdk7u/build/macosx-x86_64/JObjC.dst/Objects-normal/i386/SEL.o
     [exec] /Users/duke/src/java/jdk7u/jdk/src/macosx/native/jobjc/src/core/native/SEL.m:37:12: error: cast of type 'SEL' to 'uintptr_t' (aka 'unsigned long') is deprecated; use sel_getName instead [-Werror,-Wcast-of-sel-type]
     [exec]     return ptr_to_jlong(sel);
     [exec]            ^~~~~~~~~~~~~~~~~
     [exec] /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework/Headers/JNFJNI.h:42:44: note: expanded from macro 'ptr_to_jlong'
     [exec] #define ptr_to_jlong(a) ((jlong)(uintptr_t)(a))
     [exec]                                            ^~~
     [exec] 1 error generated.
     [exec]

Comments
Fixed with a cast to void*
2013-02-12