7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
authorohair
Tue, 11 Sep 2012 13:40:59 -0700
changeset 13678 5c8001201f98
parent 13508 7c6aa31ff1b2
child 13679 966380e1094f
7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__ 7180608: Sort the order of object files when building shared libraries Reviewed-by: ohrstrom, erikj, tbell
jdk/make/common/Defs.gmk
jdk/make/common/Demo.gmk
jdk/make/common/Library.gmk
jdk/make/common/Program.gmk
jdk/src/macosx/native/com/apple/laf/ScreenMenu.m
jdk/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiOut.c
jdk/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiUtils.c
jdk/src/macosx/native/sun/awt/CSystemColors.m
jdk/src/macosx/native/sun/awt/CTextPipe.m
jdk/src/macosx/native/sun/font/AWTStrike.m
jdk/src/share/back/error_messages.h
jdk/src/share/back/log_messages.h
jdk/src/share/demo/jvmti/hprof/debug_malloc.h
jdk/src/share/demo/jvmti/hprof/hprof_error.h
jdk/src/share/demo/jvmti/hprof/hprof_util.h
jdk/src/share/demo/jvmti/java_crw_demo/java_crw_demo.c
jdk/src/share/instrument/JPLISAssert.h
jdk/src/share/native/sun/awt/debug/debug_assert.h
jdk/src/share/native/sun/awt/debug/debug_mem.c
jdk/src/share/native/sun/awt/debug/debug_trace.h
jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h
jdk/src/share/npt/utf.h
jdk/src/share/transport/shmem/shmemBase.h
jdk/src/solaris/instrument/EncodingSupport_md.c
jdk/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiIn.cpp
jdk/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiOut.c
jdk/src/windows/native/sun/java2d/d3d/D3DPipeline.h
jdk/src/windows/native/sun/windows/alloc.h
jdk/src/windows/native/sun/windows/awt_Debug.h
jdk/src/windows/native/sun/windows/awt_Toolkit.h
jdk/src/windows/transport/shmem/shmem_md.c
--- a/jdk/make/common/Defs.gmk	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/make/common/Defs.gmk	Tue Sep 11 13:40:59 2012 -0700
@@ -542,6 +542,21 @@
 CXXFLAGS_$(VARIANT)/BYFILE  = $(CXXFLAGS_$(VARIANT)/$(@F)) \
                               $(CXXFLAGS_$(VARIANT)$(CXXFLAGS_$(VARIANT)/$(@F)))
 
+# Command line define to provide basename of file being compiled to source.
+#   The C macro THIS_FILE can replace the use of __FILE__ in the source
+#   files for the current filename being compiled.
+#   The value of the __FILE__ macro is unpredictable and can be anything
+#   from a relative path to a full path, THIS_FILE will be more consistent..
+#   The THIS_FILE macro will always be just the basename of the file being
+#   compiled.
+#   Different string literals in the the object files makes it difficult to
+#   compare shared libraries from different builds.
+#
+#   NOTE: If the THIS_FILE macro is actually expanded while in an included
+#         source file, it will not return the name of the included file.
+#
+CPP_THIS_FILE = -DTHIS_FILE='"$(<F)"'
+
 #
 # Tool flags
 #
@@ -551,7 +566,7 @@
 CFLAGS          = $(CFLAGS_$(VARIANT)/BYFILE)   $(CFLAGS_COMMON) $(OTHER_CFLAGS) $(EXTRA_CFLAGS)
 CXXFLAGS        = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS) $(EXTRA_CFLAGS)
 CPPFLAGS        = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) \
-		  $(DEFINES) $(OPTIONS:%=-D%)
+		  $(DEFINES) $(OPTIONS:%=-D%) $(CPP_THIS_FILE)
 LDFLAGS         = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS)
 LDLIBS          = $(OTHER_LDLIBS) $(LDLIBS_$(VARIANT)) $(LDLIBS_COMMON)
 LINTFLAGS       = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
