This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for Preview: jcf-io.c and Win32 case-insensitive filename handling


Hi Andrew and Ranjit,

Mohan>> I'm asking this because there are a few strategic opens / fopens
Mohan>> in jcf-*.c which, if you checked for the existence of the file
Mohan>> of the exact case on Win32, you would get the compiler working
Mohan>> on MingW.

Andrew> Go for it.

This proposed patch aims to resolve gcj compilation glitches due
to the Win32 case-insensitive filesystem. For my native MingW
build, I initially had a hacked up jcf-io.c which simulated checking
the exact case of the .java or .class file to open. This is an attempt
at the real deal. It also attempts to open the door at accomodating
other case-insensitive filesystems.

I would have liked to do something like an AC_LINK_FILES and AC_DEFINE
and avoid the ugly #ifdef-ing in the source files themselves. However, I
was thwarted in this by not having a configure.in at the gcc/java level.
Could this be done better?

Here is my defense of this patch: Andrew had mentioned that he was
worried about introducing platform-specific stuff in the front end and argued
that such functionality might better be moved to the runtime library. However,
in this case, it isn't a question of enforcing strict case checking throughout
the entire compilation process. In fact, Ranjit even has patches which do
exactly the opposite for certain file types. However, public Java classes
must exist in same-named, same-case source files and therefore (cringe),
I believe that it's the compiler's job (and not the runtime's job) to enforce
case-strictness for these specific instances on case-insensitive filesystems.
Since there is no portable way of doing this, it stands to reason that
platform-specific code must trickle into the front end. Does this make sense
or am I full of it?

I've put the patch itself in the body of this email, but am attaching jcf-win32.c,
which would be a new repository file, as well as a test case which fails
without this patch.

-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/

ChangeLog
2003-03-10  Mohan Embar  <gnustuff at thisiscool dot com>

	* jcf-win32.c: added to repository. Defines
	Win32-specific jcf_open_exact_case()
	* Make-lang.in: added jcf-win32.c
	* jcf.h: defined macro JCF_OPEN_EXACT_CASE which
	resolves to open() on non-Win32 platforms and
	Win32-specific jcf_open_exact_case() on Win32
	* jcf-io.c: use JCF_OPEN_EXACT_CASE when trying
	.java and .class files

Index: Make-lang.in
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/java/Make-lang.in,v
retrieving revision 1.91.12.3
diff -u -2 -r1.91.12.3 Make-lang.in
--- Make-lang.in	26 Jan 2003 11:31:19 -0000	1.91.12.3
+++ Make-lang.in	11 Mar 2003 04:06:29 -0000
@@ -107,16 +107,16 @@
 JAVA_OBJS = java/parse.o java/class.o java/decl.o java/expr.o \
   java/constants.o java/lang.o java/typeck.o java/except.o java/verify.o \
-  java/zextract.o java/jcf-io.o java/jcf-parse.o java/mangle.o \
-  java/mangle_name.o java/builtins.o \
+  java/zextract.o java/jcf-io.o java/jcf-win32.o java/jcf-parse.o \
+  java/mangle.o java/mangle_name.o java/builtins.o \
   java/jcf-write.o java/buffer.o java/check-init.o java/jcf-depend.o \
   java/jcf-path.o java/xref.o java/boehm.o java/java-tree-inline.o mkdeps.o
 
-GCJH_OBJS = java/gjavah.o java/jcf-io.o java/jcf-depend.o java/jcf-path.o \
-  java/zextract.o version.o mkdeps.o errors.o
+GCJH_OBJS = java/gjavah.o java/jcf-io.o java/jcf-win32.o java/jcf-depend.o \
+  java/jcf-path.o java/zextract.o version.o mkdeps.o errors.o
 
 JVSCAN_OBJS = java/parse-scan.o java/jv-scan.o version.o
 
-JCFDUMP_OBJS = java/jcf-dump.o java/jcf-io.o java/jcf-depend.o java/jcf-path.o \
-		java/zextract.o errors.o version.o mkdeps.o
+JCFDUMP_OBJS = java/jcf-dump.o java/jcf-io.o java/jcf-win32.o java/jcf-depend.o \
+  java/jcf-path.o java/zextract.o errors.o version.o mkdeps.o
 
 JVGENMAIN_OBJS = java/jvgenmain.o java/mangle_name.o errors.o
@@ -302,4 +302,5 @@
   input.h java/java-except.h $(SYSTEM_H) toplev.h java/parse.h $(GGC_H) \
   debug.h real.h gt-java-jcf-parse.h
+java/jcf-win32.o: java/jcf-win32.c $(CONFIG_H) $(SYSTEM_H) java/jcf.h
 java/jcf-write.o: java/jcf-write.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h \
   $(RTL_H) java/java-opcodes.h java/parse.h java/buffer.h $(SYSTEM_H) \
Index: jcf-io.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/java/jcf-io.c,v
retrieving revision 1.36.2.2
diff -u -2 -r1.36.2.2 jcf-io.c
--- jcf-io.c	10 Mar 2003 19:32:23 -0000	1.36.2.2
+++ jcf-io.c	11 Mar 2003 04:06:30 -0000
@@ -554,5 +554,5 @@
 			      (classname_length <= 30 ? 
 			       classname_length : 30)));
-      fd = open (buffer, O_RDONLY | O_BINARY);
+      fd = JCF_OPEN_EXACT_CASE (buffer, O_RDONLY | O_BINARY);
       if (fd >= 0)
 	goto found;
@@ -566,5 +566,5 @@
 			      (classname_length <= 30 ? 
 			       classname_length : 30)));
-      fd = open (buffer, O_RDONLY);
+      fd = JCF_OPEN_EXACT_CASE (buffer, O_RDONLY);
       if (fd >= 0)
 	{
Index: jcf.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/java/jcf.h,v
retrieving revision 1.31.20.1
diff -u -2 -r1.31.20.1 jcf.h
--- jcf.h	7 Mar 2003 04:39:46 -0000	1.31.20.1
+++ jcf.h	11 Mar 2003 04:06:31 -0000
@@ -82,4 +82,21 @@
 #endif
 
+/* On case-insensitive file systems, we need to ensure that a request
+   to open a .java or .class file is honored only if the file to be
+   opened is of the exact case we are asking for. In other words, we
+   want to override the inherent case insensitivity of the underlying
+   file system. On other platforms, this macro becomes the vanilla
+   open() call.
+
+   If you want to add another OS, add your define to the list below
+   (i.e. defined(WIN32) || defined(YOUR_OS)) and add an OS-specific
+   .c file to Make-lang.in similar to jcf-win32.c  */
+#if defined(WIN32)
+  extern int jcf_open_exact_case(const char* filename, int oflag);
+  #define JCF_OPEN_EXACT_CASE(x,y) jcf_open_exact_case(x, y)
+#else
+  #define JCF_OPEN_EXACT_CASE open
+#endif
+
 struct JCF;
 typedef int (*jcf_filbuf_t) PARAMS ((struct JCF*, int needed));

Attachment: ExactCase.zip
Description: Zip archive

Attachment: jcf-win32.c
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]