This is the mail archive of the mailing list for the GCC 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]

Java: fix Array_3 byte compiler failures

The test case (compilation from bytecode) has been
failing for a while.  It turns out that we can't compile `aconst_null;
arraylength' because build_java_array_length_access() insists that its
arg is of type array, whereas null_pointer_node is of type (void *).

My take on this is that the only way we could ever get an arg of type
(void *) passed to build_java_array_length_access() is in just this
case, and therefore we can unconditionally throw a
NullPointerException if this ever happens.

If anyone can think of a situation where build_java_array_length_access()
might be passed a node of type (void *) that is non-null, please speak up.


2002-09-26  Andrew Haley  <>

	* expr.c (build_java_array_length_access): Check for null pointer.

Index: expr.c
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.151
diff -p -2 -c -r1.151 expr.c
*** expr.c	21 Sep 2002 02:19:44 -0000	1.151
--- expr.c	26 Sep 2002 16:21:57 -0000
*************** build_java_array_length_access (node)
*** 676,679 ****
--- 676,688 ----
    HOST_WIDE_INT length;
+   /* JVM spec: If the arrayref is null, the arraylength instruction
+      throws a NullPointerException.  The only way we could get a node
+      of type (void *) at this point is `aconst_null; arraylength' or
+      somthing equivalent.  */
+   if (TREE_CODE (type) == POINTER_TYPE && array_type == void_type_node)
+     return build (CALL_EXPR, int_type_node, 
+ 		  build_address_of (soft_nullpointer_node),
    if (!is_array_type_p (type))
      abort ();

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