--- a/jdk/make/common/Demo.gmk	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/make/common/Demo.gmk	Tue Sep 11 13:40:59 2012 -0700
@@ -320,10 +320,10 @@
   ifeq ($(PLATFORM),windows)
 	$(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(DEMO_VERSION_INFO) $(VERSIONINFO_RESOURCE)
 	$(LINK.demo) $(SHARED_LIBRARY_FLAG) -Fe$@ \
-	    $(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
+	    $(sort $(DEMO_FULL_OBJECTS)) $(LDLIBS.demo)
   else
 	$(LINK.demo) $(SHARED_LIBRARY_FLAG) -o $@ \
-	    $(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
+	    $(sort $(DEMO_FULL_OBJECTS)) $(LDLIBS.demo)
   endif
 	@$(call binary_file_verification,$@)
 
--- a/jdk/make/common/Library.gmk	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/make/common/Library.gmk	Tue Sep 11 13:40:59 2012 -0700
@@ -199,7 +199,7 @@
 $(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m)
 	@$(prep-target)
 	@$(MKDIR) -p $(TEMPDIR)
-	@$(ECHO) $(FILES_o) > $@ 
+	@$(ECHO) $(sort $(FILES_o)) > $@ 
 ifndef LOCAL_RESOURCE_FILE
 	@$(ECHO) $(OBJDIR)/$(LIBRARY).res >> $@
 endif
@@ -256,9 +256,9 @@
 	@$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), OPTIMIZATION_LEVEL=$(OPTIMIZATION_LEVEL)"
 	@$(ECHO) "Rebuilding $@ because of $?"
 ifeq ($(LIBRARY), fdlibm)
-	$(AR) $(ARFLAGS) $@ $(FILES_o)
+	$(AR) $(ARFLAGS) $@ $(sort $(FILES_o))
 else # LIBRARY
-	$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
+	$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(sort $(FILES_o)) $(LDLIBS)
 	@$(call binary_file_verification,$@)
 ifeq ($(WRITE_LIBVERSION),true)
 	$(MCS) -d -a "$(FULL_VERSION)" $@
--- a/jdk/make/common/Program.gmk	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/make/common/Program.gmk	Tue Sep 11 13:40:59 2012 -0700
@@ -242,7 +242,7 @@
 	$(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
 	@$(MKDIR) -p $(TEMPDIR)
 	$(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \
-	$(FILES_o) $(THREADLIBS) $(LDLIBS)
+	$(sort $(FILES_o)) $(THREADLIBS) $(LDLIBS)
   ifeq ($(findstring privileged, $(INFO_PLIST_FILE)), privileged)
 	-codesign -s openjdk_codesign $@
   endif
@@ -372,8 +372,6 @@
 VERSION_DEFINES += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
                    -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"'
 
-
-
 $(OBJDIR)/main.$(OBJECT_SUFFIX): $(LAUNCHER_SHARE_SRC)/bin/main.c
 	@$(prep-target)
 	$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$(OBJDIR)/main.$(OBJECT_SUFFIX) \
--- a/jdk/src/macosx/native/com/apple/laf/ScreenMenu.m	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/macosx/native/com/apple/laf/ScreenMenu.m	Tue Sep 11 13:40:59 2012 -0700
@@ -37,7 +37,11 @@
 #import "ThreadUtilities.h"
 #import "CMenuBar.h"
 
-
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__     
+#endif 
+ 
 static JNF_CLASS_CACHE(sjc_ScreenMenu, "com/apple/laf/ScreenMenu");
 
 static jint ns2awtModifiers(NSUInteger keyMods) {
@@ -97,7 +101,7 @@
 {
     if (self.javaObjectWrapper == nil) {
 #ifdef DEBUG
-        NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
+        NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
 #endif
         return;
     }
@@ -115,7 +119,7 @@
 {
     if (self.javaObjectWrapper == nil) {
 #ifdef DEBUG
-        NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
+        NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
 #endif
         return;
     }
@@ -133,7 +137,7 @@
 {
     if (self.javaObjectWrapper == nil) {
 #ifdef DEBUG
-        NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
+        NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
 #endif
         return;
     }
--- a/jdk/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiOut.c	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiOut.c	Tue Sep 11 13:40:59 2012 -0700
@@ -26,6 +26,11 @@
 //#define USE_ERROR
 //#define USE_TRACE
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #if USE_PLATFORM_MIDI_OUT == TRUE
 
 #include "PLATFORM_API_MacOSX_MidiUtils.h"
@@ -128,7 +133,7 @@
                 case 0xF7:
                     // System exclusive
                     fprintf(stderr, "%s: %d->internal error: sysex message status=0x%X while sending short message\n",
-                            __FILE__, __LINE__, data[0]);
+                            THIS_FILE, __LINE__, data[0]);
                     byteIsInvalid = TRUE;
                     break;
 
@@ -154,7 +159,7 @@
                 default:
                     // Invalid message
                     fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n",
-                            __FILE__, __LINE__, data[0]);
+                            THIS_FILE, __LINE__, data[0]);
                     byteIsInvalid = TRUE;
                     break;
             }
@@ -164,7 +169,7 @@
         default:
             // This can't happen, but handle it anyway.
             fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n",
-                    __FILE__, __LINE__, data[0]);
+                    THIS_FILE, __LINE__, data[0]);
             byteIsInvalid = TRUE;
             break;
     }
--- a/jdk/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiUtils.c	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_MidiUtils.c	Tue Sep 11 13:40:59 2012 -0700
@@ -42,6 +42,11 @@
 //#define USE_ERROR
 //#define USE_TRACE
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #if (USE_PLATFORM_MIDI_IN == TRUE) || (USE_PLATFORM_MIDI_OUT == TRUE)
 
 #include "PLATFORM_API_MacOSX_MidiUtils.h"
@@ -317,7 +322,7 @@
                             packedMsg = pendingMessageStatus | pendingData[0] << 8;
                         } else {
                             fprintf(stderr, "%s: %d->internal error: pendingMessageStatus=0x%X, pendingDataLength=%d\n",
-                                    __FILE__, __LINE__, pendingMessageStatus, pendingDataLength);
+                                    THIS_FILE, __LINE__, pendingMessageStatus, pendingDataLength);
                             byteIsInvalid = TRUE;
                         }
                         pendingDataLength = 0;
