public inbox for rhug-rhats@sourceware.org
 help / color / mirror / Atom feed
* gcj -C bug in xalan
@ 2001-09-09  9:41 Anthony Green
  2001-09-10 13:24 ` Alexandre Petit-Bianco
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Anthony Green @ 2001-09-09  9:41 UTC (permalink / raw)
  To: apbianco; +Cc: rhug-rhats

Hi Alex -

   I recently checked in changes to build Xalan .class files before
the object code.  For this to work, I had to add the following bits...


%.class: %.java
	$(GCJ) -C --encoding=UTF-8 $(CLASSPATH) -O2 -d upstream/src $<

# Work around a gcj bug by putting the srcdir at the front of the classpath.
upstream/src/org/apache/xalan/xsltc/compiler/util/NodeType.class: upstream/src/org/apache/xalan/xsltc/compiler/util/NodeType.java
	gcj -C --encoding=UTF-8 -fCLASSPATH=$(srcdir)/upstream/src:../xerces/upstream/src:../BCEL/upstream:../cup/upstream:$(srcdir)/upstream/src -O2 -d upstream/src $(srcdir)/upstream/src/org/apache/xalan/xsltc/compiler/util/NodeType.java
upstream/src/org/apache/xalan/xsltc/compiler/util/Type.class: upstream/src/org/apache/xalan/xsltc/compiler/util/Type.java
	gcj -C --encoding=UTF-8 -fCLASSPATH=$(srcdir)/upstream/src:../xerces/upstream/src:../BCEL/upstream:../cup/upstream:$(srcdir)/upstream/src -O2 -d upstream/src $(srcdir)/upstream/src/org/apache/xalan/xsltc/compiler/util/Type.java

   The default rule has the classpath starting with upstream/src (the
build directory).  However, when building NoteType.class and
Type.class, gcj -C fails when it has to read generated class files
first.  The exceptions above force the $(srcdir)/upstream/src to the
front of the classpath as a work around.  If you remove them you'll
see errors like...

gcj -C --encoding=UTF-8 -fCLASSPATH=upstream/src:../xerces/upstream/src:../BCEL/upstream:../cup/upstream:/fencer/cutlass/aph/green/cvs/rhug/xalan/upstream/src -O2 -d upstream/src /fencer/cutlass/aph/green/cvs/rhug/xalan/upstream/src/org/apache/xalan/xsltc/compiler/util/Type.java
/fencer/cutlass/aph/green/cvs/rhug/xalan/upstream/src/org/apache/xalan/xsltc/compiler/NodeTest.java:79: Undefined variable or class name: `DOM'.
       public static final int ANODE     = DOM.FIRST_TYPE - 1;
                                           ^
/fencer/cutlass/aph/green/cvs/rhug/xalan/upstream/src/org/apache/xalan/xsltc/compiler/NodeTest.java:72: Undefined variable or class name: `DOM'.
       public static final int ROOT      = DOM.ROOT;
                                           ^
/fencer/cutlass/aph/green/cvs/rhug/xalan/upstream/src/org/apache/xalan/xsltc/compiler/NodeTest.java:73: Undefined variable or class name: `DOM'.
       public static final int ELEMENT   = DOM.ELEMENT;
                                           ^
/fencer/cutlass/aph/green/cvs/rhug/xalan/upstream/src/org/apache/xalan/xsltc/compiler/NodeTest.java:74: Undefined variable or class name: `DOM'.
       public static final int ATTRIBUTE = DOM.ATTRIBUTE;
                                           ^
/fencer/cutlass/aph/green/cvs/rhug/xalan/upstream/src/org/apache/xalan/xsltc/compiler/NodeTest.java:69: Undefined variable or class name: `DOM'.
       public static final int TEXT      = DOM.TEXT;
                                           ^
/fencer/cutlass/aph/green/cvs/rhug/xalan/upstream/src/org/apache/xalan/xsltc/compiler/NodeTest.java:70: Undefined variable or class name: `DOM'.
       public static final int COMMENT   = DOM.COMMENT;
                                           ^
/fencer/cutlass/aph/green/cvs/rhug/xalan/upstream/src/org/apache/xalan/xsltc/compiler/NodeTest.java:71: Undefined variable or class name: `DOM'.
       public static final int PI        = DOM.PROCESSING_INSTRUCTION;
                                           ^
