Index: toba-1.1/History diff -c toba-1.1/History:1.11 toba-1.1/History:1.14 *** toba-1.1/History:1.11 Sun Jul 26 12:25:28 1998 --- toba-1.1/History Thu Dec 3 19:11:52 1998 *************** *** 1,5 **** --- 1,11 ---- Toba Version Log + 1.1b December 4, 1998 + Fixes for reflection, misc bugs. + + 1.1a October 27, 1998 + Fixes for serialization, internationalization, networking + 1.1 July 31, 1998 JDK 1.1 support Index: toba-1.1/README diff -c toba-1.1/README:1.9 toba-1.1/README:1.12 *** toba-1.1/README:1.9 Fri May 1 18:09:14 1998 --- toba-1.1/README Thu Dec 3 19:11:52 1998 *************** *** 1,6 **** Toba README file ! March 6, 1998 ! This is Toba, a freely distributable system for translating Java code into C code. Toba comes from the Sumatra Group, part of the --- 1,5 ---- Toba README file ! 04Dec98 -- Version 1.1b This is Toba, a freely distributable system for translating Java code into C code. Toba comes from the Sumatra Group, part of the *************** *** 11,35 **** of the Boehm-Dermers-Weiner conservative garbage collector. It is covered by its own copyright; see gc/README. ! The biss/biss-0.87 subdirectory, included by permission, is version 0.87 ! of the BISS AWT package. Additionally the C and H files in the biss ! subdirectory are derived from BISS AWT sources. The BISS AWT is ! covered by its own copyright; see biss/biss-0.87/LICENSE.BISS-AWT. ! ! The first beta version of Toba was known as Juice. Documentation in HTML form is contained in the doc subdirectory. Installation instructions are given in the "install.html" file. ! Toba currently does not support Java version 1.1 or higher. ! To build Toba, you will need version 1.1.3 of the Java Developers Kit (JDK). ! For the Irix version, see ! http://www.sgi.com/Fun/Free_webtools.html ! For Linux, see ! http://www.blackdown.org/java-linux.html ! For Solaris and Windows NT, see ! http://java.sun.com/products/JDK/1.1.3/index.html ! Additional information about the Sumatra project may be found at http://www.cs.arizona.edu/sumatra/. --- 10,27 ---- of the Boehm-Dermers-Weiner conservative garbage collector. It is covered by its own copyright; see gc/README. ! The zlib and bnlib packages in ./SupFiles, and the BISS archives in ./biss, ! are distributed in original form in accordance with their respective ! copyrights. The home sites for these packages are documented in ! doc/porting.html. These supplementary systems will be unpacked, and in the ! cast of BISS patched to meet Toba's needs, during the configuration process; ! see doc/install.html. Documentation in HTML form is contained in the doc subdirectory. Installation instructions are given in the "install.html" file. ! Toba currently supports Java version 1.1. Serialization is supported; ! reflection is mostly supported (invocation of some methods may fail). Additional information about the Sumatra project may be found at http://www.cs.arizona.edu/sumatra/. Index: toba-1.1/bin/toba.sh diff -c toba-1.1/bin/toba.sh:1.37 toba-1.1/bin/toba.sh:1.38 *** toba-1.1/bin/toba.sh:1.37 Thu Jul 30 15:16:13 1998 --- toba-1.1/bin/toba.sh Wed Oct 28 21:38:20 1998 *************** *** 239,245 **** trace export TOBAPATH # explicit or implicit CLASSPATH, before we add to it ! CPATH="${CLASSPATH:-.}" # set JAVA_HOME in the same way javac would PRG=`whereis ${JAVA}` --- 239,255 ---- trace export TOBAPATH # explicit or implicit CLASSPATH, before we add to it ! CPATH='' ! # Normally, we'd tack our stuff on _after_ the user's class path. However, ! # when we've built for BISS, we've replaced certain classes in the standard ! # library with new versions, and if we end up looking at the old ones first, ! # bad things will happen. So, if there's a BISSAPI directory, set the ! # first places we look to be where we put the retranslated classes. ! if [ -d ${PKGS}/BISSAPI ] ; then ! CPATH="${PKGS}/SUNAPI/classes:${PKGS}/BISSAPI/classes:" ! fi ! # Now tack on the user's CLASSPATH as the next highest priority. ! CPATH="${CPATH}${CLASSPATH:-.}" # set JAVA_HOME in the same way javac would PRG=`whereis ${JAVA}` Index: toba-1.1/configs/biss.linux.opt diff -c toba-1.1/configs/biss.linux.opt:1.2 toba-1.1/configs/biss.linux.opt:1.3 *** toba-1.1/configs/biss.linux.opt:1.2 Tue Jul 28 15:14:54 1998 --- toba-1.1/configs/biss.linux.opt Thu Oct 29 16:56:47 1998 *************** *** 1,6 **** ! # $Id: biss.linux.opt,v 1.2 1998/07/28 22:14:54 pab Exp $ # Option overrides to build BISS on Linux OPTION_BISS = true JDK_SOURCE_DIR = @@JDK_SOURCE_DIR@@ ! BISS_LDFLAGS = -L/usr/X11/lib -lX11 -lXext -lXaw BISS_INCLUDE_FLAG = -I../packages/BISSAPI/include --- 1,7 ---- ! # $Id: biss.linux.opt,v 1.3 1998/10/29 23:56:47 pab Exp $ # Option overrides to build BISS on Linux OPTION_BISS = true JDK_SOURCE_DIR = @@JDK_SOURCE_DIR@@ ! # This maybe should be -L/usr/X11/lib, depending on your installation ! BISS_LDFLAGS = -L/usr/X11R6/lib -lX11 -lXext -lXaw BISS_INCLUDE_FLAG = -I../packages/BISSAPI/include Index: toba-1.1/configs/irix.mk diff -c toba-1.1/configs/irix.mk:1.4 toba-1.1/configs/irix.mk:1.5 *** toba-1.1/configs/irix.mk:1.4 Thu Jul 30 15:16:14 1998 --- toba-1.1/configs/irix.mk Thu Dec 3 11:55:29 1998 *************** *** 1,7 **** # toba make definitions for MIPS/Irix using SGI CC and Irix threads ARCH = mips CBUILD = -KPIC ! CTOBA = -ansi TBUILD = -O SLOPT = -shared # NB: Space follows -rpath below --- 1,9 ---- # toba make definitions for MIPS/Irix using SGI CC and Irix threads ARCH = mips CBUILD = -KPIC ! # Shut up noisy Irix warnings: ! # 1429: long long being non-standard. ! CTOBA = -ansi -woff 1429 TBUILD = -O SLOPT = -shared # NB: Space follows -rpath below *************** *** 13,16 **** # irix because they hid their resource bundles somewhere we can't find then, # so we won't build it there. WantXJavac = - --- 15,17 ---- Index: toba-1.1/packages/buildAPI diff -c toba-1.1/packages/buildAPI:1.4 toba-1.1/packages/buildAPI:1.6 *** toba-1.1/packages/buildAPI:1.4 Mon Jul 27 10:39:36 1998 --- toba-1.1/packages/buildAPI Thu Dec 3 19:11:52 1998 *************** *** 1,5 **** #!/bin/sh ! # $Id: buildAPI,v 1.4 1998/07/27 17:39:36 pab Exp $ # # Script to automate the translation of Sun and BISS class files into # packages suitable for use by Toba. --- 1,5 ---- #!/bin/sh ! # $Id: buildAPI,v 1.6 1998/12/04 02:11:52 pab Exp $ # # Script to automate the translation of Sun and BISS class files into # packages suitable for use by Toba. *************** *** 52,63 **** # SUN_EXCLUDE: A group of patterns of classes in the sun.* hierarchy that # we don't want to tobafy. stamp 'Computing sun.* exclusion patterns' ! SUN_EXCLUDE='^sun.' ! # The following is a little more lax, and bloats the library a lot. ! #SUN_EXCLUDE='' ! #for f in applet audio awt beans io jdbc net rmi tools ; do ! # SUN_EXCLUDE="${SUN_EXCLUDE} ^sun.${f}." ! #done # CLASS_EXCLUDE: A group of classes that we want to exclude. Specifically # for BISS builds: there are some AWT classes that require things not --- 52,64 ---- # SUN_EXCLUDE: A group of patterns of classes in the sun.* hierarchy that # we don't want to tobafy. stamp 'Computing sun.* exclusion patterns' ! #SUN_EXCLUDE='^sun.' ! # The following is a little more lax, and bloats the library, but also ! # allows serialization to work. ! SUN_EXCLUDE='' ! for f in applet audio awt beans io jdbc net rmi tools ; do ! SUN_EXCLUDE="${SUN_EXCLUDE} ^sun.${f}." ! done # CLASS_EXCLUDE: A group of classes that we want to exclude. Specifically # for BISS builds: there are some AWT classes that require things not *************** *** 74,79 **** --- 75,86 ---- done fi + # CLASS_INCLUDE: A set of additional classes that would otherwise be excluded, + # but that we want anyway. Separate with single spaces. + # sun.io.ByteToCharISO8859_1 and its companion provide the JDK default + # conversion between Unicode characters and bytes. + CLASS_INCLUDE='sun.io.ByteToCharISO8859_1 sun.io.CharToByteISO8859_1' + # Create an fgrep "pattern" file that we'll use to exclude what we don't # want to see. EXCLUDE="${JAVA_EXCLUDE} ${SUN_EXCLUDE} ${CLASS_EXCLUDE}" *************** *** 118,125 **** | sed -e 's@^@^@' -e 's@$@$@' \ | fgrep -v -f fgrep.in$$ \ | sed -e 's@^^@@' -e 's@\$$@@' \ - | sort \ > api.core-${TAG} # If we're building BISS, we should add the BISS classes to the ones we # want. if ${OPTION_BISS} ; then --- 125,137 ---- | sed -e 's@^@^@' -e 's@$@$@' \ | fgrep -v -f fgrep.in$$ \ | sed -e 's@^^@@' -e 's@\$$@@' \ > api.core-${TAG} + if [ -n "${CLASS_INCLUDE}" ] ; then + echo ${CLASS_INCLUDE} \ + | tr ' ' '\012' \ + >> api.core-${TAG} + fi + sort -o api.core-${TAG} api.core-${TAG} # If we're building BISS, we should add the BISS classes to the ones we # want. if ${OPTION_BISS} ; then Index: toba-1.1/runtime/Makefile diff -c toba-1.1/runtime/Makefile:1.24 toba-1.1/runtime/Makefile:1.25 *** toba-1.1/runtime/Makefile:1.24 Tue Jul 28 10:39:53 1998 --- toba-1.1/runtime/Makefile Wed Nov 18 12:22:15 1998 *************** *** 12,18 **** HELP = alloc.c binary_loader.c file.c finalizer.c helpers.c \ loader.c monitor.c runtime.c sthreads.c structs.c throw.c \ ! intern.c classfile_ClassData.c JITSRC = jit_JITCodeGen.c jit_CodeBlock.c \ runtime_ClassRT.c \ --- 12,18 ---- HELP = alloc.c binary_loader.c file.c finalizer.c helpers.c \ loader.c monitor.c runtime.c sthreads.c structs.c throw.c \ ! intern.c classfile_ClassData.c invoke_c.c JITSRC = jit_JITCodeGen.c jit_CodeBlock.c \ runtime_ClassRT.c \ *************** *** 50,56 **** touch $(UPDATED) $(DONE) sleep 1 ! $(OBJ): toba.h runtime.h md.h withjit: $(MAKE) JIT="$(JITSRC)" --- 50,56 ---- touch $(UPDATED) $(DONE) sleep 1 ! $(OBJ): toba.h runtime.h md.h reflect.h withjit: $(MAKE) JIT="$(JITSRC)" Index: toba-1.1/runtime/alloc.c diff -c toba-1.1/runtime/alloc.c:1.10 toba-1.1/runtime/alloc.c:1.12 *** toba-1.1/runtime/alloc.c:1.10 Wed Jan 28 16:27:46 1998 --- toba-1.1/runtime/alloc.c Thu Nov 19 18:54:55 1998 *************** *** 22,28 **** static Object memerror; /* out-of-memory Error exception */ - static void null_warn_proc(char *msg, GC_word arg) /*ARGSUSED*/ {} /* --- 22,27 ---- *************** *** 76,88 **** return; } ! /* memexit -- shut down memory interface */ void memexit(void) { ! GC_finalize_all(); return; } --- 75,98 ---- return; } ! static Boolean doRunFinalizers = JAVA_FALSE; ! /* This is java.lang.Runtime.runFinalizersOnExit, defined here so we don't ! * have to make either that flag or a mutator function global. */ ! Void ! runFinalizersOnExit0_z_osowt (Boolean arg1) ! { ! doRunFinalizers = arg1; ! } /* memexit -- shut down memory interface */ void memexit(void) { ! /* Only run the finalizers if we were asked to do so. By default, ! * java doesn't. */ ! if (doRunFinalizers) { ! GC_finalize_all(); ! } return; } *************** *** 261,301 **** return a; } - - Object mnewarray(Class c, int arraydim, int ndim, int *dlist) { int i; ! ! /* make Class structs out to final dimension */ for (i = 0; i < arraydim; i++) { ! if (!c->arrayclass) c->arrayclass = arrayclassof(c); c = c->arrayclass; } /* recursively create the requested number of dimensions */ return mkarray(c->elemclass, ndim, dlist); - } /* mnewarray(c, arraydim, ndim, d1, d2, ...) -- implement multianewarray */ ! ! Object vmnewarray(Class c, int arraydim, int ndim, /*d1,d2,*/...) { ! va_list ap; int dlist[256]; /* bytecode limits dimensions to 256 max */ int i; /* store dimensions from vararg list in local array */ va_start(ap, ndim); ! for (i = 0; i < ndim; i++) dlist[i] = va_arg(ap, int); va_end(ap); ! return mnewarray(c, arraydim, ndim, dlist); } ! static Object mkarray(Class c, int ndim, int *dlist) /* make ndim-array of c */ { int i; Object o; --- 271,331 ---- return a; } Object mnewarray(Class c, int arraydim, int ndim, int *dlist) { int i; ! ! /* The class structure we have refers to the ultimate base type. ! * We need to get a pointer to the class corresponding to the ! * topmost element type; e.g., with a 5-d array, we want the ! * [[[[X class (array-four-times of base type). NB: We go up ! * one level further than we need to, so there's a class ! * description available for the type we're going to return ! * as well as the recursive element types. */ for (i = 0; i < arraydim; i++) { ! if (NULL == c->arrayclass) { c->arrayclass = arrayclassof(c); + } c = c->arrayclass; } + /* recursively create the requested number of dimensions */ return mkarray(c->elemclass, ndim, dlist); } /* mnewarray(c, arraydim, ndim, d1, d2, ...) -- implement multianewarray */ ! Object ! vmnewarray (Class c, /* Class of ultimate base element */ ! int arraydim, /* Ultimate array rank */ ! int ndim, /* Number of axes we're going to allocate here */ ! /*d1,d2,*/...) /* Dimensions for axes 1 through ndim */ { ! va_list ap; /* */ int dlist[256]; /* bytecode limits dimensions to 256 max */ int i; + if ((256 <= ndim) || (0 >= ndim)) { + throwInternalError ("vmnewarray attempting to allocate %d-dimensional array.", ndim); + } + if ((ndim > arraydim) || (0 >= arraydim)) { + throwInternalError ("vmnewarray invalid dimensions (%d, allocating %d).", arraydim, ndim); + } + /* store dimensions from vararg list in local array */ va_start(ap, ndim); ! for (i = 0; i < ndim; i++) { dlist[i] = va_arg(ap, int); + } va_end(ap); ! return mnewarray (c, arraydim, ndim, dlist); ! } ! static Object ! mkarray (Class c, /* Element class data */ ! int ndim, /* Number of dimensions we're going to build */ ! int *dlist) /* Extent of each dimension */ { int i; Object o; *************** *** 305,313 **** throwNegativeArraySizeException(*dlist); } o = anewarray(c, *dlist); ! if (ndim > 1) ! for (i = 0; i < *dlist; i++) ! ((struct aarray *)o)->data[i] = ! mkarray(c->elemclass, ndim - 1, dlist + 1); return o; } --- 335,347 ---- throwNegativeArraySizeException(*dlist); } o = anewarray(c, *dlist); ! ! /* If there are more dimensions to do, fill in each element of the ! * array we just created with a new n-1--dimensional array. */ ! if (1 < ndim) { ! for (i = 0; i < *dlist; i++) { ! ((struct aarray *)o)->data[i] = mkarray(c->elemclass, ndim - 1, dlist + 1); ! } ! } return o; } Index: toba-1.1/runtime/binary_loader.c diff -c toba-1.1/runtime/binary_loader.c:1.8 toba-1.1/runtime/binary_loader.c:1.9 *** toba-1.1/runtime/binary_loader.c:1.8 Fri Jul 24 16:19:34 1998 --- toba-1.1/runtime/binary_loader.c Mon Nov 9 13:47:19 1998 *************** *** 78,83 **** --- 78,84 ---- #endif /* HAVE_TCLASS_NAME_LIST */ } + #if HAVE_DLSYM /* Look up a symbol in all open dynamic libraries. Y'know, this probably * ought to be restricted based on class loader. */ static void * *************** *** 97,102 **** --- 98,104 ---- } return rv; } + #endif /* HAVE_DLSYM */ /** Given the (fully-qualified) name of a Java class, find it in whatever * way we have to. */ Index: toba-1.1/runtime/genInvokeCases diff -c /dev/null toba-1.1/runtime/genInvokeCases:1.2 *** /dev/null Thu Dec 3 22:21:42 1998 --- toba-1.1/runtime/genInvokeCases Thu Nov 19 18:56:19 1998 *************** *** 0 **** --- 1,97 ---- + #!/usr/local/bin/perl + # $Id: genInvokeCases,v 1.2 1998/11/20 01:56:19 pab Exp $ + # + # Generate the case statements used inside invoke_c to invoke methods that + # take primitive types as parameters. + + # Sizes of primitive data types + @aset = ( 1, 2, 4, 8 ); + + # Names for the generic type we use to cover all types with a given size. + %mtype = (); + $mtype{0} = "Void"; + $mtype{1} = "Byte"; + $mtype{2} = "Char"; + $mtype{4} = "Int"; + $mtype{8} = "Long"; + + # For a list of sizes, generate the tag value used to represent the list, + # the prototype string using the generic types, and the actual parameter + # string extracting data from a char array and casting it to the + # appropriate type. We assume the actual parameters are stored aligned + # on 4-byte boundaries. + sub genSizeInfo () { + local @sset = @_; + my $tag = ""; + my $proto = ""; + my $param = ""; + my $tsize = 0; + + for $s (@sset) { + if ("" ne $proto) { + $proto .= ","; + $param .= ","; + } + + $tag .= "${s}"; + $proto .= $mtype{$s}; + $param .= "*($mtype{$s}*)(pData+$tsize)"; + if (4 >= $s) { + $tsize += 4; + } else { + $tsize += $s; + } + } + return ($tag, $proto, $param); + } + + %doneCase = (); + + sub emitCase () { + local ($tag, $prot, $parm) = @_; + return if ($doneCase{$tag}); + $doneCase{$tag} = 1; + while (4 > (length $tag)) { + $tag = "0" . $tag; + } + print <<"EOText" + case 0x${tag}: + if (0 == rSize) { + ((Void(*)($prot))(m->f))($parm); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)($prot))(m->f))($parm); + } else { + prv.F = ((Float(*)($prot))(m->f))($parm); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)($prot))(m->f))($parm); + } else { + prv.D = ((Double(*)($prot))(m->f))($parm); + } + } + break; + EOText + ; + } + + sub genInvokes () { + local @sset = @_; + + &emitCase (&genSizeInfo (@sset)); + &emitCase (&genSizeInfo (4, @sset)); + return; + } + + + &genInvokes(4); + for $s1 (@aset) { + &genInvokes ($s1); + for $s2 (@aset) { + &genInvokes ($s1, $s2); + # for $s3 (@aset) { + # &genInvokes ($s1, $s2, $s3); + # } + } + } Index: toba-1.1/runtime/helpers.c diff -c toba-1.1/runtime/helpers.c:1.12 toba-1.1/runtime/helpers.c:1.14 *** toba-1.1/runtime/helpers.c:1.12 Sat Apr 18 16:30:17 1998 --- toba-1.1/runtime/helpers.c Fri Nov 20 13:26:16 1998 *************** *** 3,8 **** --- 3,9 ---- #include "toba.h" #include "runtime.h" #include "java_lang_NullPointerException.h" + #include "java_io_Serializable.h" #include #include *************** *** 150,164 **** */ int assignablefrom(Class c, Class oc) { ! if (oc == c) /* quick check for exact match */ ! return 1; ! if ((oc->flags | c->flags) & IS_PRIMITIVE) ! return 0; /* if primitive, must be identical */ ! if (c->flags & IS_INTERFACE) /* if an interface, check specially */ return interfinstance(oc, c); /* at this point c is a simple class although oc may be an array; */ /* an array matches only java.lang.Object */ return oc->nsupers >= c->nsupers && oc->supers[oc->nsupers-c->nsupers] == c; --- 151,177 ---- */ int assignablefrom(Class c, Class oc) { ! if (oc == c) { /* quick check for exact match */ ! return JAVA_TRUE; ! } ! if ((oc->flags | c->flags) & IS_PRIMITIVE) { ! /* Primitives are compatible only if they're identical, and these ! * aren't because we already checked that. */ ! return JAVA_FALSE; /* if primitive, must be identical */ ! } ! if ((IS_ARRAY & oc->flags) && ! (&cl_java_io_Serializable.C == c)) { ! /* Arrays can be assigned to serializables. */ ! return JAVA_TRUE; ! } ! ! if (c->flags & IS_INTERFACE) { /* if an interface, check specially */ return interfinstance(oc, c); + } + /* Why did somebody put this comment here? Why is it true? */ /* at this point c is a simple class although oc may be an array; */ /* an array matches only java.lang.Object */ return oc->nsupers >= c->nsupers && oc->supers[oc->nsupers-c->nsupers] == c; Index: toba-1.1/runtime/invoke_c.c diff -c /dev/null toba-1.1/runtime/invoke_c.c:1.5 *** /dev/null Thu Dec 3 22:21:42 1998 --- toba-1.1/runtime/invoke_c.c Fri Nov 20 14:01:05 1998 *************** *** 0 **** --- 1,977 ---- + /* $Id: invoke_c.c,v 1.5 1998/11/20 21:01:05 pab Exp $ + * Support for invoking dynamically-specified methods. This includes + * both constructors and normal methods. */ + + #include + #include + #include + #include + + #include "toba.h" + #include "classfile_ClassData.h" + #include "java_lang_reflect_InvocationTargetException.h" + #include "runtime.h" + #include "reflect.h" + + /* We need to be able to invoke a function with an arbitrary parameter + * specification. We could generate an assembly sequence at runtime that + * sticks the parameters in the appropriate location and invokes the + * function, but we're going to try to do as much as we can in semi-portable + * C. + * + * Here's the general principle: Although there are a bunch of primitive + * types, we're going to assume that all the ones of a particular size + * can be treated identically: e.g., all 1-byte quantities as Bytes, + * all 4-byte quantities as Ints, all 8-byte quantities as Longs. This + * would break if, e.g., floating point values are not returned in the + * same way as longs are. We're also assuming that Objects are 4-byte + * values, and that all 1 and 2-byte values are returned as a 32-bit + * integer. + * + * What we do is calculate a hash code that identifies the parameters + * to a method by their size (sizes encoded in the nybbles of an int), + * and generate a switch statement which ends up invoking the method + * function by casting it to a function pointer of the corresponding + * type, and extracting the parameters from a buffer, again casting + * them to the appropriate (generic) type for the parameter (size). + * The return value is stored into a primitive value location and, + * if appropriate, wrapped in an object before being returned from + * the invoke routine. + * + * The provided set supports all 1 and 2-parameter methods, both static + * and instance; static 3-parameter methods where the first parameter + * is a 4-byte type; and methods with up to 12 parameters all of which + * are 4-byte quantities. Any missing signature ends up throwing + * an internal error; you can get around that by adding another case + * to the switch, or by writing an assembly-language wrapping invoker. + * + * Note that when we stuff the parameters into the buffer that we use + * to store them in primitive form, we align everything on 4-byte + * boundaries, even if they're 1- or 2-byte quantities. This should + * prevent alignment traps on picky hardware. + */ + + /* How many object-like parameters are we prepared to handle? */ + #define MAX_PARAM_WORDS (12) + + static Object + invoke_object (struct mt_generic *m, /* The method we're going to invoke */ + int nParams, /* Number of parameters */ + char * pSize, /* Sequence of bytes describing sizes of parameters */ + char * pData) /* Sequence of native-mode actual parameters */ + { + Object orv; /* The object we're returning as a result */ + int apat; /* Hash code of the argument pattern */ + int hasNonObjParam; /* Nonzero iff some argument is not 4-bytes big */ + const Char * chp; /* Pointer into signature for determining return type */ + PrimClassTriple * rpct; /* Data corresponding to return type */ + AnyJavaValue prv; /* Where we store primitive result values */ + int rSize; /* Size of the result value */ + Boolean didInv; /* True after switch only if we matched and invoked */ + int i; /* General purpose index */ + + /* The type of the result of the method is indicated by the character + * immediately following the close paren in the method's signature. + * Back up to that character and use it to look up the primitive + * class information for the return type. Calculate the size of the + * result value. */ + chp = m->sig_chars + m->sig_len - 1; + while ((m->sig_chars < chp) && + (')' != chp[-1])) { + --chp; + } + rpct = getPCTbySigChar (*chp); + if (NULL == rpct) { + /* Only way we should be able to get here is if the return type + * is a non-primitive object. If it isn't, complain loudly. */ + if ('L' != *chp) { + throwInternalError ("invoke: Mismatch extracting return type"); + } + rSize = sizeof (Object); + } else { + rSize = PCT_primSize (rpct); + } + + /* The hash code consists of an encoding of the sizes of the first so-many + * arguments of the method. Don't compute a hash on more than the number + * of args we're prepared to deal with. */ + #define MAX_SPECIALIZED_INVOKE_ARGS (3) + apat = 0; + hasNonObjParam = 0; + for (i = 0; i < nParams; i++) { + hasNonObjParam |= (sizeof (Object) != pSize [i]); + if (MAX_SPECIALIZED_INVOKE_ARGS > i) { + assert (16 > pSize [i]); + /* Hash encoding is 4-bit left-to-right of sizes */ + apat = (apat << 4) + (pSize [i] & 0x0F); + } + } + /* If there aren't more arguments than we have special cases for, + * try to find a match in the switch statement. */ + didInv = JAVA_FALSE; + if (MAX_SPECIALIZED_INVOKE_ARGS > nParams) { + didInv = JAVA_TRUE; + switch (apat) { + /* The case statements are generated automatically by genInvokeCases. + * Edit them there. */ + case 0x0004: + if (0 == rSize) { + ((Void(*)(Int))(m->f))(*(Int*)(pData+0)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int))(m->f))(*(Int*)(pData+0)); + } else { + prv.F = ((Float(*)(Int))(m->f))(*(Int*)(pData+0)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int))(m->f))(*(Int*)(pData+0)); + } else { + prv.D = ((Double(*)(Int))(m->f))(*(Int*)(pData+0)); + } + } + break; + case 0x0044: + if (0 == rSize) { + ((Void(*)(Int,Int))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Int))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4)); + } else { + prv.F = ((Float(*)(Int,Int))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Int))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4)); + } else { + prv.D = ((Double(*)(Int,Int))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4)); + } + } + break; + case 0x0001: + if (0 == rSize) { + ((Void(*)(Byte))(m->f))(*(Byte*)(pData+0)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Byte))(m->f))(*(Byte*)(pData+0)); + } else { + prv.F = ((Float(*)(Byte))(m->f))(*(Byte*)(pData+0)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Byte))(m->f))(*(Byte*)(pData+0)); + } else { + prv.D = ((Double(*)(Byte))(m->f))(*(Byte*)(pData+0)); + } + } + break; + case 0x0041: + if (0 == rSize) { + ((Void(*)(Int,Byte))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Byte))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4)); + } else { + prv.F = ((Float(*)(Int,Byte))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Byte))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4)); + } else { + prv.D = ((Double(*)(Int,Byte))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4)); + } + } + break; + case 0x0011: + if (0 == rSize) { + ((Void(*)(Byte,Byte))(m->f))(*(Byte*)(pData+0),*(Byte*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Byte,Byte))(m->f))(*(Byte*)(pData+0),*(Byte*)(pData+4)); + } else { + prv.F = ((Float(*)(Byte,Byte))(m->f))(*(Byte*)(pData+0),*(Byte*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Byte,Byte))(m->f))(*(Byte*)(pData+0),*(Byte*)(pData+4)); + } else { + prv.D = ((Double(*)(Byte,Byte))(m->f))(*(Byte*)(pData+0),*(Byte*)(pData+4)); + } + } + break; + case 0x0411: + if (0 == rSize) { + ((Void(*)(Int,Byte,Byte))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Byte*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Byte,Byte))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Byte*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Byte,Byte))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Byte*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Byte,Byte))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Byte*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Byte,Byte))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Byte*)(pData+8)); + } + } + break; + case 0x0012: + if (0 == rSize) { + ((Void(*)(Byte,Char))(m->f))(*(Byte*)(pData+0),*(Char*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Byte,Char))(m->f))(*(Byte*)(pData+0),*(Char*)(pData+4)); + } else { + prv.F = ((Float(*)(Byte,Char))(m->f))(*(Byte*)(pData+0),*(Char*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Byte,Char))(m->f))(*(Byte*)(pData+0),*(Char*)(pData+4)); + } else { + prv.D = ((Double(*)(Byte,Char))(m->f))(*(Byte*)(pData+0),*(Char*)(pData+4)); + } + } + break; + case 0x0412: + if (0 == rSize) { + ((Void(*)(Int,Byte,Char))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Char*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Byte,Char))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Char*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Byte,Char))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Char*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Byte,Char))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Char*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Byte,Char))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Char*)(pData+8)); + } + } + break; + case 0x0014: + if (0 == rSize) { + ((Void(*)(Byte,Int))(m->f))(*(Byte*)(pData+0),*(Int*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Byte,Int))(m->f))(*(Byte*)(pData+0),*(Int*)(pData+4)); + } else { + prv.F = ((Float(*)(Byte,Int))(m->f))(*(Byte*)(pData+0),*(Int*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Byte,Int))(m->f))(*(Byte*)(pData+0),*(Int*)(pData+4)); + } else { + prv.D = ((Double(*)(Byte,Int))(m->f))(*(Byte*)(pData+0),*(Int*)(pData+4)); + } + } + break; + case 0x0414: + if (0 == rSize) { + ((Void(*)(Int,Byte,Int))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Int*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Byte,Int))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Int*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Byte,Int))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Int*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Byte,Int))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Int*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Byte,Int))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Int*)(pData+8)); + } + } + break; + case 0x0018: + if (0 == rSize) { + ((Void(*)(Byte,Long))(m->f))(*(Byte*)(pData+0),*(Long*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Byte,Long))(m->f))(*(Byte*)(pData+0),*(Long*)(pData+4)); + } else { + prv.F = ((Float(*)(Byte,Long))(m->f))(*(Byte*)(pData+0),*(Long*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Byte,Long))(m->f))(*(Byte*)(pData+0),*(Long*)(pData+4)); + } else { + prv.D = ((Double(*)(Byte,Long))(m->f))(*(Byte*)(pData+0),*(Long*)(pData+4)); + } + } + break; + case 0x0418: + if (0 == rSize) { + ((Void(*)(Int,Byte,Long))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Long*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Byte,Long))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Long*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Byte,Long))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Long*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Byte,Long))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Long*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Byte,Long))(m->f))(*(Int*)(pData+0),*(Byte*)(pData+4),*(Long*)(pData+8)); + } + } + break; + case 0x0002: + if (0 == rSize) { + ((Void(*)(Char))(m->f))(*(Char*)(pData+0)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Char))(m->f))(*(Char*)(pData+0)); + } else { + prv.F = ((Float(*)(Char))(m->f))(*(Char*)(pData+0)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Char))(m->f))(*(Char*)(pData+0)); + } else { + prv.D = ((Double(*)(Char))(m->f))(*(Char*)(pData+0)); + } + } + break; + case 0x0042: + if (0 == rSize) { + ((Void(*)(Int,Char))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Char))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4)); + } else { + prv.F = ((Float(*)(Int,Char))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Char))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4)); + } else { + prv.D = ((Double(*)(Int,Char))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4)); + } + } + break; + case 0x0021: + if (0 == rSize) { + ((Void(*)(Char,Byte))(m->f))(*(Char*)(pData+0),*(Byte*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Char,Byte))(m->f))(*(Char*)(pData+0),*(Byte*)(pData+4)); + } else { + prv.F = ((Float(*)(Char,Byte))(m->f))(*(Char*)(pData+0),*(Byte*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Char,Byte))(m->f))(*(Char*)(pData+0),*(Byte*)(pData+4)); + } else { + prv.D = ((Double(*)(Char,Byte))(m->f))(*(Char*)(pData+0),*(Byte*)(pData+4)); + } + } + break; + case 0x0421: + if (0 == rSize) { + ((Void(*)(Int,Char,Byte))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Byte*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Char,Byte))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Byte*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Char,Byte))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Byte*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Char,Byte))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Byte*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Char,Byte))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Byte*)(pData+8)); + } + } + break; + case 0x0022: + if (0 == rSize) { + ((Void(*)(Char,Char))(m->f))(*(Char*)(pData+0),*(Char*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Char,Char))(m->f))(*(Char*)(pData+0),*(Char*)(pData+4)); + } else { + prv.F = ((Float(*)(Char,Char))(m->f))(*(Char*)(pData+0),*(Char*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Char,Char))(m->f))(*(Char*)(pData+0),*(Char*)(pData+4)); + } else { + prv.D = ((Double(*)(Char,Char))(m->f))(*(Char*)(pData+0),*(Char*)(pData+4)); + } + } + break; + case 0x0422: + if (0 == rSize) { + ((Void(*)(Int,Char,Char))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Char*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Char,Char))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Char*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Char,Char))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Char*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Char,Char))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Char*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Char,Char))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Char*)(pData+8)); + } + } + break; + case 0x0024: + if (0 == rSize) { + ((Void(*)(Char,Int))(m->f))(*(Char*)(pData+0),*(Int*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Char,Int))(m->f))(*(Char*)(pData+0),*(Int*)(pData+4)); + } else { + prv.F = ((Float(*)(Char,Int))(m->f))(*(Char*)(pData+0),*(Int*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Char,Int))(m->f))(*(Char*)(pData+0),*(Int*)(pData+4)); + } else { + prv.D = ((Double(*)(Char,Int))(m->f))(*(Char*)(pData+0),*(Int*)(pData+4)); + } + } + break; + case 0x0424: + if (0 == rSize) { + ((Void(*)(Int,Char,Int))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Int*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Char,Int))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Int*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Char,Int))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Int*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Char,Int))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Int*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Char,Int))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Int*)(pData+8)); + } + } + break; + case 0x0028: + if (0 == rSize) { + ((Void(*)(Char,Long))(m->f))(*(Char*)(pData+0),*(Long*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Char,Long))(m->f))(*(Char*)(pData+0),*(Long*)(pData+4)); + } else { + prv.F = ((Float(*)(Char,Long))(m->f))(*(Char*)(pData+0),*(Long*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Char,Long))(m->f))(*(Char*)(pData+0),*(Long*)(pData+4)); + } else { + prv.D = ((Double(*)(Char,Long))(m->f))(*(Char*)(pData+0),*(Long*)(pData+4)); + } + } + break; + case 0x0428: + if (0 == rSize) { + ((Void(*)(Int,Char,Long))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Long*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Char,Long))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Long*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Char,Long))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Long*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Char,Long))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Long*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Char,Long))(m->f))(*(Int*)(pData+0),*(Char*)(pData+4),*(Long*)(pData+8)); + } + } + break; + case 0x0441: + if (0 == rSize) { + ((Void(*)(Int,Int,Byte))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Byte*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Int,Byte))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Byte*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Int,Byte))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Byte*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Int,Byte))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Byte*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Int,Byte))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Byte*)(pData+8)); + } + } + break; + case 0x0442: + if (0 == rSize) { + ((Void(*)(Int,Int,Char))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Char*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Int,Char))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Char*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Int,Char))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Char*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Int,Char))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Char*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Int,Char))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Char*)(pData+8)); + } + } + break; + case 0x0444: + if (0 == rSize) { + ((Void(*)(Int,Int,Int))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Int*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Int,Int))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Int*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Int,Int))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Int*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Int,Int))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Int*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Int,Int))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Int*)(pData+8)); + } + } + break; + case 0x0048: + if (0 == rSize) { + ((Void(*)(Int,Long))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Long))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4)); + } else { + prv.F = ((Float(*)(Int,Long))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Long))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4)); + } else { + prv.D = ((Double(*)(Int,Long))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4)); + } + } + break; + case 0x0448: + if (0 == rSize) { + ((Void(*)(Int,Int,Long))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Long*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Int,Long))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Long*)(pData+8)); + } else { + prv.F = ((Float(*)(Int,Int,Long))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Long*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Int,Long))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Long*)(pData+8)); + } else { + prv.D = ((Double(*)(Int,Int,Long))(m->f))(*(Int*)(pData+0),*(Int*)(pData+4),*(Long*)(pData+8)); + } + } + break; + case 0x0008: + if (0 == rSize) { + ((Void(*)(Long))(m->f))(*(Long*)(pData+0)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Long))(m->f))(*(Long*)(pData+0)); + } else { + prv.F = ((Float(*)(Long))(m->f))(*(Long*)(pData+0)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Long))(m->f))(*(Long*)(pData+0)); + } else { + prv.D = ((Double(*)(Long))(m->f))(*(Long*)(pData+0)); + } + } + break; + case 0x0081: + if (0 == rSize) { + ((Void(*)(Long,Byte))(m->f))(*(Long*)(pData+0),*(Byte*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Long,Byte))(m->f))(*(Long*)(pData+0),*(Byte*)(pData+8)); + } else { + prv.F = ((Float(*)(Long,Byte))(m->f))(*(Long*)(pData+0),*(Byte*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Long,Byte))(m->f))(*(Long*)(pData+0),*(Byte*)(pData+8)); + } else { + prv.D = ((Double(*)(Long,Byte))(m->f))(*(Long*)(pData+0),*(Byte*)(pData+8)); + } + } + break; + case 0x0481: + if (0 == rSize) { + ((Void(*)(Int,Long,Byte))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Byte*)(pData+12)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Long,Byte))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Byte*)(pData+12)); + } else { + prv.F = ((Float(*)(Int,Long,Byte))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Byte*)(pData+12)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Long,Byte))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Byte*)(pData+12)); + } else { + prv.D = ((Double(*)(Int,Long,Byte))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Byte*)(pData+12)); + } + } + break; + case 0x0082: + if (0 == rSize) { + ((Void(*)(Long,Char))(m->f))(*(Long*)(pData+0),*(Char*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Long,Char))(m->f))(*(Long*)(pData+0),*(Char*)(pData+8)); + } else { + prv.F = ((Float(*)(Long,Char))(m->f))(*(Long*)(pData+0),*(Char*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Long,Char))(m->f))(*(Long*)(pData+0),*(Char*)(pData+8)); + } else { + prv.D = ((Double(*)(Long,Char))(m->f))(*(Long*)(pData+0),*(Char*)(pData+8)); + } + } + break; + case 0x0482: + if (0 == rSize) { + ((Void(*)(Int,Long,Char))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Char*)(pData+12)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Long,Char))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Char*)(pData+12)); + } else { + prv.F = ((Float(*)(Int,Long,Char))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Char*)(pData+12)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Long,Char))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Char*)(pData+12)); + } else { + prv.D = ((Double(*)(Int,Long,Char))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Char*)(pData+12)); + } + } + break; + case 0x0084: + if (0 == rSize) { + ((Void(*)(Long,Int))(m->f))(*(Long*)(pData+0),*(Int*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Long,Int))(m->f))(*(Long*)(pData+0),*(Int*)(pData+8)); + } else { + prv.F = ((Float(*)(Long,Int))(m->f))(*(Long*)(pData+0),*(Int*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Long,Int))(m->f))(*(Long*)(pData+0),*(Int*)(pData+8)); + } else { + prv.D = ((Double(*)(Long,Int))(m->f))(*(Long*)(pData+0),*(Int*)(pData+8)); + } + } + break; + case 0x0484: + if (0 == rSize) { + ((Void(*)(Int,Long,Int))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Int*)(pData+12)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Long,Int))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Int*)(pData+12)); + } else { + prv.F = ((Float(*)(Int,Long,Int))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Int*)(pData+12)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Long,Int))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Int*)(pData+12)); + } else { + prv.D = ((Double(*)(Int,Long,Int))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Int*)(pData+12)); + } + } + break; + case 0x0088: + if (0 == rSize) { + ((Void(*)(Long,Long))(m->f))(*(Long*)(pData+0),*(Long*)(pData+8)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Long,Long))(m->f))(*(Long*)(pData+0),*(Long*)(pData+8)); + } else { + prv.F = ((Float(*)(Long,Long))(m->f))(*(Long*)(pData+0),*(Long*)(pData+8)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Long,Long))(m->f))(*(Long*)(pData+0),*(Long*)(pData+8)); + } else { + prv.D = ((Double(*)(Long,Long))(m->f))(*(Long*)(pData+0),*(Long*)(pData+8)); + } + } + break; + case 0x0488: + if (0 == rSize) { + ((Void(*)(Int,Long,Long))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Long*)(pData+12)); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int(*)(Int,Long,Long))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Long*)(pData+12)); + } else { + prv.F = ((Float(*)(Int,Long,Long))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Long*)(pData+12)); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long(*)(Int,Long,Long))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Long*)(pData+12)); + } else { + prv.D = ((Double(*)(Int,Long,Long))(m->f))(*(Int*)(pData+0),*(Long*)(pData+4),*(Long*)(pData+12)); + } + } + break; + + default: + /* Remember that invocation failed so we can recover. */ + didInv = JAVA_FALSE; + break; + } + } + + /* If we haven't successfully invoked the method, attempt to do so + * treating all parameters as object pointers. We're assuming it's + * safe to pass more params to a function than it was declared to + * take; C's pretty lenient that way, at least pre-ANSI. */ + if (! didInv) { + Object * inParams; /* Aliased parameter pointer */ + + /* We can't invoke this way if some parameter isn't of a conforming + * size. */ + if (hasNonObjParam) { + throwInternalError ("invoke: Unsupported parameter grouping. Try updating runtime/invoke_c.c."); + } + inParams = (Object *) pData; + /* Invoke the appropriate function returning 0-byte, 4-byte, or 8-byte + * values. */ + if (0 == rSize) { + ((Void (*) ()) (m->f)) (inParams[0], inParams[1], inParams[2], + inParams[3], inParams[4], inParams[5], + inParams[6], inParams[7], inParams[8], + inParams[9], inParams[10], inParams[11]); + } else if (4 >= rSize) { + if ((NULL == rpct) || (&cl_float != PCT_primClass(rpct))) { + prv.I = ((Int (*) ()) (m->f)) (inParams[0], inParams[1], inParams[2], + inParams[3], inParams[4], inParams[5], + inParams[6], inParams[7], inParams[8], + inParams[9], inParams[10], inParams[11]); + } else { + prv.F = ((Float (*) ()) (m->f)) (inParams[0], inParams[1], inParams[2], + inParams[3], inParams[4], inParams[5], + inParams[6], inParams[7], inParams[8], + inParams[9], inParams[10], inParams[11]); + } + } else { + if (&cl_double != PCT_primClass(rpct)) { + prv.J = ((Long (*) ()) (m->f)) (inParams[0], inParams[1], inParams[2], + inParams[3], inParams[4], inParams[5], + inParams[6], inParams[7], inParams[8], + inParams[9], inParams[10], inParams[11]); + } else { + prv.D = ((Double (*) ()) (m->f)) (inParams[0], inParams[1], inParams[2], + inParams[3], inParams[4], inParams[5], + inParams[6], inParams[7], inParams[8], + inParams[9], inParams[10], inParams[11]); + } + } + } + + /* Zero out the return value, and copy over the invocation return if + * it's an object type, or wrap it if it's a primitive non-void type. */ + orv = NULL; + if (NULL == rpct) { + orv = (Object) prv.I; + } else if (0 < rSize) { + /* If the actual value isn't 4 bytes, do a cast to the appropriate + * size to work around byte order problems in the AnyJavaValue union. */ + if (1 == rSize) { + prv.B = (Byte) prv.I; + } else if (2 == rSize) { + prv.S = (Short) prv.I; + } + orv = wrapPrimObject (PCT_primClass (rpct), &prv); + } + + return orv; + } + + Object + invoke_c (struct mt_generic *m, /* Information on the method we're to invoke */ + Object iobj, /* Instance object on which we're invoking the method */ + struct aarray *expectedArgs, /* Array of jlClass objects representing formal params*/ + struct aarray *givenArgs, /* Array of jlObject objects representing actual params */ + Boolean isInstance, /* Do we invoke this as an instance method? */ + Boolean useVoid) /* Do we invoke this as a void method? */ + { + int nParams; /* Number of parameters in method */ + char inParamBlock [MAX_PARAM_WORDS * sizeof (Object)]; + char inParamSize [MAX_PARAM_WORDS]; + char * nextParamData; + char * nextParamSize; + Object *expParams; /* Pointer into sequence of jlClass objects naming parameter types */ + Object *giveParams; /* Pointer into sequence of jlObject objects wrapping actual parameters */ + Object param; + struct mythread *tdata; + jmp_buf newbuf; + void * oldjmpbuf; + int i; + Object rv; + + /* There's a critical assumption in all this that objects are the same + * size as ints. If you're running on a 64-bit machine, you'll need + * to modify the switch statement in the invoker function, and probably + * do a bunch of other stuff too. */ + if (4 != sizeof(Object)) { + throwInternalError ("invoke: Built-in assumption that pointers are 4-bytes is wrong."); + } + + memset (inParamBlock, 0, sizeof (inParamBlock)); + nextParamData = inParamBlock; + nextParamSize = inParamSize; + + nParams = expectedArgs->length; + expParams = expectedArgs->data; + giveParams = givenArgs->data; + + /* Comments match javadoc for reflect.Constructor and reflect.Method */ + + /* If this Method object enforces Java language access control and + * the underlying method is inaccessible, the creation throws an + * IllegalAccessException. */ + if (ACC_ABSTRACT == (m->access & ACC_ABSTRACT)) { + throwIllegalAccessException ("method inaccessible"); + } + + /* NB: We don't have enough information here to enforce other access + * controls: specifically, we may have a protected method, where + * invocation is allowed if we're running inside a subclass. Also, + * constructors that are protected seem to be callable from anywhere if + * they're the only constructor. Java is a weird language.*/ + + /* If the number of actual parameters supplied via args is different + * from the number of formal parameters required by the underlying method, + * the invocation throws an IllegalArgumentException. */ + if (nParams != givenArgs->length) { + throwIllegalArgumentException ("wrong number of arguments"); + } + + /* First parameter is the instance object. Don't need to do type/value + * checking on it; that was done by our caller. */ + if (isInstance) { + *nextParamSize = sizeof (iobj); + *(Object *)nextParamData = iobj; + nextParamData += (4 >= *nextParamSize) ? 4 : *nextParamSize; + ++nextParamSize; + } + + /* For each actual parameter in the supplied initargs array: + * If the corresponding formal parameter has a primitive type, + * an unwrapping conversion is attempted to convert the object + * value to a value of the primitive type. + * If this attempt fails, the creation throws an IllegalArgumentException. + * If, after possible unwrapping, the parameter value cannot be + * converted to the corresponding formal parameter type by an identity + * or widening conversion, the creation throws an + * IllegalArgumentException. */ + + for (i = 0 ; i < nParams; i++) { + Class fpcl; /* Formal parameter class */ + Class apcl; /* Actual parameter class */ + Object aparam; /* Actual parameter as object */ + PrimClassTriple * fpct; /* Translation info for formal parameter */ + PrimClassTriple * apct; /* Translation info for actual parameter */ + + /* Get the class information for the formal parameter. If the + * actual parameter isn't null, get its class info too. */ + fpcl = find_class ((struct in_java_lang_Class *)expParams [i]); + apcl = NULL; + apct = NULL; + aparam = giveParams [i]; + if (NULL != aparam) { + apcl = ((struct in_generic *)aparam)->class; + apct = getPCTbyObjClass (apcl); + } + + /* If the actual parameter is present, and the corresponding formal + * is a primitive type, attempt to do the conversion into the + * parameter buffer; if that fails, we'll break out, and throw + * an IAE later. */ + if ((NULL != apct) && (IS_PRIMITIVE & fpcl->flags)) { + fpct = getPCTbyPrimClass (fpcl); + assert (NULL != fpct); + /* Convert from the native format of the actual parameter into + * the native format of the formal parameter, storing data into + * the destination buffer. */ + if (! widenConvert (PCT_primClass (apct), PCT_objPrimValAddr (apct, aparam), + fpcl, nextParamData)) { + break; + } + /* Record how big the formal parameter (what we're actually passing) is. */ + *nextParamSize = PCT_primSize (fpct); + } else { + /* Not a primitive-to-primitive assignment. If the formal type is not + * primitive, and the value is either null or assignable to the formal + * type, stuff it into place. */ + if ((! (IS_PRIMITIVE & fpcl->flags)) && + ((NULL == aparam) || + assignablefrom (fpcl, apcl))) { + *nextParamSize = sizeof (aparam); + * (Object *)nextParamData = aparam; + } else { + /* We can't deal with this. */ + break; + } + } + /* Increment the pointer into the actual parameter buffer; do this + * 4-byte aligned. Also point to the next size element. */ + nextParamData += (4 >= *nextParamSize) ? 4 : *nextParamSize; + ++nextParamSize; + if (((inParamBlock + sizeof(inParamBlock)) <= nextParamData) || + ((inParamSize + sizeof(inParamSize)) <= nextParamSize)) { + throwInternalError ("invoke: too many arguments; need to implement expandable buffers"); + } + } + /* If we get out without converting everything, throw an IAE */ + if (i < nParams) { + throwIllegalArgumentException ("argument type mismatch"); + } + + /* Control transfers to the underlying constructor to initialize the + * new instance. If the constructor completes abruptly by throwing an + * exception, the exception is placed in an InvocationTargetException + * and thrown in turn to the caller of newInstance. */ + tdata = mythread(); + oldjmpbuf = tdata->jmpbuf; + if (setjmp(newbuf)) { + Object excep; /* Exception that was thrown */ + Object ite; /* jlrITE encapsulating exception */ + + /* Clean up after the exception. Reset state so when we throw the + * ITE we'll end up in the caller's exception handler. Create a + * new ITE exception object saving the exception that we caught so + * the user can look at it. Throw the ITE. */ + sthread_got_exception(); + tdata->jmpbuf = oldjmpbuf; + excep = tdata->exception; + ite = new(&cl_java_lang_reflect_InvocationTargetException.C); + /* call constructor for jlrITE */ + init_TS_usqSb (ite, excep, 0); + athrow(ite); + } + + + /* Save the new exception buffer, and invoke the method. */ + tdata->jmpbuf = newbuf; + rv = invoke_object (m, (nextParamSize - inParamSize), inParamSize, inParamBlock); + + /* Restore the previous exception handler and return the result of + * the invocation. */ + mythread()->jmpbuf = oldjmpbuf; + + return rv; + } Index: toba-1.1/runtime/io_ObjectInputStream.c diff -c toba-1.1/runtime/io_ObjectInputStream.c:1.1 toba-1.1/runtime/io_ObjectInputStream.c:1.2 *** toba-1.1/runtime/io_ObjectInputStream.c:1.1 Sat Apr 18 16:30:18 1998 --- toba-1.1/runtime/io_ObjectInputStream.c Mon Nov 9 13:58:22 1998 *************** *** 1,4 **** --- 1,6 ---- + #ifndef SCOUT #include + #endif /* SCOUT */ #include "toba.h" #include "runtime.h" #include "java_io_ObjectInputStream.h" Index: toba-1.1/runtime/io_ObjectOutputStream.c diff -c toba-1.1/runtime/io_ObjectOutputStream.c:1.1 toba-1.1/runtime/io_ObjectOutputStream.c:1.2 *** toba-1.1/runtime/io_ObjectOutputStream.c:1.1 Sat Apr 18 16:30:18 1998 --- toba-1.1/runtime/io_ObjectOutputStream.c Mon Nov 9 13:58:22 1998 *************** *** 1,4 **** --- 1,6 ---- + #ifndef SCOUT #include + #endif /* SCOUT */ #include "toba.h" #include "runtime.h" #include "java_io_ObjectOutputStream.h" Index: toba-1.1/runtime/io_ObjectStreamClass.c diff -c toba-1.1/runtime/io_ObjectStreamClass.c:1.1 toba-1.1/runtime/io_ObjectStreamClass.c:1.2 *** toba-1.1/runtime/io_ObjectStreamClass.c:1.1 Sat Apr 18 16:30:18 1998 --- toba-1.1/runtime/io_ObjectStreamClass.c Thu Dec 3 11:55:29 1998 *************** *** 97,102 **** --- 97,104 ---- if (len==namelen && memcmp(namebuf,buf,len*sizeof(Char))==0) return mt[i].access; } + throwInternalError("jiObjectStreamClass: Improper argument to private native method"); + /*NOTREACHED*/ } Object getFieldSignatures_C_vtzTW(Object Harg1) /* Since JDK1.1 */ *************** *** 155,160 **** --- 157,164 ---- if (len==namelen && memcmp(buf,namebuf,len*sizeof(Char))==0) return vt[i].access; } + throwInternalError("jiObjectStreamClass: Improper argument to private native method"); + /*NOTREACHED*/ } /* Get the array of non-static non-transient fields */ Index: toba-1.1/runtime/java_lang_Character-hc.c diff -c toba-1.1/runtime/java_lang_Character-hc.c:1.2 toba-1.1/runtime/java_lang_Character-hc.c:1.3 *** toba-1.1/runtime/java_lang_Character-hc.c:1.2 Mon Jul 27 12:24:41 1998 --- toba-1.1/runtime/java_lang_Character-hc.c Thu Dec 3 11:55:29 1998 *************** *** 750,755 **** --- 750,756 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M hashCode__WOaBD: java.lang.Character.hashCode()I */ *************** *** 774,779 **** --- 775,781 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M equals_O_LwTmy: java.lang.Character.equals(Ljava/lang/Object;)Z */ *************** *** 831,836 **** --- 833,839 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M toString__wiHO9: java.lang.Character.toString()Ljava/lang/String; */ *************** *** 873,878 **** --- 876,882 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isLowerCase_c_GbMan: java.lang.Character.isLowerCase(C)Z */ *************** *** 934,939 **** --- 938,944 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isUpperCase_c_1nbCM: java.lang.Character.isUpperCase(C)Z */ *************** *** 995,1000 **** --- 1000,1006 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isTitleCase_c_PxFAc: java.lang.Character.isTitleCase(C)Z */ *************** *** 1056,1061 **** --- 1062,1068 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isDigit_c_489xD: java.lang.Character.isDigit(C)Z */ *************** *** 1117,1122 **** --- 1124,1130 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isDefined_c_KWB7r: java.lang.Character.isDefined(C)Z */ *************** *** 1177,1182 **** --- 1185,1191 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isLetter_c_DsO7h: java.lang.Character.isLetter(C)Z */ *************** *** 1241,1246 **** --- 1250,1256 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isLetterOrDigit_c_7lxPy: java.lang.Character.isLetterOrDigit(C)Z */ *************** *** 1305,1310 **** --- 1315,1321 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isJavaLetter_c_p8wvb: java.lang.Character.isJavaLetter(C)Z */ *************** *** 1366,1371 **** --- 1377,1383 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isJavaLetterOrDigit_c_1rcua: java.lang.Character.isJavaLetterOrDigit(C)Z */ *************** *** 1426,1431 **** --- 1438,1444 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isJavaIdentifierStart_c_6EJtS: java.lang.Character.isJavaIdentifierStart(C)Z */ *************** *** 1487,1492 **** --- 1500,1506 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isJavaIdentifierPart_c_nEv70: java.lang.Character.isJavaIdentifierPart(C)Z */ *************** *** 1547,1552 **** --- 1561,1567 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isUnicodeIdentifierStar_c_Rlxqr: java.lang.Character.isUnicodeIdentifierStart(C)Z */ *************** *** 1608,1613 **** --- 1623,1629 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isUnicodeIdentifierPart_c_qxU9a: java.lang.Character.isUnicodeIdentifierPart(C)Z */ *************** *** 1668,1673 **** --- 1684,1690 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isIdentifierIgnorable_c_9OyUG: java.lang.Character.isIdentifierIgnorable(C)Z */ *************** *** 1729,1734 **** --- 1746,1752 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M toLowerCase_c_Kft8E: java.lang.Character.toLowerCase(C)C */ *************** *** 1796,1801 **** --- 1814,1820 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M toUpperCase_c_5rSz3: java.lang.Character.toUpperCase(C)C */ *************** *** 1863,1868 **** --- 1882,1888 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M toTitleCase_c_TBmyt: java.lang.Character.toTitleCase(C)C */ *************** *** 1960,1965 **** --- 1980,1986 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M digit_ci_Cj4mh: java.lang.Character.digit(CI)I */ *************** *** 2066,2071 **** --- 2087,2093 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M getNumericValue_c_kBwFE: java.lang.Character.getNumericValue(C)I */ *************** *** 2213,2218 **** --- 2235,2241 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isSpace_c_LYJJQ: java.lang.Character.isSpace(C)Z */ *************** *** 2332,2337 **** --- 2355,2361 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isWhitespace_c_2ZLys: java.lang.Character.isWhitespace(C)Z */ *************** *** 2393,2398 **** --- 2417,2423 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M isISOControl_c_VHYwq: java.lang.Character.isISOControl(C)Z */ *************** *** 2482,2487 **** --- 2507,2513 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M forDigit_ii_BpWTd: java.lang.Character.forDigit(II)C */ *************** *** 3828,3833 **** --- 3854,3860 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } Index: toba-1.1/runtime/java_text_DecompositionIterator-hc.c diff -c toba-1.1/runtime/java_text_DecompositionIterator-hc.c:1.2 toba-1.1/runtime/java_text_DecompositionIterator-hc.c:1.3 *** toba-1.1/runtime/java_text_DecompositionIterator-hc.c:1.2 Mon Jul 27 12:24:42 1998 --- toba-1.1/runtime/java_text_DecompositionIterator-hc.c Thu Dec 3 11:55:30 1998 *************** *** 491,496 **** --- 491,497 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M next__XpA3r: java.text.DecompositionIterator.next()C */ *************** *** 796,801 **** --- 797,803 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M previous__PctOH: java.text.DecompositionIterator.previous()C */ *************** *** 986,991 **** --- 988,994 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M reset__MuNyF: java.text.DecompositionIterator.reset()V */ *************** *** 1021,1026 **** --- 1024,1030 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M decompose_ci_mIHlA: java.text.DecompositionIterator.decompose(CI)Ljava/lang/String; */ *************** *** 1128,1133 **** --- 1132,1138 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M decompose_Si_5Zmdx: java.text.DecompositionIterator.decompose(Ljava/lang/StringBuffer;I)V */ *************** *** 1162,1167 **** --- 1167,1173 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M decompose_Siii_DN1z4: java.text.DecompositionIterator.decompose(Ljava/lang/StringBuffer;III)V */ *************** *** 1313,1318 **** --- 1319,1325 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M decompose_Si_DUgkc: java.text.DecompositionIterator.decompose(Ljava/lang/String;I)Ljava/lang/String; */ *************** *** 1347,1352 **** --- 1354,1360 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M decompose_Siii_nh0Qv: java.text.DecompositionIterator.decompose(Ljava/lang/String;III)Ljava/lang/String; */ *************** *** 1467,1472 **** --- 1475,1481 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M decompose_caci_hGLZD: java.text.DecompositionIterator.decompose(C[CI)I */ *************** *** 1567,1572 **** --- 1576,1582 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } /*M getMaximumDecomposition__TWsKf: java.text.DecompositionIterator.getMaximumDecomposition()I */ *************** *** 1722,1727 **** --- 1732,1738 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } static short kOffsetIndex[]={ *************** *** 2845,2850 **** --- 2856,2862 ---- NULLX: throwNullPointerException(0); + /*NOTREACHED*/ } Index: toba-1.1/runtime/lang_Class.c diff -c toba-1.1/runtime/lang_Class.c:1.9 toba-1.1/runtime/lang_Class.c:1.17 *** toba-1.1/runtime/lang_Class.c:1.9 Wed May 6 14:29:31 1998 --- toba-1.1/runtime/lang_Class.c Thu Dec 3 11:55:30 1998 *************** *** 2,19 **** #include #include #include "toba.h" ! #include "runtime.h" #include "java_lang_Class.h" #include "java_lang_String.h" #include "java_util_Hashtable.h" #include "java_lang_Object.h" #include "java_lang_reflect_Field.h" #include "java_lang_reflect_Method.h" #include "java_lang_reflect_Constructor.h" #include "java_lang_NoSuchFieldException.h" #include "java_lang_NoSuchMethodException.h" - #include "classfile_ClassData.h" #include "java_io_Serializable.h" #ifdef OPTION_JIT #include "toba_runtime_SystemClassLoader.h" --- 2,41 ---- #include #include #include "toba.h" ! #include "java_lang_Boolean.h" ! #include "java_lang_Byte.h" ! #include "java_lang_Integer.h" ! #include "java_lang_Short.h" ! #include "java_lang_Long.h" ! #include "java_lang_Float.h" ! #include "java_lang_Double.h" ! #include "java_lang_Character.h" ! #include "java_lang_Void.h" #include "java_lang_Class.h" #include "java_lang_String.h" #include "java_util_Hashtable.h" #include "java_lang_Object.h" #include "java_lang_reflect_Field.h" + #include "java_lang_reflect_Member.h" #include "java_lang_reflect_Method.h" #include "java_lang_reflect_Constructor.h" #include "java_lang_NoSuchFieldException.h" #include "java_lang_NoSuchMethodException.h" #include "java_io_Serializable.h" + #include "runtime.h" + #include "reflect.h" + #include "classfile_ClassData.h" + + /* Tags to identify method as member/nonmember */ + typedef enum + MethodCategory { + MT_constructor, /* Method is named "" */ + MT_staticInitializer, /* Method is named "" */ + MT_memberMethod /* Method is a member method */ + } MethodCategory; + + static Object GetClassFromSignature(const Char *sig,int *cnt); + #ifdef OPTION_JIT #include "toba_runtime_SystemClassLoader.h" *************** *** 24,36 **** /* hash table with (classname -> instance of class Class) */ static struct in_java_util_Hashtable *all_classes = 0; - static Object GetClassFromSignature(const Char *sig,int *cnt); /* install a class in the hashtable (called during startup) */ void register_class(Class cl) { ! if (all_classes == NULL) { struct in_java_util_Hashtable * nac; /* make a hashtable w/ 250 buckets to start with */ --- 46,57 ---- /* hash table with (classname -> instance of class Class) */ static struct in_java_util_Hashtable *all_classes = 0; /* install a class in the hashtable (called during startup) */ void register_class(Class cl) { ! if (NULL == all_classes) { struct in_java_util_Hashtable * nac; /* make a hashtable w/ 250 buckets to start with */ *************** *** 89,127 **** /* STATIC Method */ init_java_lang_Class(); ! #ifdef OPTION_JIT ! /* This is the moral equivalent of systemclassloader.findSystemClass(c), ! * which loads the class, followed by systemclassloader.resolveClass(c), ! * which links it. Don't call loadClass; we may not want to generate ! * code. findSystemClass knows whether defineClass is required or not, ! * depending on where it found things. */ ! /* From empirical testing, this routine is not obliged to find classes ! * that were loaded with something other than the system class loader. */ ! val = system_loader->class->M.findSystemClass_S_FLv3x.f(system_loader, arg1); ! /* If the find failed, we threw an exception, right? */ ! assert (NULL != val); ! system_loader->class->M.resolveClass_C_vKDXp.f(system_loader, val); ! #else /* OPTION_JIT */ /* look it up in our hash table of all known classes */ /* java_util_Hashtable get(Object, Object) */ val = (struct in_java_lang_Class *)get_O_doAa7(all_classes, arg1); /* Try to find the class in the shared libraries */ ! if(!val) val = load_native_system_class(arg1); if (!val){ ! int x; ! Char *s = ((struct carray*)arg1->value)->data; ! /* find array classes */ ! if (s[0]=='[') ! return GetClassFromSignature(s,&x); } if(!val) { throwClassNotFoundException(cstring(arg1)); } - #endif /* OPTION_JIT */ return val; } --- 110,156 ---- /* STATIC Method */ init_java_lang_Class(); ! val = NULL; ! ! #ifndef OPTION_JIT /* look it up in our hash table of all known classes */ /* java_util_Hashtable get(Object, Object) */ val = (struct in_java_lang_Class *)get_O_doAa7(all_classes, arg1); + #endif /* OPTION_JIT */ /* Try to find the class in the shared libraries */ ! if(!val) { val = load_native_system_class(arg1); + } + /* No go. See if it's an array class. */ if (!val){ ! Char *s = arg1->offset + ((struct carray*)arg1->value)->data; ! /* find array classes; we never jit those. */ ! if ('[' == *s) { ! return GetClassFromSignature(s, NULL); ! } ! } ! ! #ifdef OPTION_JIT ! if (!val) { ! /* This is the moral equivalent of systemclassloader.findSystemClass(c), ! * which loads the class, followed by systemclassloader.resolveClass(c), ! * which links it. Don't call loadClass; we may not want to generate ! * code. findSystemClass knows whether defineClass is required or not, ! * depending on where it found things. */ ! /* From empirical testing, this routine is not obliged to find classes ! * that were loaded with something other than the system class loader. */ ! val = system_loader->class->M.findSystemClass_S_FLv3x.f(system_loader, arg1); ! /* If the find failed, we threw an exception, right? */ ! assert (NULL != val); ! system_loader->class->M.resolveClass_C_vKDXp.f(system_loader, val); } + #endif /* OPTION_JIT */ if(!val) { throwClassNotFoundException(cstring(arg1)); } return val; } *************** *** 136,143 **** /* we're never allowed to newInstance java.lang.Class * since all instances *must* be embedded within struct Class */ ! if(cl == &cl_java_lang_Class.C) throwIllegalAccessException("can't instantiate java.lang.Class"); res = construct(cl); return res; --- 165,173 ---- /* we're never allowed to newInstance java.lang.Class * since all instances *must* be embedded within struct Class */ ! if (cl == &cl_java_lang_Class.C) { throwIllegalAccessException("can't instantiate java.lang.Class"); + } res = construct(cl); return res; *************** *** 159,173 **** Object getSuperclass__bNIlH(Object Harg1) { struct in_java_lang_Class *this = (struct in_java_lang_Class *)Harg1; ! Class cl, super; /* do we have a superclass? */ ! cl = find_class(this); ! if(cl->nsupers < 2) ! return 0; ! super = cl->supers[1]; ! return find_classclass(super); } /* java/lang/Class getInterfaces ()[Ljava/lang/Class; */ --- 189,203 ---- Object getSuperclass__bNIlH(Object Harg1) { struct in_java_lang_Class *this = (struct in_java_lang_Class *)Harg1; ! Class cl; /* do we have a superclass? */ ! cl = find_class (this); ! if (2 > cl->nsupers) { ! return NULL; ! } ! return find_classclass(cl->supers [1]); } /* java/lang/Class getInterfaces ()[Ljava/lang/Class; */ *************** *** 181,187 **** c = find_class(this); inters = anewarray(&cl_java_lang_Class.C, c->ndinters); ! for(i = 0; i < c->ndinters; i++) { inters->data[i] = find_classclass(c->inters[i]); } return inters; --- 211,217 ---- c = find_class(this); inters = anewarray(&cl_java_lang_Class.C, c->ndinters); ! for (i = 0; i < c->ndinters; i++) { inters->data[i] = find_classclass(c->inters[i]); } return inters; *************** *** 201,210 **** Class cl; cl = find_class(this); ! if(cl->flags & IS_INTERFACE) return JAVA_TRUE; ! else return JAVA_FALSE; } Boolean isInstance_O_ggynA(Object Harg1, Object Harg2) /* Since JDK1.1 */ --- 231,241 ---- Class cl; cl = find_class(this); ! if (cl->flags & IS_INTERFACE) { return JAVA_TRUE; ! } else { return JAVA_FALSE; + } } Boolean isInstance_O_ggynA(Object Harg1, Object Harg2) /* Since JDK1.1 */ *************** *** 213,222 **** Class cl; cl = find_class(this); ! if (instanceof(Harg2,cl,0)) return JAVA_TRUE; ! else return JAVA_FALSE; } Boolean isAssignableFrom_C_3OtSc(Object Harg1, Object Harg2) /* Since JDK1.1 */ --- 244,254 ---- Class cl; cl = find_class(this); ! if (instanceof(Harg2,cl,0)) { return JAVA_TRUE; ! } else { return JAVA_FALSE; + } } Boolean isAssignableFrom_C_3OtSc(Object Harg1, Object Harg2) /* Since JDK1.1 */ *************** *** 228,238 **** cl_this = find_class(this); cl_arg = find_class(arg); ! if (assignablefrom(cl_this,cl_arg)) ! return 1; ! if ((cl_arg->flags&IS_ARRAY) && cl_this==&cl_java_io_Serializable.C) ! return 1; ! return 0; } Boolean isArray__yE28G(Object Harg1) /* Since JDK1.1 */ --- 260,266 ---- cl_this = find_class(this); cl_arg = find_class(arg); ! return assignablefrom(cl_this, cl_arg); } Boolean isArray__yE28G(Object Harg1) /* Since JDK1.1 */ *************** *** 241,250 **** Class cl; cl = find_class(this); ! if (cl->flags & IS_ARRAY){ return JAVA_TRUE; ! } ! else{ return JAVA_FALSE; } } --- 269,277 ---- Class cl; cl = find_class(this); ! if (cl->flags & IS_ARRAY) { return JAVA_TRUE; ! } else { return JAVA_FALSE; } } *************** *** 255,264 **** Class cl; cl = find_class(this); ! if (cl->flags & IS_PRIMITIVE){ return JAVA_TRUE; ! } ! else{ return JAVA_FALSE; } } --- 282,290 ---- Class cl; cl = find_class(this); ! if (cl->flags & IS_PRIMITIVE) { return JAVA_TRUE; ! } else{ return JAVA_FALSE; } } *************** *** 275,283 **** cl = find_class(this); if (cl->flags & IS_ARRAY){ return find_classclass(cl->elemclass); } - else - return 0; } Int getModifiers__W5R4X(Object Harg1) /* Since JDK1.1 */ --- 301,309 ---- cl = find_class(this); if (cl->flags & IS_ARRAY){ return find_classclass(cl->elemclass); + } else { + return NULL; } } Int getModifiers__W5R4X(Object Harg1) /* Since JDK1.1 */ *************** *** 293,993 **** { return anewarray(&cl_java_lang_Object.C,0); } Void setSigners_aO_la6GY(Object Harg1, Object Harg2) /* Unimplemented JDK1.1 */ { } extern struct class cl_void; ! Object getPrimitiveClass_S_JFLGD(Object Harg1) /* Since JDK1.1 */ { ! Class cl; ! static char *primNames[]={ "boolean", "byte", "char", "short", "int", ! "long", "float", "double", "void" }; ! static Class primClasses[]={ ! &cl_boolean, ! &cl_byte, ! &cl_char, ! &cl_short, ! &cl_int, ! &cl_long, ! &cl_float, ! &cl_double, ! &cl_void ! }; ! int i; ! char *name; ! /* STATIC Method */ ! init_java_lang_Class(); ! name = cstring(Harg1); ! for (i=0;iarrayclass) ! return find_classclass(arrayclassof(cl)); ! else ! return find_classclass(cl->arrayclass); } } ! /* ! * Construct signature from a java.lang.Class object ! * Return : number of characters appended ! */ ! static int GetSigFromClass(Object clcl,Char *buf) { ! struct carray *v; ! Class cl; ! Char *p; ! int cnt=0; ! int i,len; cl = find_class((struct in_java_lang_Class*)clcl); ! v = (struct carray*)((struct in_java_lang_String*)(cl->name))->value; ! p = v->data; ! len = ((struct in_java_lang_String*)(cl->name))->count; ! if (cl->flags & IS_PRIMITIVE){ *buf = toupper(*p); ! if (*p=='l') *buf = 'J'; ! if (*p=='b' && *(p+1)=='o') *buf = 'Z'; cnt = 1; ! } ! else{ ! for (*buf++ ='L',cnt=1,i=0; idata; ! struct in_java_lang_Class *elem; *buf++ = '('; ! cnt = 1; for (i=0; ilength; i++){ - if (isArray__yE28G(clcls[i])){ - elem = getComponentType__hwyYb(clcls[i]); - *buf++ = '['; - cnt++; - while (isArray__yE28G(elem)){ - elem = getComponentType__hwyYb(elem); - *buf++ = '['; - cnt++; - } - n = GetSigFromClass(elem,buf); - buf += n; - cnt += n; - } - else{ - n = GetSigFromClass(clcls[i],buf); - buf += n; - cnt += n; - } - } - *buf++ = ')'; - cnt++; - *buf=0; - return cnt; - } ! static Object GetRetTypeFromSig(const Char *sig,int sig_len) ! { ! int t,i; ! for (i=0;i=sig_len) - return 0; ! return GetClassFromSignature(sig+i+1,&t); } ! static Object GetArgTypesFromSig(const Char *sig,int sig_len) { ! struct aarray *args; ! int i,cnt; ! const Char *p; ! for (p=sig+1,cnt=0; *p!=')'; ){ ! if (*p=='L'){ ! while (*p++!=';'); ! cnt++; ! } ! else if (*p=='['){ ! p++; ! } ! else{ ! p++; ! cnt++; ! } } ! args = anewarray(&cl_java_lang_Class.C,cnt); ! for (p=sig+1,i=0; *p!=')'; i++){ ! args->data[i] = GetClassFromSignature(p,&cnt); ! p += cnt; } ! return args; } ! static int SameMethod(struct mt_generic *m1,struct mt_generic *m2); ! /* Return an array of exception classes */ ! static Object GetExceptionTypes(Class cl,struct mt_generic *m) ! { ! struct aarray *ret; ! Class *p; ! int i,j,cnt; ! struct mt_generic *mtable; ! int nmthds; ! int found=0; ! ! /* the exception list is only set in defining class */ ! if (!m->localp){ ! for (i=1;insupers && !found;i++){ ! mtable = cl->supers[i]->smethods; ! nmthds = cl->supers[i]->nsmethods; ! for (j=0;jsupers[i])->M; ! nmthds = cl->supers[i]->nimethods; ! for (j=0;jxlist){ ! ret = anewarray(&cl_java_lang_Class.C,0); ! return ret; } ! /* count the number of exceptions */ ! for (cnt=0,p=m->xlist; *p; p++,cnt++); ! ! ret = anewarray(&cl_java_lang_Class.C,cnt); ! for (i=0; idata[i]=find_classclass(m->xlist[i]); ! return ret; } ! int SameAsJavaStr(const Char *s,int len,Object jstr) ! { ! struct carray *x; ! int i; ! ! if (len!=((struct in_java_lang_String*)jstr)->count) ! return 0; ! x = (struct carray*)((struct in_java_lang_String*)jstr)->value; ! for (i=0;idata[i]) ! return 0; ! return 1; } - static int SameField(struct vt_generic *v1,struct vt_generic *v2) - { - if ( v1->name_len==v2->name_len && - v1->sig_len ==v2->sig_len && - memcmp(v1->name_chars,v2->name_chars,v1->name_len*sizeof(Char))==0 && - memcmp(v1->sig_chars, v2->sig_chars, v1->sig_len*sizeof(Char))==0 ) - return 1; - return 0; - } ! /* Check if a field is declared in the class */ ! static int FieldDeclared(Class cl,struct vt_generic *vt) { ! int i; ! ! for (i=0;incvars;i++){ ! if (cl->cvars[i].localp && SameField(vt,cl->cvars+i)) ! return 1; ! } ! for (i=0;inivars;i++){ ! if (cl->ivars[i].localp && SameField(vt,cl->ivars+i)) ! return 1; } - return 0; - } - - static int SameMethod(struct mt_generic *m1,struct mt_generic *m2) - { - if ( m1->name_len==m2->name_len && - m1->sig_len ==m2->sig_len && - memcmp(m1->name_chars,m2->name_chars,m1->name_len*sizeof(Char))==0 && - memcmp(m1->sig_chars, m2->sig_chars, m1->sig_len*sizeof(Char))==0 ) - return 1; - return 0; - } ! /* Check if a method is declared in the class */ ! static int MethodDeclared(Class cl,struct mt_generic *mt) ! { ! int i; ! struct mt_generic *mtable; ! ! mtable = cl->smethods; ! for (i=0;insmethods;i++){ ! if (mtable[i].localp && SameMethod(mt,mtable+i)) ! return 1; ! } ! mtable = ((struct cl_generic*)cl)->M; ! for (i=0;inimethods;i++){ ! if (mtable[i].localp && SameMethod(mt,mtable+i)) ! return 1; ! } ! return 0; } ! static Object DeclaringClass_V(Class cl,struct vt_generic *v) { int i; ! for (i=0;insupers;i++){ ! if (FieldDeclared(cl->supers[i],v)) ! return find_classclass(cl->supers[i]); } ! } ! static Object DeclaringClass_M(Class cl,struct mt_generic *m) ! { ! int i; ! for (i=0;insupers;i++){ ! if (MethodDeclared(cl->supers[i],m)) ! return find_classclass(cl->supers[i]); } } ! static Object GetReflectField(Class cl, ! struct vt_generic *v, ! int slot) { - int x; struct in_java_lang_reflect_Field *fld; fld = new(&cl_java_lang_reflect_Field.C); fld->name = arraystring(v->name_chars,v->name_len); fld->slot = slot; ! fld->type = GetClassFromSignature(v->sig_chars,&x); ! fld->clazz = DeclaringClass_V(cl,v); return fld; } ! static Object GetReflectMethod(Class cl, ! struct mt_generic *m, ! int slot) { - int x; struct in_java_lang_reflect_Method *mthd; mthd = new(&cl_java_lang_reflect_Method.C); mthd->name = arraystring(m->name_chars,m->name_len); mthd->slot = slot; ! mthd->clazz = DeclaringClass_M(cl,m); mthd->returnType = GetRetTypeFromSig(m->sig_chars,m->sig_len); mthd->parameterTypes = GetArgTypesFromSig(m->sig_chars,m->sig_len); ! mthd->exceptionTypes = GetExceptionTypes(cl,m); return mthd; } - static int isConstructor(struct mt_generic *mt) - { - if (!SameAsJavaStr(mt->name_chars,mt->name_len,javastring(""))) - return 0; - if (mt->sig_chars[mt->sig_len-1]!='V' || mt->sig_chars[mt->sig_len-2]!=')') - return 0; - return 1; - } - - static int CountPublicFields(struct vt_generic *vars,int nvars,int declared) - { - int i; - int cnt; ! for (i=0,cnt=0;iflags & IS_INTERFACE) && !mthds[i].localp){ ! for (j=1;jnsupers;j++){ ! if (MethodDeclared(cl->supers[j],mthds+i)) ! break; ! } ! if (!(cl->supers[j]->flags & IS_INTERFACE)) ! continue; ! } ! ! if (mthds[i].localp || !declared){ ! cnt++; ! } ! } ! } ! return cnt; ! } ! ! /* Fill in the array of java.lang.reflect.Field objects */ ! static int FillPublicFields(Class cl, ! struct in_java_lang_reflect_Field **pfld, ! struct vt_generic *vars, ! int nvars, ! int declared) ! { ! int i,j,cnt; ! int x; ! ! for (i=0,cnt=0;iflags & IS_INTERFACE) && !mtable[i].localp){ ! for (j=1;jnsupers;j++){ ! if (MethodDeclared(cl->supers[j],mtable+i)) ! break; ! } ! if (!(cl->supers[j]->flags & IS_INTERFACE)) ! continue; ! } ! ! if (constr){ ! *pconstr = new(&cl_java_lang_reflect_Constructor.C); ! (*pconstr)->slot = i; ! (*pconstr)->clazz = find_classclass(cl); ! (*pconstr)->parameterTypes = GetArgTypesFromSig(mtable[i].sig_chars, ! mtable[i].sig_len); ! (*pconstr)->exceptionTypes = GetExceptionTypes(cl,mtable+i); ! pconstr++; ! cnt++; ! } ! else{ ! *pmthd = GetReflectMethod(cl,mtable+i,i); ! pmthd++; ! cnt++; ! } ! } } ! return cnt; } ! Object getFields0_i_hY6Lk(Object Harg1, Int arg2) /* Since JDK1.1 */ ! { ! struct in_java_lang_Class *this = (struct in_java_lang_Class *)Harg1; ! Class cl,supercl; ! Object flds; ! int i,cnt; ! struct in_java_lang_reflect_Field **pfld; ! ! cl = find_class(this); ! ! cnt = 0; ! if (!(cl->flags & IS_ARRAY) && !(cl->flags & IS_PRIMITIVE)){ ! for (i=0;insupers;i++) ! cnt += CountPublicFields(cl->supers[i]->cvars,cl->supers[i]->ncvars,arg2); ! cnt += CountPublicFields(cl->ivars,cl->nivars,arg2); } ! flds = anewarray(&cl_java_lang_reflect_Field.C,cnt); ! if (!cnt) ! return flds; ! ! pfld = (struct in_java_lang_reflect_Field**)(((struct aarray*)flds)->data); ! for (i=0;insupers;i++){ ! supercl = cl->supers[i]; ! cnt = FillPublicFields(supercl,pfld,supercl->cvars,supercl->ncvars,arg2); ! pfld += cnt; } - FillPublicFields(cl,pfld,cl->ivars,cl->nivars,arg2); - return flds; - } - - Object getMethods0_i_XYCWL(Object Harg1, Int arg2) /* Since JDK1.1 */ - { - struct in_java_lang_Class *this = (struct in_java_lang_Class *)Harg1; - Class cl,supercl; - Object mthds; - int i,cnt; - struct in_java_lang_reflect_Method **pmthd; cl = find_class(this); ! for (i=0,cnt=0;insupers;i++){ ! cnt += CountPublicMethods(cl,cl->supers[i]->smethods,cl->supers[i]->nsmethods,arg2,0); } - cnt += CountPublicMethods(cl,((struct cl_generic *)cl)->M,cl->nimethods,arg2,0); - - mthds = anewarray(&cl_java_lang_reflect_Method.C,cnt); - if (!cnt) - return mthds; - pmthd = (struct in_java_lang_reflect_Method **)(((struct aarray*)mthds)->data); - for (i=0;insupers;i++){ - supercl = cl->supers[i]; - cnt = FillPublicMethods(supercl,pmthd,supercl->smethods,supercl->nsmethods,arg2,0); - pmthd += cnt; - } - FillPublicMethods(cl,pmthd,((struct cl_generic *)cl)->M,cl->nimethods,arg2,0); return mthds; } ! Object getConstructors0_i_L3cNN(Object Harg1, Int arg2) /* Since JDK1.1 */ ! { ! struct in_java_lang_Class *this = (struct in_java_lang_Class *)Harg1; ! Class cl,supercl; ! Object mthds; ! int i,cnt; ! struct in_java_lang_reflect_Constructor **pcons; cl = find_class(this); ! cnt = CountPublicMethods(cl,((struct cl_generic *)cl)->M,cl->nimethods,arg2,1); ! ! mthds = anewarray(&cl_java_lang_reflect_Constructor.C,cnt); ! if (!cnt) ! return mthds; ! ! pcons = (struct in_java_lang_reflect_Constructor **)(((struct aarray*)mthds)->data); ! FillPublicMethods(cl,pcons,((struct cl_generic *)cl)->M,cl->nimethods,arg2,1); ! return mthds; ! } ! ! Object getField0_Si_JLURr(Object Harg1, Object Harg2, Int arg3) /* Since JDK1.1 */ ! { ! struct in_java_lang_Class *this = (struct in_java_lang_Class *)Harg1; ! struct in_java_lang_String *fldname = (struct in_java_lang_String*)Harg2; ! struct vt_generic *vars; ! Class cl; ! int i,j,nvars; ! ! cl = find_class(this); ! nvars = cl->nivars; ! vars = cl->ivars; ! for (j=0;jnsupers;i++){ ! nvars = cl->supers[i]->ncvars; ! vars = cl->supers[i]->cvars; ! for (j=0;jcount; ! ! if (arg4){ ! /* If arg4==1 then only find declared method */ ! nsupers = 1; } ! else{ ! nsupers = cl->nsupers; } ! num = cl->nimethods; ! mtable = ((struct cl_generic *)cl)->M; ! for (j=0;jnsupers;i++){ ! num = cl->supers[i]->nsmethods; ! mtable = cl->supers[i]->smethods; ! for (j=0;j"); ! namelen = 6; ! ! if (arg3){ ! /* If arg3==1 then only find declared method */ ! nsupers = 1; ! } ! else{ ! nsupers = cl->nsupers; ! } ! ! for (i=0;insupers;i++){ ! num = cl->supers[i]->nimethods; ! mtable = ((struct cl_generic *)cl->supers[i])->M; ! for (j=0;jslot = j; ! constr->clazz = find_classclass(cl->supers[i]); ! constr->parameterTypes = GetArgTypesFromSig(mtable[j].sig_chars,mtable[j].sig_len); ! constr->exceptionTypes = GetExceptionTypes(cl->supers[i],mtable+j); ! return constr; ! } ! } } - throwMesg(&cl_java_lang_NoSuchMethodException.C,"getConstructor0"); - return 0; - } --- 319,1653 ---- { return anewarray(&cl_java_lang_Object.C,0); } + Void setSigners_aO_la6GY(Object Harg1, Object Harg2) /* Unimplemented JDK1.1 */ { + /* shouldn't we beef about this? */ } extern struct class cl_void; ! static PrimClassTriple ! primTriples [] = { ! {"int", 'I', &cl_int, &cl_java_lang_Integer.C, sizeof(Int), offsetof(struct in_java_lang_Integer, value)}, ! {"boolean", 'Z', &cl_boolean, &cl_java_lang_Boolean.C, sizeof(Boolean), offsetof(struct in_java_lang_Boolean, value)}, ! {"byte", 'B', &cl_byte, &cl_java_lang_Byte.C, sizeof(Byte), offsetof(struct in_java_lang_Byte, value)}, ! {"short", 'S', &cl_short, &cl_java_lang_Short.C, sizeof(Short), offsetof(struct in_java_lang_Short, value)}, ! {"char", 'C', &cl_char, &cl_java_lang_Character.C, sizeof(Char), offsetof(struct in_java_lang_Character, value)}, ! {"long", 'J', &cl_long, &cl_java_lang_Long.C, sizeof(Long), offsetof(struct in_java_lang_Long, value)}, ! {"float", 'F', &cl_float, &cl_java_lang_Float.C, sizeof(Float), offsetof(struct in_java_lang_Float, value)}, ! {"double", 'D', &cl_double, &cl_java_lang_Double.C, sizeof(Double), offsetof(struct in_java_lang_Double, value)}, ! {"void", 'V', &cl_void, &cl_java_lang_Void.C, 0, 0} ! }; ! static const int nPrimTriples = sizeof (primTriples) / sizeof (*primTriples); ! ! /* Look up class information given a pointer to the internal structure ! * for the primitive class; e.g. &cl_boolean. Returns NULL if the ! * provided class isn't primitive. */ ! PrimClassTriple * ! getPCTbyPrimClass (Class primcl) { ! int i; ! for (i = 0; i < nPrimTriples; i++) { ! if (primTriples[i].primClass == primcl) { ! return primTriples + i; ! } ! } ! return NULL; ! } ! /* Look up class information given a pointer to the internal structure ! * for the object class; e.g. java.lang.Boolean. Returns NULL if the ! * provided class doesn't have a primitive analogue. */ ! PrimClassTriple * ! getPCTbyObjClass (Class objcl) ! { ! int i; ! for (i = 0; i < nPrimTriples; i++) { ! if (primTriples[i].objClass == objcl) { ! return primTriples + i; ! } ! } ! return NULL; ! } ! /* Look up class information given the java language level name of ! * the type; e.g., boolean. Returns NULL if the name doesn't ! * name a primitive type. */ ! PrimClassTriple * ! getPCTbyName (char *name) ! { ! int i; ! for (i = 0; i < nPrimTriples; i++) { ! if (0 == strcmp(primTriples[i].name,name)) { ! return primTriples + i; ! } ! } ! return NULL; } ! /* Look up class information given the character by which the type is ! * represented in signatures; e.g. 'Z'. Returns NULL if the provided char ! * doesn't represent a primitive type. */ ! PrimClassTriple * ! getPCTbySigChar (int sch) { ! int i; ! for (i = 0; i < nPrimTriples; i++) { ! if (primTriples[i].sigChar == sch) { ! return primTriples + i; ! } ! } ! return NULL; ! } ! ! /* Given: a generic pointer to a primitive value and the Class ! * corresponding to the (primitive or wrapper) type of that value, create a ! * new instance of the corresponding wrapper class and copy the value into ! * it. Returns NULL iff the provided class has no primitive ! * correspondent. */ ! Object ! wrapPrimObject (Class primClass, /* Class denoting value; e.g. &cl_int */ ! void * vaddr) ! { ! PrimClassTriple * wpct; /* Information on destination type */ ! Object rv; /* Value we're returning */ ! ! /* Gotta have a source value address, the source class, and an ! * object into which we can store the value. */ ! assert (NULL != vaddr); ! assert (NULL != primClass); ! assert (IS_PRIMITIVE & primClass->flags); ! ! wpct = getPCTbyPrimClass (primClass); ! ! /* Get the translation information corresponding to the target class. */ ! assert (NULL != wpct); ! ! /* Allocate a new object of the appropriate class. */ ! rv = new (PCT_objClass (wpct)); ! assert (NULL != rv); ! ! /* Make sure the primitive class type has data (isn't void), and ! * figure out where in it the primitive value is stored. */ ! assert (0 < PCT_primSize (wpct)); ! memcpy (PCT_objPrimValAddr (wpct, rv), vaddr, PCT_primSize (wpct)); ! ! return rv; ! } ! ! /* Given types and pointers-to-values for source and destination, assign the ! * source to the destination through any widening conversion that is necessary. ! * The types must name primitive classes, not the corresponding wrapped classes. ! * Iff either type is not a primitive type, or there is no valid widening ! * conversion from the source to destination type, the function returns 0. */ ! int ! widenConvert (Class stype, /* Source type */ ! void * svp, /* Pointer to primitive value in source type */ ! Class dtype, /* Destination type */ ! void * dvp) /* Pointer to storage for primitive value in destination type */ ! { ! AnyJavaValue * sval; ! AnyJavaValue * dval; ! Boolean badconv; ! if (! ((IS_PRIMITIVE & dtype->flags) && ! (IS_PRIMITIVE & stype->flags))) { ! return 0; } + + sval = (AnyJavaValue *) svp; + dval = (AnyJavaValue *) dvp; + + if (stype == dtype) { + PrimClassTriple * pct; + + /* Can't just assign over; one or the other of the values + * pointed to might not be the size of an AnyJavaValue. Look + * up the type, and copy over only what's necessary. */ + pct = getPCTbyPrimClass (stype); + assert (NULL != pct); + memcpy (dval, sval, PCT_primSize (pct)); + return 1; + } + + /* Macro sees whether the desired destination type is _ptype; if it is, + * extracts the _sfld field from the source value and casts it through + * _jtype to store into _dfld field of the destination value. */ + #define CheckAndAssign(_ptype,_jtype,_sfld,_dfld) \ + if (&cl_##_ptype == dtype) { \ + dval->_dfld = (_jtype) sval->_sfld; \ + } \ + + /* Gotta do a widening conversion. What's allowed is defined by JLS + * section 5.1.2. */ + badconv = JAVA_FALSE; + if (&cl_byte == stype) { + CheckAndAssign(short,Short,B,S) + else CheckAndAssign(int,Int,B,I) + else CheckAndAssign(long,Long,B,J) + else CheckAndAssign(float,Float,B,F) + else CheckAndAssign(double,Double,B,D) + else { + badconv = JAVA_TRUE; + } + } else if (&cl_short == stype) { + CheckAndAssign(int,Int,S,I) + else CheckAndAssign(long,Long,S,J) + else CheckAndAssign(float,Float,S,F) + else CheckAndAssign(double,Double,S,D) + else { + badconv = JAVA_TRUE; + } + } else if (&cl_char == stype) { + CheckAndAssign(int,Int,C,I) + else CheckAndAssign(long,Long,C,J) + else CheckAndAssign(float,Float,C,F) + else CheckAndAssign(double,Double,C,D) + else { + badconv = JAVA_TRUE; + } + } else if (&cl_int == stype) { + CheckAndAssign(long,Long,I,J) + else CheckAndAssign(float,Float,I,F) + else CheckAndAssign(double,Double,I,D) + else { + badconv = JAVA_TRUE; + } + } else if (&cl_long == stype) { + CheckAndAssign(float,Float,J,F) + else CheckAndAssign(double,Double,J,D) + else { + badconv = JAVA_TRUE; + } + } else if (&cl_float == stype) { + CheckAndAssign(double,Double,F,D) + else { + badconv = JAVA_TRUE; + } + } else { + badconv = JAVA_TRUE; + } + #undef CheckAndAssign + + return (! badconv); } ! Object ! getPrimitiveClass_S_JFLGD (Object Harg1) /* Since JDK1.1 */ { ! char *name; /* Name of the class in C format */ ! PrimClassTriple * pct; ! ! init_java_lang_Class(); ! name = cstring(Harg1); ! pct = getPCTbyName (name); ! if (NULL != pct) { ! return PCT_primClassClass(pct); ! } ! throwClassNotFoundException(name); ! /*NOTREACHED*/ ! } ! ! /* Parse signature and return a java Class object */ ! static Object ! GetClassFromSignature (const Char * sig, ! int * cnt) ! { ! if (NULL != cnt) { ! *cnt = 1; ! } ! switch (toupper(*sig)) { ! case 'B': ! return &cl_byte.classclass; ! case 'C': ! return &cl_char.classclass; ! case 'D': ! return &cl_double.classclass; ! case 'F': ! return &cl_float.classclass; ! case 'I': ! return &cl_int.classclass; ! case 'J': ! return &cl_long.classclass; ! case 'S': ! return &cl_short.classclass; ! case 'V': ! return &cl_void.classclass; ! case 'Z': ! return &cl_boolean.classclass; ! case 'L': { ! Char buf[1024]; ! int i; ! ! /* NB: We're working on 16bit chars here, so can't use ! * standard str* routines. We're assuming the signature ! * is properly formatted (has a ';'), and isn't too ! * long. */ ! ++sig; ! i = 0; ! /* Copy over all characters up to the terminating semicolon, ! * translating slashes into dots */ ! while ((';' != *sig) && ! (i < (sizeof (buf) - 1))) { ! buf [i] = *(sig++); ! if ('/' == buf [i]) { ! buf [i] = '.'; ! } ! ++i; ! } ! buf [i] = 0; ! if (NULL != cnt) { ! /* 'L' + name + ';' */ ! *cnt = 1 + i + 1; ! } ! return forName_S_UuOsX(arraystring(buf,i)); ! } ! case '[': { ! int arank; /* Rank (depth) of the array */ ! Object clcl; /* jl.Class object corresponding to base element */ ! Class cl; /* Class structure corresponding to array or element */ ! ! /* Determine the rank of the array by counting the left ! * brackets. */ ! arank = 1; ! while ('[' == *++sig) { ! ++arank; ! } ! ! /* We've reached the base element. Figure out what it is, ! * including its length. Then add to the length what ! * we already consumed computing the array rank. */ ! clcl = GetClassFromSignature(sig, cnt); ! if (NULL != cnt) { ! *cnt += arank; ! } ! ! /* Now we need to back up arank levels of array on top ! * of the base element. We do all this in the C class ! * structures, since it's easier. */ ! cl = find_class(clcl); ! while (0 <= --arank) { ! if (cl->arrayclass) { ! /* Already have a class for arrays of these; use it. */ ! cl = cl->arrayclass; ! } else { ! /* Don't have an array of these yet; build one. */ ! cl = arrayclassof (cl); ! } ! } ! ! /* Return the jl.Class object corresponding to the final ! * array class. */ ! return find_classclass (cl); ! } ! } ! /*NOTREACHED*/ ! } ! ! /* Given a java.lang.Class object, append to the buffer the sequence of ! * Java characters which represent it in signatures. The object must ! * either a primitive or a base object, not an array. Returns the number ! * of chars added to the buffer. */ ! static int ! buildSigFromClass (Object clcl, /* Class for signature */ ! Char * buf) /* Where to start storing signature chars */ ! { ! Class cl; /* C class data */ ! struct in_java_lang_String * cln; /* Name of class */ ! Char *p; /* Pointer into class name */ ! int cnt; /* Number of characters added to buffer */ ! int len; /* Number of chars remaining in name */ cl = find_class((struct in_java_lang_Class*)clcl); ! cln = (struct in_java_lang_String *) cl->name; ! p = cln->offset + ((struct carray*) cln->value)->data; ! len = cln->count; ! if (cl->flags & IS_PRIMITIVE) { *buf = toupper(*p); ! if ('l' == *p) { ! /* long is J not L */ *buf = 'J'; ! } else if (('b' == p[0]) && ('o' == p[1])) { ! /* boolean is Z not B */ *buf = 'Z'; + } cnt = 1; ! } else { ! int i; /* Index over name length */ ! ! /* Apparently someone thinks we'll never see an array class here. ! * Are they right? As this function is used right now, they are, ! * but in case somebody wants to reuse it elsewhere, we really ought ! * to check. */ ! assert (! (IS_ARRAY & cl->flags)); ! ! /* Insert the name (with dots converted to slashes) between an L ! * and a semicolon. */ ! *(buf++) = 'L'; ! i = 0; ! while (i < len) { ! *buf = *(p++); ! if ('.' == *buf) { ! *buf = '/'; ! } ! ++buf; ! ++i; ! } *buf = ';'; ! /* 'L' + name + ';' */ ! cnt = 1 + i + 1; } return cnt; } ! /* Construct the (partial) signature from an array of java.lang.Class objects. */ ! static int ! buildSigFromArgTypes (Object args, /* Class [] object */ ! Char * buf) /* Where to store partial signature */ ! { ! int i; /* Index over arguments */ ! Char * obuf; /* Start of stored signature */ ! struct aarray *a; /* C structure of jlC array */ ! struct in_java_lang_Class **clcls; /* Pointer to sequence of jlC objects */ ! struct in_java_lang_Class *elem; /* Pointer to current argument class */ ! ! /* Record where we started, so we can compute how many chars ! * we added. */ ! obuf = buf; + /* Start with the opening parenthesis. */ *buf++ = '('; ! ! /* For each class in the array of classes, append any required array ! * prefixes, and the signature for the base element. */ ! a = (struct aarray*)args; ! clcls = (struct in_java_lang_Class**)a->data; for (i=0; ilength; i++){ ! /* Get the parameter class. If it's an array, append the ! * appropriate number of array markers. */ ! elem = clcls [i]; ! while (isArray__yE28G (elem)) { ! *buf++ = '['; ! elem = getComponentType__hwyYb(elem); ! } ! /* Append the signature for the base type. */ ! buf += buildSigFromClass(elem,buf); } ! /* Tack on the closing parenthesis. */ ! *buf++ = ')'; ! ! /* Return the number of chars appended. */ ! return (buf - obuf); } ! /* Return the java Class object corresponding to the return type of a method ! * with the provided signature. */ ! static Object ! GetRetTypeFromSig (const Char *sig, /* Signature of a method */ ! int sig_len) /* Length of the signature */ { ! int i; /* Index into signature */ ! /* Scan backwards for the parenthesis that marks the end of the ! * parameter list. */ ! i = sig_len; ! while ((0 <= i) && ! (')' != sig [i])) { ! --i; } ! /* If we didn't find a close paren, something went very badly wrong. */ ! if (0 > i) { ! return 0; } ! ! return GetClassFromSignature(sig+i+1, NULL); } ! /* Build an array of java.lang.Class objects corresponding to the ! * parameter types described by the provided signature. */ ! static Object ! GetArgTypesFromSig (const Char *sig, /* Parenthesized partial signature */ ! int sig_len) /* Length of signature */ ! { ! struct aarray *args; /* Array of jlC objects */ ! int na; /* Number of arguments in signature */ ! const Char *p; /* Pointer into signature */ ! ! assert ('(' == *sig); ! ! /* First, parse the argument list to the extent that we can count ! * the number of args. */ ! p = sig + 1; ! na = 0; ! while (')' != *p) { ! if ('L' == *p) { ! /* Object type: increment the argument count, and skip ! * over the thing. */ ! ++na; ! while (';' != *++p) { ! /* skipping to end of Object param */ ! } ! /* skip over the trailing semicolon too */ ! ++p; ! } else if ('[' == *p) { ! /* Skip over array markers; we account for the argument ! * when we hit the base type. */ ! while ('[' == *++p) { ! /* skipping to end of brackets */ ! } ! } else { ! /* Ought to be a primitive type; skip over it, and ! * increment the argument count */ ! ++p; ! ++na; ! } } + + /* Allocate an array of jlC objects to hold the parameter types. */ + args = anewarray(&cl_java_lang_Class.C, na); ! /* Rewalk the signature storing the actual argument type classes. */ ! na = 0; ! p = sig + 1; ! while (')' != *p) { ! int plen; ! ! args->data [na++] = GetClassFromSignature(p, &plen); ! p += plen; ! /* Let's just be sure that the signature parsing ends up ! * counting the same number of arguments as we did above. */ ! assert (na <= args->length); } ! assert (na == args->length); ! return args; } ! #define FieldMatchNameSig(_f1,_f2) ( \ ! ((_f1)->name_len == (_f2)->name_len) && \ ! ((_f1)->sig_len == (_f2)->sig_len) && \ ! (0 == memcmp ((_f1)->name_chars, (_f2)->name_chars, (_f2)->name_len * sizeof (*(_f2)->name_chars))) && \ ! (0 == memcmp ((_f1)->sig_chars, (_f2)->sig_chars, (_f2)->sig_len * sizeof (*(_f2)->sig_chars))) \ ! ) ! ! /* Find the last method in the table of the given length that matches ! * the provided method in name and signature. If needLocal is true, ! * we further require that a match have the localp flag set. Returns ! * a pointer to the match, or NULL if there is none. */ ! struct mt_generic * ! findMethodInTable (struct mt_generic * m, /* Method we're trying to match */ ! struct mt_generic * mtable, /* Array of method structures to compare with */ ! int nmtb, /* Number of entries in mtable */ ! int needLocal) /* Do we insist that the match have localp set? */ ! { ! struct mt_generic * pm; ! ! /* Walk the table from top down, looking for a name+sig match */ ! pm = mtable + nmtb; ! while (0 <= --nmtb) { ! --pm; ! if (FieldMatchNameSig(pm,m)) { ! /* Found an entry that matches in name and signature. If we ! * don't care about it being local, or it is local, return it. ! * If we need a local one and this one isn't local, then ! * treat this as failure to find a match. We should _not_ ! * be able to find a method in this table that is local _and_ ! * has been overloaded in this class by a non-local method. */ ! if (pm->localp || (! needLocal)) { ! return pm; ! } ! return NULL; ! } ! } ! return NULL; ! } ! ! /* Scan through the provided method table, looking for a method that has ! * the same name and signature as that provided. The signature need ! * match only the parameter portion, not the return value. */ ! static struct mt_generic * ! findNamedMethodInTable (struct in_java_lang_String * name, /* Name of method */ ! Char * sig_chars, /* Parameter portion of signature */ ! int sig_len, /* Length of partial signature */ ! struct mt_generic * mtable, /* Sequence of method structures */ ! int nmtb) /* Number of method structures in table */ ! { ! struct mt_generic * pm; /* Potential method match */ ! const Char * name_chars; /* Java char data for name */ ! int name_len; /* Length of name */ ! ! /* Get the character data and length of the provided name. */ ! name_chars = name->offset + ((struct carray *)name->value)->data; ! name_len = name->count; ! ! /* Walk the table from top down, looking for a name+sig match. ! * Note that we only compare the first sig_len chars of the signature, ! * since we are not checking against the return type. The partial ! * signature should start and end with parentheses to avoid ! * any improper prefix matching. */ ! pm = mtable + nmtb; ! while (0 <= --nmtb) { ! --pm; ! if ((pm->name_len == name_len) && ! (pm->sig_len > sig_len) && ! (0 == memcmp (pm->name_chars, name_chars, name_len * sizeof (*name_chars))) && ! (0 == memcmp (pm->sig_chars, sig_chars, sig_len * sizeof (*sig_chars)))) { ! ! /* The entry matches in name and signature; return it. */ ! return pm; ! } ! } ! ! /* No match: return null */ ! return NULL; ! } ! ! ! /* Scan through the provided field table, looking for a field that has ! * the same name as that provided. */ ! static struct vt_generic * ! findNamedFieldInTable (struct in_java_lang_String * name, /* Name of field */ ! struct vt_generic * ftable, /* Sequence of field structures */ ! int nftb) /* Number of field structures in table */ ! { ! struct vt_generic * pf; /* Potential field match */ ! const Char * name_chars; /* Java char data for name */ ! int name_len; /* Length of name */ ! ! /* Get the character data and length of the provided name. */ ! name_chars = name->offset + ((struct carray *)name->value)->data; ! name_len = name->count; ! ! /* Walk the table from top down, looking for a name match. */ ! pf = ftable + nftb; ! while (0 <= --nftb) { ! --pf; ! if ((pf->name_len == name_len) && ! (0 == memcmp (pf->name_chars, name_chars, name_len * sizeof (*name_chars)))) { ! /* The entry matches in name; return it. */ ! return pf; ! } ! } ! /* No match: return null */ ! return NULL; } + ! /* Return an array of exception classes */ ! static Object ! GetExceptionTypes (struct mt_generic *m) { ! struct aarray *ret; /* Array of class objects representing exceptions */ ! Class * ecl; /* Pointer into the exception table */ ! int nexc; /* Number of exceptions */ ! ! /* The exception list is null-terminated. Count the number of exceptions. ! * Count should be zero if the exception list is undefined (null). */ ! nexc = 0; ! ecl = m->xlist; ! while ((NULL != ecl) && (NULL != *(ecl++))) { ! ++nexc; ! } ! ! /* Allocate an array of class pointers, then store the Class entries ! * for each exception. */ ! ret = anewarray(&cl_java_lang_Class.C, nexc); ! while (0 <= --nexc) { ! ret->data [nexc] = find_classclass (m->xlist [nexc]); } ! return ret; } ! int SameAsJavaStr (const Char *s,int len,Object arg3) { + struct in_java_lang_String * jstr = (struct in_java_lang_String *) arg3; + Char * scp; int i; ! if (len != jstr->count) { ! return 0; } ! scp = jstr->offset + ((struct carray*)jstr->value)->data; ! while (0 <= --len) { ! if (s [len] != scp [len]) { ! return 0; ! } } + + return 1; } ! static Object ! buildReflectField(Class cl, ! struct vt_generic *v, ! int slot) { struct in_java_lang_reflect_Field *fld; + assert (FTS_invalidSlot != slot); fld = new(&cl_java_lang_reflect_Field.C); fld->name = arraystring(v->name_chars,v->name_len); fld->slot = slot; ! fld->type = GetClassFromSignature(v->sig_chars, NULL); ! /* The class we store is the one we found the field in, i.e. ! * the one where it's declared. We don't dynamically re-resolve ! * at runtime---doing so would prevent accessing obscured instance ! * fields. */ ! assert (v->localp); ! fld-