--- a/jdk/src/macosx/native/sun/awt/CSystemColors.m	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/macosx/native/sun/awt/CSystemColors.m	Tue Sep 11 13:40:59 2012 -0700
@@ -33,6 +33,11 @@
 
 #import "ThreadUtilities.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 NSColor **sColors = nil;
 NSColor **appleColors = nil;
 
@@ -130,7 +135,7 @@
         result = (useAppleColor ? appleColors : sColors)[colorIndex];
     }
     else {
-        NSLog(@"%s: %s %sColor: %ld not found, returning black.", __FILE__, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex);
+        NSLog(@"%s: %s %sColor: %ld not found, returning black.", THIS_FILE, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex);
         result = [NSColor blackColor];
     }
 
--- a/jdk/src/macosx/native/sun/awt/CTextPipe.m	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/macosx/native/sun/awt/CTextPipe.m	Tue Sep 11 13:40:59 2012 -0700
@@ -36,6 +36,10 @@
 #import "QuartzSurfaceData.h"
 #include "AWTStrike.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
 
 static const CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
 
@@ -488,7 +492,7 @@
         if (glyphs == NULL || advances == NULL)
         {
             (*env)->DeleteLocalRef(env, glyphsArray);
-            [NSException raise:NSMallocException format:@"%s-%s:%d", __FILE__, __FUNCTION__, __LINE__];
+            [NSException raise:NSMallocException format:@"%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__];
             return;
         }
 
--- a/jdk/src/macosx/native/sun/font/AWTStrike.m	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/macosx/native/sun/font/AWTStrike.m	Tue Sep 11 13:40:59 2012 -0700
@@ -33,6 +33,11 @@
 #import "CoreTextSupport.h"
 //#import "jni_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 @implementation AWTStrike
 
 static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
@@ -102,7 +107,7 @@
 #define AWT_FONT_CLEANUP_FINISH                                         \
     if (_fontThrowJavaException == YES) {                               \
         char s[512];                                                    \
-        sprintf(s, "%s-%s:%d", __FILE__, __FUNCTION__, __LINE__);       \
+        sprintf(s, "%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__);       \
         [JNFException raise:env as:kRuntimeException reason:s];         \
     }
 
--- a/jdk/src/share/back/error_messages.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/back/error_messages.h	Tue Sep 11 13:40:59 2012 -0700
@@ -42,31 +42,36 @@
 const char * eventText(int);
 const char * jdwpErrorText(jdwpError);
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define EXIT_ERROR(error,msg) \
         { \
                 print_message(stderr, "JDWP exit error ", "\n", \
                         "%s(%d): %s [%s:%d]", \
                         jvmtiErrorText((jvmtiError)error), error, (msg==NULL?"":msg), \
-                        __FILE__, __LINE__); \
+                        THIS_FILE, __LINE__); \
                 debugInit_exit((jvmtiError)error, msg); \
         }
 
 #define JDI_ASSERT(expression)  \
 do {                            \
     if (gdata && gdata->assertOn && !(expression)) {            \
-        jdiAssertionFailed(__FILE__, __LINE__, #expression); \
+        jdiAssertionFailed(THIS_FILE, __LINE__, #expression); \
     }                                           \
 } while (0)
 
 #define JDI_ASSERT_MSG(expression, msg)  \
 do {                            \
     if (gdata && gdata->assertOn && !(expression)) {            \
-        jdiAssertionFailed(__FILE__, __LINE__, msg); \
+        jdiAssertionFailed(THIS_FILE, __LINE__, msg); \
     }                                           \
 } while (0)
 
 #define JDI_ASSERT_FAILED(msg)  \
-   jdiAssertionFailed(__FILE__, __LINE__, msg)
+   jdiAssertionFailed(THIS_FILE, __LINE__, msg)
 
 void do_pause(void);
 
--- a/jdk/src/share/back/log_messages.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/back/log_messages.h	Tue Sep 11 13:40:59 2012 -0700
@@ -33,11 +33,15 @@
 
 #define LOG_NULL ((void)0)
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #ifdef JDWP_LOGGING
 
-
     #define _LOG(flavor,args) \
-                (log_message_begin(flavor,__FILE__,__LINE__), \
+                (log_message_begin(flavor,THIS_FILE,__LINE__), \
                  log_message_end args)
 
     #define LOG_TEST(flag)  (gdata->log_flags & (flag))
--- a/jdk/src/share/demo/jvmti/hprof/debug_malloc.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/demo/jvmti/hprof/debug_malloc.h	Tue Sep 11 13:40:59 2012 -0700
@@ -59,6 +59,11 @@
 #include <stdlib.h>
 #include <string.h>
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* The real functions behind the macro curtains. */
 
 void           *debug_malloc(size_t, const char *, int);
@@ -71,10 +76,10 @@
 
 void            debug_malloc_verify(const char*, int);
 #undef malloc_verify
-#define malloc_verify()     debug_malloc_verify(__FILE__, __LINE__)
+#define malloc_verify()     debug_malloc_verify(THIS_FILE, __LINE__)
 
 void            debug_malloc_police(const char*, int);
 #undef malloc_police
-#define malloc_police()     debug_malloc_police(__FILE__, __LINE__)
+#define malloc_police()     debug_malloc_police(THIS_FILE, __LINE__)
 
 #endif
--- a/jdk/src/share/demo/jvmti/hprof/hprof_error.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/demo/jvmti/hprof/hprof_error.h	Tue Sep 11 13:40:59 2012 -0700
@@ -41,20 +41,25 @@
 #ifndef HPROF_ERROR_H
 #define HPROF_ERROR_H
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Macros over assert and error functions so we can capture the source loc. */
 
 #define HPROF_BOOL(x) ((jboolean)((x)==0?JNI_FALSE:JNI_TRUE))
 
 #define HPROF_ERROR(fatal,msg) \
-    error_handler(HPROF_BOOL(fatal), JVMTI_ERROR_NONE, msg, __FILE__, __LINE__)
+    error_handler(HPROF_BOOL(fatal), JVMTI_ERROR_NONE, msg, THIS_FILE, __LINE__)
 
 #define HPROF_JVMTI_ERROR(error,msg) \
     error_handler(HPROF_BOOL(error!=JVMTI_ERROR_NONE), \
-            error, msg, __FILE__, __LINE__)
+            error, msg, THIS_FILE, __LINE__)
 
 #if defined(DEBUG) || !defined(NDEBUG)
     #define HPROF_ASSERT(cond) \
-        (((int)(cond))?(void)0:error_assert(#cond, __FILE__, __LINE__))
+        (((int)(cond))?(void)0:error_assert(#cond, THIS_FILE, __LINE__))
 #else
     #define HPROF_ASSERT(cond)
 #endif
@@ -77,11 +82,11 @@
 #define LOG_FORMAT(format)      "HPROF LOG: " format " [%s:%d]\n"
 
 #define LOG1(str1)              LOG_STDERR((stderr, LOG_FORMAT("%s"), \
-                                    str1, __FILE__, __LINE__ ))
+                                    str1, THIS_FILE, __LINE__ ))
 #define LOG2(str1,str2)         LOG_STDERR((stderr, LOG_FORMAT("%s %s"), \
-                                    str1, str2, __FILE__, __LINE__ ))
+                                    str1, str2, THIS_FILE, __LINE__ ))
 #define LOG3(str1,str2,num)     LOG_STDERR((stderr, LOG_FORMAT("%s %s 0x%x"), \