7 errors
make: *** [upstream/src/org/apache/xalan/xsltc/compiler/util/Type.class] Error 1


      Any ideas?

AG

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gcj -C bug in xalan
  2001-09-09  9:41 gcj -C bug in xalan Anthony Green
@ 2001-09-10 13:24 ` Alexandre Petit-Bianco
  2001-09-10 13:33   ` Anthony Green
  2001-09-10 13:42   ` Anthony Green
  2001-09-11  1:21 ` Alexandre Petit-Bianco
  2001-09-13 15:14 ` Alexandre Petit-Bianco
  2 siblings, 2 replies; 8+ messages in thread
From: Alexandre Petit-Bianco @ 2001-09-10 13:24 UTC (permalink / raw)
  To: rhug-rhats

Anthony Green writes:

>       Any ideas?

FYI, I'm looking into it. On the other hand, I'm getting some other
build errors:

cj -C --encoding=UTF-8 -fCLASSPATH=upstream/src:../xerces/upstream/src:../BCEL/upstream:../cup/upstream:/home/apbianco/src/rhug/xalan/upstream/src -O2 -d upstream/src /home/apbianco/src/rhug/xalan/upstream/src/javax/xml/transform/stream/StreamSource.java
gcj -C --encoding=UTF-8 -fCLASSPATH=upstream/src:../xerces/upstream/src:../BCEL/upstream:../cup/upstream:/home/apbianco/src/rhug/xalan/upstream/src -O2 -d upstream/src /home/apbianco/src/rhug/xalan/upstream/src/org/apache/xalan/extensions/ExpressionContext.java
/home/apbianco/src/rhug/xalan/upstream/src/org/apache/xml/utils/XMLString.java:648: unrecognized character in input stream.
      * "Fahrvergn|gen".toUpperCase() returns "FAHRVERGN\GEN"
                                                             ^
/home/apbianco/src/rhug/xalan/upstream/src/org/apache/xml/utils/XMLString.java:649: unrecognized character in input stream.
      * "Visit Ljubinje!".toUpperCase() returns "VISIT LJUBINJE!"
                                                                 ^
/home/apbianco/src/rhug/xalan/upstream/src/org/apache/xpath/objects/XString.java:1044: unrecognized character in input stream.
      * "Fahrvergn|gen".toUpperCase() returns "FAHRVERGN\GEN"
                                                             ^
/home/apbianco/src/rhug/xalan/upstream/src/org/apache/xpath/objects/XString.java:1045: unrecognized character in input stream.
      * "Visit Ljubinje!".toUpperCase() returns "VISIT LJUBINJE!"
                                                                 ^
4 errors
make[1]: *** [upstream/src/org/apache/xalan/extensions/ExpressionContext.class] Error 1
make[1]: Leaving directory `/raid/apbianco/build/rhug/i686-pc-linux-gnu/xalan'
make: *** [all-recursive] Error 1

I guess the trick would be to provide a different value for --encoding
(or no value at all) but then I get:

apbianco@janus[~/build/rhug/i686-pc-linux-gnu]: gcj -C -fCLASSPATH=upstream/src:../xerces/upstream/src:../BCEL/upstream:../cup/upstream:/home/apbianco/src/rhug/xalan/upstream/src -O2 -d upstream/src /home/apbianco/src/rhug/xalan/upstream/src/org/apache/xalan/extensions/ExpressionContext.java
jc1: No such file or directory: can't create directory upstream/src/org


./A

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gcj -C bug in xalan
  2001-09-10 13:24 ` Alexandre Petit-Bianco
@ 2001-09-10 13:33   ` Anthony Green
  2001-09-10 13:42   ` Anthony Green
  1 sibling, 0 replies; 8+ messages in thread
From: Anthony Green @ 2001-09-10 13:33 UTC (permalink / raw)
  To: apbianco, rhug-rhats

Alex wrote:
> FYI, I'm looking into it. On the other hand, I'm getting some other
> build errors:

Interesting.  I wonder why I didn't see those.  Try changing --encoding=UTF-8
to --encoding=8859_1.

AG


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gcj -C bug in xalan
  2001-09-10 13:24 ` Alexandre Petit-Bianco
  2001-09-10 13:33   ` Anthony Green
@ 2001-09-10 13:42   ` Anthony Green
  1 sibling, 0 replies; 8+ messages in thread
