United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-8007748 MacOSX build error : cast of type 'SEL' to 'uintptr_t' (aka 'unsigned long') is deprecated; use sel_getName instead
JDK-8007748 : MacOSX build error : cast of type 'SEL' to 'uintptr_t' (aka 'unsigned long') is deprecated; use sel_getName instead

Details
Type:
Bug
Submit Date:
2013-02-07
Status:
Resolved
Updated Date:
2013-02-22
Project Name:
JDK
Resolved Date:
2013-02-12
Component:
other-libs
OS:
os_x
Sub-Component:
other
CPU:
Priority:
P3
Resolution:
Fixed
Affected Versions:
Fixed Versions:

Related Reports
Backport:

Sub Tasks

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
URL:   http://hg.openjdk.java.net/jdk8/2d/jdk/rev/5f0217537435
User:  prr
Date:  2013-02-12 17:58:56 +0000

                                     
2013-02-12
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/5f0217537435
User:  lana
Date:  2013-02-15 17:35:39 +0000

                                     
2013-02-15



Hardware and Software, Engineered to Work Together