-                                    str1, str2, num, __FILE__, __LINE__ ))
+                                    str1, str2, num, THIS_FILE, __LINE__ ))
 
 #define LOG(str) LOG1(str)
 
--- a/jdk/src/share/demo/jvmti/hprof/hprof_util.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/demo/jvmti/hprof/hprof_util.h	Tue Sep 11 13:40:59 2012 -0700
@@ -41,6 +41,11 @@
 #ifndef HPROF_UTIL_H
 #define HPROF_UTIL_H
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Macros that protect code from accidently using a local ref improperly */
 #define WITH_LOCAL_REFS(env, number)            \
     {                                           \
@@ -184,8 +189,8 @@
 #ifdef DEBUG
     void *        hprof_debug_malloc(int size, char *file, int line);
     void          hprof_debug_free(void *ptr, char *file, int line);
-    #define HPROF_MALLOC(size)  hprof_debug_malloc(size, __FILE__, __LINE__)
-    #define HPROF_FREE(ptr)     hprof_debug_free(ptr, __FILE__, __LINE__)
+    #define HPROF_MALLOC(size)  hprof_debug_malloc(size, THIS_FILE, __LINE__)
+    #define HPROF_FREE(ptr)     hprof_debug_free(ptr, THIS_FILE, __LINE__)
 #else
     #define HPROF_MALLOC(size)  hprof_malloc(size)
     #define HPROF_FREE(ptr)     hprof_free(ptr)
--- a/jdk/src/share/demo/jvmti/java_crw_demo/java_crw_demo.c	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/demo/jvmti/java_crw_demo/java_crw_demo.c	Tue Sep 11 13:40:59 2012 -0700
@@ -70,12 +70,20 @@
 
 /* Macros over error functions to capture line numbers */
 
-#define CRW_FATAL(ci, message) fatal_error(ci, message, __FILE__, __LINE__)
+/* Fatal error used in all builds. */
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE "java_crw.demo.c" /* Never use __FILE__ */
+#endif
+
+#define CRW_FATAL(ci, message) fatal_error(ci, message, THIS_FILE, __LINE__)
 
 #if defined(DEBUG) || !defined(NDEBUG)
 
+  /* This assert macro is only used in the debug builds. */
   #define CRW_ASSERT(ci, cond) \
-        ((cond)?(void)0:assert_error(ci, #cond, __FILE__, __LINE__))
+        ((cond)?(void)0:assert_error(ci, #cond, THIS_FILE, __LINE__))
 
 #else
 
--- a/jdk/src/share/instrument/JPLISAssert.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/instrument/JPLISAssert.h	Tue Sep 11 13:40:59 2012 -0700
@@ -49,10 +49,14 @@
 #define JPLISASSERT_ENABLEASSERTIONS    (0)
 #endif
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
 
 #if JPLISASSERT_ENABLEASSERTIONS
-#define jplis_assert(x)             JPLISAssertCondition((jboolean)(x), #x, __FILE__, __LINE__)
-#define jplis_assert_msg(x, msg)    JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, __FILE__, __LINE__)
+#define jplis_assert(x)             JPLISAssertCondition((jboolean)(x), #x, THIS_FILE, __LINE__)
+#define jplis_assert_msg(x, msg)    JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, THIS_FILE, __LINE__)
 #else
 #define jplis_assert(x)
 #define jplis_assert_msg(x, msg)
--- a/jdk/src/share/native/sun/awt/debug/debug_assert.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/native/sun/awt/debug/debug_assert.h	Tue Sep 11 13:40:59 2012 -0700
@@ -32,17 +32,22 @@
 
 #include "debug_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #if defined(DEBUG)
 
 #define DASSERT(_expr) \
         if ( !(_expr) ) { \
-            DAssert_Impl( #_expr, __FILE__, __LINE__); \
+            DAssert_Impl( #_expr, THIS_FILE, __LINE__); \
         } else { \
         }
 
 #define DASSERTMSG(_expr, _msg) \
         if ( !(_expr) ) { \
-            DAssert_Impl( (_msg), __FILE__, __LINE__); \
+            DAssert_Impl( (_msg), THIS_FILE, __LINE__); \
         } else { \
         }
 
--- a/jdk/src/share/native/sun/awt/debug/debug_mem.c	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/native/sun/awt/debug/debug_mem.c	Tue Sep 11 13:40:59 2012 -0700
@@ -27,6 +27,11 @@
 
 #include "debug_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define DMEM_MIN(a,b)   (a) < (b) ? (a) : (b)
 #define DMEM_MAX(a,b)   (a) > (b) ? (a) : (b)
 
@@ -291,7 +296,7 @@
     DMutex_Enter(DMemMutex);
 
     /* Force memory leaks to be output regardless of trace settings */
-    DTrace_EnableFile(__FILE__, TRUE);
+    DTrace_EnableFile(THIS_FILE, TRUE);
     DTRACE_PRINTLN("--------------------------");
     DTRACE_PRINTLN("Debug Memory Manager Leaks");
     DTRACE_PRINTLN("--------------------------");
--- a/jdk/src/share/native/sun/awt/debug/debug_trace.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/native/sun/awt/debug/debug_trace.h	Tue Sep 11 13:40:59 2012 -0700
@@ -34,6 +34,11 @@
 
 #include "debug_util.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 typedef int     dtrace_id;
 enum {
     UNDEFINED_TRACE_ID = -1 /* indicates trace point has not been registered yet */
@@ -69,7 +74,7 @@
 #define _DTrace_Template(_func, _ac, _f, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) \
 { \
     static dtrace_id _dt_lineid_ = UNDEFINED_TRACE_ID; \
-    DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, __FILE__, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
+    DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, THIS_FILE, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
 }
 
 /* printf style trace macros */
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h	Tue Sep 11 13:40:59 2012 -0700
@@ -452,7 +452,12 @@
 void *p11malloc(size_t c, char *file, int line);
 void p11free(void *p, char *file, int line);
 
-#define malloc(c)       (p11malloc((c), __FILE__, __LINE__))
-#define free(c)         (p11free((c), __FILE__, __LINE__))
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
+#define malloc(c)       (p11malloc((c), THIS_FILE, __LINE__))
+#define free(c)         (p11free((c), THIS_FILE, __LINE__))
 
 #endif
--- a/jdk/src/share/npt/utf.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/npt/utf.h	Tue Sep 11 13:40:59 2012 -0700
@@ -33,8 +33,13 @@
 #include "jni.h"
 #include "utf_md.h"
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Error and assert macros */
-#define UTF_ERROR(m) utfError(__FILE__, __LINE__,  m)
+#define UTF_ERROR(m) utfError(THIS_FILE, __LINE__,  m)
 #define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 )
 
 void utfError(char *file, int line, char *message);
--- a/jdk/src/share/transport/shmem/shmemBase.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/share/transport/shmem/shmemBase.h	Tue Sep 11 13:40:59 2012 -0700
@@ -49,11 +49,16 @@
 jint shmemBase_name(SharedMemoryTransport *, char **name);
 jint shmemBase_getlasterror(char *msg, jint size);
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #ifdef DEBUG
 #define SHMEM_ASSERT(expression)  \
 do {                            \
     if (!(expression)) {                \
-        exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \
+        exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \
     } \
 } while (0)
 #else
@@ -63,7 +68,7 @@
 #define SHMEM_GUARANTEE(expression) \
 do {                            \
     if (!(expression)) {                \
-        exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \
+        exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \
     } \
 } while (0)
 
--- a/jdk/src/solaris/instrument/EncodingSupport_md.c	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/solaris/instrument/EncodingSupport_md.c	Tue Sep 11 13:40:59 2012 -0700
@@ -33,8 +33,13 @@
 
 /* Routines to convert back and forth between Platform Encoding and UTF-8 */
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /* Error and assert macros */
-#define UTF_ERROR(m) utfError(__FILE__, __LINE__,  m)
+#define UTF_ERROR(m) utfError(THIS_FILE, __LINE__,  m)
 #define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 )
 #define UTF_DEBUG(x)
 
--- a/jdk/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiIn.cpp	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiIn.cpp	Tue Sep 11 13:40:59 2012 -0700
@@ -35,9 +35,15 @@
 
 #ifdef USE_ERROR
 #include <stdio.h>
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define MIDIIN_CHECK_ERROR { \
         if (err != MMSYSERR_NOERROR) \
-            ERROR3("MIDI IN Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \
+            ERROR3("MIDI IN Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \
     }
 #else
 #define MIDIIN_CHECK_ERROR
--- a/jdk/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiOut.c	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_MidiOut.c	Tue Sep 11 13:40:59 2012 -0700
@@ -33,9 +33,15 @@
 
 #ifdef USE_ERROR
 #include <stdio.h>
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define MIDIOUT_CHECK_ERROR  { \
         if (err != MMSYSERR_NOERROR) \
-            ERROR3("MIDI OUT Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \
+            ERROR3("MIDI OUT Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \
         }
 #else
 #define MIDIOUT_CHECK_ERROR
--- a/jdk/src/windows/native/sun/java2d/d3d/D3DPipeline.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/windows/native/sun/java2d/d3d/D3DPipeline.h	Tue Sep 11 13:40:59 2012 -0700
@@ -28,6 +28,11 @@
 #define D3D_DEBUG_INFO
 #endif // DEBUG
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE THIS_FILE
+#endif
+
 #ifdef D3D_PPL_DLL
 
 
@@ -104,7 +109,7 @@
 #define ACT_IF_NULL(ACTION, value)         \
     if ((value) == NULL) {                 \
         J2dTraceLn3(J2D_TRACE_ERROR,       \
-                    "%s is null in %s:%d", #value, __FILE__, __LINE__); \
+                    "%s is null in %s:%d", #value, THIS_FILE, __LINE__); \
         ACTION;                            \
     } else do { } while (0)
 #define RETURN_IF_NULL(value)   ACT_IF_NULL(return, value)
@@ -114,12 +119,12 @@
 
 #define RETURN_STATUS_IF_EXP_FAILED(EXPR) \
     if (FAILED(res = (EXPR))) {                    \
-        DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## __FILE__); \
+        DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## THIS_FILE); \
         return res;                   \
     } else do { } while (0)
 
 #define RETURN_STATUS_IF_FAILED(status) \
     if (FAILED((status))) {                    \
-        DebugPrintD3DError((status), " failed in " ## __FILE__ ## ", return;");\
+        DebugPrintD3DError((status), " failed in " ## THIS_FILE ## ", return;");\
         return (status);                   \
     } else do { } while (0)
--- a/jdk/src/windows/native/sun/windows/alloc.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/windows/native/sun/windows/alloc.h	Tue Sep 11 13:40:59 2012 -0700
@@ -26,6 +26,11 @@
 #ifndef _ALLOC_H_
 #define _ALLOC_H_
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #include "stdhdrs.h"
 
 // By defining std::bad_alloc in a local header file instead of including
@@ -127,12 +132,12 @@
         throw (std::bad_alloc);
 
     #define safe_Malloc(size) \
-        safe_Malloc_outofmem(size, __FILE__, __LINE__)
+        safe_Malloc_outofmem(size, THIS_FILE, __LINE__)
     #define safe_Calloc(num, size) \
-        safe_Calloc_outofmem(num, size, __FILE__, __LINE__)
+        safe_Calloc_outofmem(num, size, THIS_FILE, __LINE__)
     #define safe_Realloc(memblock, size) \
-        safe_Realloc_outofmem(memblock, size, __FILE__, __LINE__)
-    #define new new(__FILE__, __LINE__)
+        safe_Realloc_outofmem(memblock, size, THIS_FILE, __LINE__)
+    #define new new(THIS_FILE, __LINE__)
 #endif /* OUTOFMEM_TEST */
 
 #define TRY \
--- a/jdk/src/windows/native/sun/windows/awt_Debug.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/windows/native/sun/windows/awt_Debug.h	Tue Sep 11 13:40:59 2012 -0700
@@ -65,7 +65,12 @@
     #define AWT_DUMP_CLIP_RECTANGLE(_msg, _hwnd) \
         _DTrace_Template(DumpClipRectangle, 2, "", (_msg), (_hwnd), 0, 0, 0, 0, 0, 0)
 
-    #define new         new(__FILE__, __LINE__)
+    /* Use THIS_FILE when it is available. */
+    #ifndef THIS_FILE
+        #define THIS_FILE __FILE__
+    #endif
+
+    #define new         new(THIS_FILE, __LINE__)
 
     #define VERIFY(exp)         DASSERT(exp)
     #define UNIMPLEMENTED()     DASSERT(FALSE)
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.h	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.h	Tue Sep 11 13:40:59 2012 -0700
@@ -132,24 +132,30 @@
 
 // Macros for using CriticalSection objects that help trace
 // lock/unlock actions
+
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 #define CRITICAL_SECTION_ENTER(cs) { \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Wait:  tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
     (cs).Enter(); \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Enter: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
 }
 
 #define CRITICAL_SECTION_LEAVE(cs) { \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Leave: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
     (cs).Leave(); \
     J2dTraceLn4(J2D_TRACE_VERBOSE2, \
                 "CS.Left:  tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
-                GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
+                GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
 }
 
 /************************************************************************
--- a/jdk/src/windows/transport/shmem/shmem_md.c	Wed Jul 05 18:20:34 2017 +0200
+++ b/jdk/src/windows/transport/shmem/shmem_md.c	Tue Sep 11 13:40:59 2012 -0700
@@ -30,6 +30,11 @@
 #include "sysShmem.h"
 #include "shmemBase.h"  /* for exitTransportWithError */
 
+/* Use THIS_FILE when it is available. */
+#ifndef THIS_FILE
+    #define THIS_FILE __FILE__
+#endif
+
 /*
  * These functions are not completely universal. For now, they are used
  * exclusively for Jbug's shared memory transport mechanism. They have
@@ -44,7 +49,7 @@
     if (!(expression)) {                \
             exitTransportWithError \
             ("\"%s\", line %d: assertion failure\n", \
-             __FILE__, __DATE__, __LINE__); \
+             THIS_FILE, __DATE__, __LINE__); \
     }                                   \
 }
 #else