From: Anthony Green @ 2001-09-10 13:42 UTC (permalink / raw)
  To: apbianco, rhug-rhats

Alex wrote:
> FYI, I'm looking into it. On the other hand, I'm getting some other
> build errors:

I checked in a fix for this.

> apbianco@janus[~/build/rhug/i686-pc-linux-gnu]:
gcj -C -fCLASSPATH=upstream/src:../xerces/upstream/src:../BCEL/upstream:../cup
/upstream:/home/apbianco/src/rhug/xalan/upstream/src -O2 -d upstream/src
/home/apbianco/src/rhug/xalan/upstream/src/org/apache/xalan/extensions/Express
ionContext.java
> jc1: No such file or directory: can't create directory upstream/src/org

And this (in the toplevel configure.in/configure).  For now, just create an
"xalan/upstream/src" directory in your build tree.

Thanks,

AG


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gcj -C bug in xalan
  2001-09-09  9:41 gcj -C bug in xalan Anthony Green
  2001-09-10 13:24 ` Alexandre Petit-Bianco
@ 2001-09-11  1:21 ` Alexandre Petit-Bianco
  2001-09-13 15:14 ` Alexandre Petit-Bianco
  2 siblings, 0 replies; 8+ messages in thread
From: Alexandre Petit-Bianco @ 2001-09-11  1:21 UTC (permalink / raw)
  To: rhug-rhats

Anthony Green writes:

>       Any ideas?

Yeah, we're not keeping the information on imports when we leave the
scope of the class we're parsing. As a result, it shows when we try to
resolve type in some cases. I'm working on a patch.

./A

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gcj -C bug in xalan
  2001-09-09  9:41 gcj -C bug in xalan Anthony Green
  2001-09-10 13:24 ` Alexandre Petit-Bianco
  2001-09-11  1:21 ` Alexandre Petit-Bianco
@ 2001-09-13 15:14 ` Alexandre Petit-Bianco
  2001-09-13 15:25   ` Anthony Green
  2001-09-14 14:35   ` Anthony Green
  2 siblings, 2 replies; 8+ messages in thread
From: Alexandre Petit-Bianco @ 2001-09-13 15:14 UTC (permalink / raw)
  To: rhug-rhats

Anthony Green writes:

>       Any ideas?

I appended a patch below (tested for regression and everything.) Also,
I found that it was necessary to revert this BCEL/Makefile.am patch to
let BCEL build:

  Mon Sep 10 13:36:15 2001  Anthony Green  <green@redhat.com>

	* Makefile.am (GCJFLAGS): Remove "/src" from classpath.
	* Makefile.in: Rebuilt.

With or without the compiler patch below. Any insights on why this
patch was needed in the first place?

Let me know about both patches.
	
./A

2001-09-13  Alexandre Petit-Bianco  <apbianco@redhat.com>

	* java-tree.h (TYPE_IMPORT_LIST): New macro.
	(TYPE_IMPORT_DEMAND_LIST): Likewise.
	(struct lang_type): New fields import_list and import_demand_list.
	* parse.y (java_complete_class): Initialize TYPE_IMPORT_LIST and
	TYPE_IMPORT_DEMAND_LIST with ctxp counterparts.
	(do_resolve_class): New local saved_enclosing_type, initialized,
	passed as parameter to find_in_imports and find_in_imports_on_demand.
	(find_in_imports): Added paramater enclosing_type, use its
	TYPE_IMPORT_LIST when applicable.
	(find_in_imports_on_demand): Added parameter enclosing_type, use
	its TYPE_IMPORT_DEMAND_LIST when applicable. Reorganized locals
	declaration and initialization.
	(fold_constant_for_init): Switch/restore current_class to the
	appropriate context.

Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.121
diff -u -p -r1.121 java-tree.h
--- java-tree.h	2001/09/07 18:40:26	1.121
+++ java-tree.h	2001/09/13 21:17:56
@@ -950,6 +950,8 @@ struct lang_decl_var
    for non primitive types when compiling to bytecode. */
 #define TYPE_DOT_CLASS(T)        (TYPE_LANG_SPECIFIC(T)->dot_class)
 #define TYPE_PACKAGE_LIST(T)     (TYPE_LANG_SPECIFIC(T)->package_list)
+#define TYPE_IMPORT_LIST(T)      (TYPE_LANG_SPECIFIC(T)->import_list)
+#define TYPE_IMPORT_DEMAND_LIST(T) (TYPE_LANG_SPECIFIC(T)->import_demand_list)
 #define TYPE_PRIVATE_INNER_CLASS(T) (TYPE_LANG_SPECIFIC(T)->pic)
 #define TYPE_PROTECTED_INNER_CLASS(T) (TYPE_LANG_SPECIFIC(T)->poic)
 #define TYPE_HAS_FINAL_VARIABLE(T) (TYPE_LANG_SPECIFIC(T)->hfv)
@@ -968,6 +970,8 @@ struct lang_type
 				   compiling to bytecode to implement
 				   <non_primitive_type>.class */
   tree package_list;		/* List of package names, progressive */
+  tree import_list;		/* Imported types, in the CU of this class */
+  tree import_demand_list;	/* Imported types, in the CU of this class */
   unsigned pic:1;		/* Private Inner Class. */
   unsigned poic:1;		/* Protected Inner Class. */
   unsigned hfv:1;		/* Has final variables */
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.310
diff -u -p -r1.310 parse.y
--- parse.y	2001/09/13 14:37:24	1.310
+++ parse.y	2001/09/13 21:18:05
@@ -99,8 +99,8 @@ static tree parse_jdk1_1_error PARAMS ((
 static void complete_class_report_errors PARAMS ((jdep *));
 static int process_imports PARAMS ((void));
 static void read_import_dir PARAMS ((tree));
-static int find_in_imports_on_demand PARAMS ((tree));
-static void find_in_imports PARAMS ((tree));
+static int find_in_imports_on_demand PARAMS ((tree, tree));
+static void find_in_imports PARAMS ((tree, tree));
 static void check_static_final_variable_assignment_flag PARAMS ((tree));
 static void reset_static_final_variable_assignment_flag PARAMS ((tree));
 static void check_final_variable_local_assignment_flag PARAMS ((tree, tree));
@@ -5564,6 +5564,13 @@ java_complete_class ()
        cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
     {
       jdep *dep;
+
+      /* We keep the compilation unit imports in the class so that
+	 they can be used later to resolve type dependencies that
+	 aren't necessary to solve now. */
+      TYPE_IMPORT_LIST (TREE_TYPE (cclass)) = ctxp->import_list;
+      TYPE_IMPORT_DEMAND_LIST (TREE_TYPE (cclass)) = ctxp->import_demand_list;
+
       for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
 	{
 	  tree decl;
@@ -5750,6 +5757,7 @@ do_resolve_class (enclosing, class_type,
      tree enclosing, class_type, decl, cl;
 {
   tree new_class_decl = NULL_TREE, super = NULL_TREE;
+  tree saved_enclosing_type = enclosing ? TREE_TYPE (enclosing) : NULL_TREE;
   struct hash_table _ht, *circularity_hash = &_ht;
 
   /* This hash table is used to register the classes we're going
@@ -5786,7 +5794,7 @@ do_resolve_class (enclosing, class_type,
 
   /* 1- Check for the type in single imports. This will change
      TYPE_NAME() if something relevant is found */
-  find_in_imports (class_type);
+  find_in_imports (saved_enclosing_type, class_type);
 
   /* 2- And check for the type in the current compilation unit */
   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
@@ -5808,7 +5816,7 @@ do_resolve_class (enclosing, class_type,
   /* 4- Check the import on demands. Don't allow bar.baz to be
      imported from foo.* */
   if (!QUALIFIED_P (TYPE_NAME (class_type)))
-    if (find_in_imports_on_demand (class_type))
+    if (find_in_imports_on_demand (saved_enclosing_type, class_type))
       return NULL_TREE;
 
   /* If found in find_in_imports_on_demant, the type has already been
@@ -6710,17 +6718,22 @@ process_imports ()
    statement.  */
 
 static void
-find_in_imports (class_type)
+find_in_imports (enclosing_type, class_type)
+     tree enclosing_type;
      tree class_type;
 {
-  tree import;
-
-  for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
-    if (TREE_VALUE (import) == TYPE_NAME (class_type))
-      {
-	TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
-	QUALIFIED_P (TYPE_NAME (class_type)) = 1;
-      }
+  tree import = (enclosing_type ? TYPE_IMPORT_LIST (enclosing_type) : 
+		 ctxp->import_list);
+  while (import)
+    {
+      if (TREE_VALUE (import) == TYPE_NAME (class_type))
+	{
+	  TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
+	  QUALIFIED_P (TYPE_NAME (class_type)) = 1;
+	  return;
+	}
+      import = TREE_CHAIN (import);
+    }
 }
 
 static int
@@ -6869,14 +6882,17 @@ read_import_dir (wfl)
    entire list, to detected potential double definitions.  */
 		 
 static int
-find_in_imports_on_demand (class_type)
+find_in_imports_on_demand (enclosing_type, class_type)
+     tree enclosing_type;
      tree class_type;
 {
-  tree node, import, node_to_use = NULL_TREE;
+  tree import = (enclosing_type ? TYPE_IMPORT_DEMAND_LIST (enclosing_type) :
+		  ctxp->import_demand_list);
+  tree node_to_use = NULL_TREE, cl = NULL_TREE;
+  tree node;
   int seen_once = -1;
-  tree cl = NULL_TREE;
 
-  for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
+  while (import)
     {
       const char *id_name;
       obstack_grow (&temporary_obstack, 
@@ -6907,6 +6923,7 @@ find_in_imports_on_demand (class_type)
 		 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
 	    }
 	}
+      import = TREE_CHAIN (import);
     }
 
   if (seen_once == 1)
@@ -16129,8 +16146,14 @@ fold_constant_for_init (node, context)
 	    }
 	  else
 	    {
+	      /* Install the proper context for the field resolution.
+		 The prior context is restored once the name is
+		 properly qualified. */
+	      tree saved_current_class = current_class;
 	      /* Wait until the USE_COMPONENT_REF re-write.  FIXME. */
+	      current_class = DECL_CONTEXT (context);
 	      qualify_ambiguous_name (node);
+	      current_class = saved_current_class;
 	      if (resolve_field_access (node, &decl, NULL)
 		  && decl != NULL_TREE)
 		return fold_constant_for_init (decl, decl);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gcj -C bug in xalan
  2001-09-13 15:14 ` Alexandre Petit-Bianco
@ 2001-09-13 15:25   ` Anthony Green
  2001-09-14 14:35   ` Anthony Green
  1 sibling, 0 replies; 8+ messages in thread
From: Anthony Green @ 2001-09-13 15:25 UTC (permalink / raw)
  To: apbianco, rhug-rhats

Alex wrote:
> With or without the compiler patch below. Any insights on why this
> patch was needed in the first place?

I have no idea :-(   Coincidentally, I just noticed this also and committed
the fix.

Thanks -- I'll try your patch.

AG


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gcj -C bug in xalan
  2001-09-13 15:14 ` Alexandre Petit-Bianco
  2001-09-13 15:25   ` Anthony Green
@ 2001-09-14 14:35   ` Anthony Green
  1 sibling, 0 replies; 8+ messages in thread
From: Anthony Green @ 2001-09-14 14:35 UTC (permalink / raw)
  To: apbianco, rhug-rhats

Alex wrote:
> Let me know about both patches.

This patch did the trick!

Thanks - I'll revert the work-around once you check in the gcj patch.

AG


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-09-14 14:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-09  9:41 gcj -C bug in xalan Anthony Green
2001-09-10 13:24 ` Alexandre Petit-Bianco
2001-09-10 13:33   ` Anthony Green
2001-09-10 13:42   ` Anthony Green
2001-09-11  1:21 ` Alexandre Petit-Bianco
2001-09-13 15:14 ` Alexandre Petit-Bianco
2001-09-13 15:25   ` Anthony Green
2001-09-14 14:35   ` Anthony Green

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).