[pypy-svn] r52062 - in pypy/branch/fixed-list-ootype/pypy/translator/jvm: . src/pypy test

niko at codespeak.net niko at codespeak.net
Sun Mar 2 18:48:49 CET 2008


Author: niko
Date: Sun Mar  2 18:48:48 2008
New Revision: 52062

Added:
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/src/pypy/VoidArray.java
Modified:
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/builtin.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/constant.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/database.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/generator.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/metavm.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/methods.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/node.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/opcodes.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/test/test_class.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py
Log:
a big refactoring aiming at better support for array branch.  Move 
most jvm constants etc into typesystem.py, which should eventually
be renamed to jvm.py as it is more general now.  Change arrays to use
the new VoidArray class, and refactor how array methods were supported
to make them more general (there is now an OpcodeMethod which is something
that can be called like a method, but is implemented via a native opcode).



Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/builtin.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/builtin.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/builtin.py	Sun Mar  2 18:48:48 2008
@@ -1,5 +1,4 @@
-from pypy.translator.jvm import typesystem as jvmtype
-from pypy.translator.jvm import generator as jvmgen
+import pypy.translator.jvm.typesystem as jvm
 from pypy.rpython.ootypesystem import ootype
 from pypy.translator.jvm.typesystem import \
      jInt, jVoid, jStringBuilder, jString, jPyPy, jChar, jArrayList, jObject, \
@@ -9,7 +8,7 @@
 # ______________________________________________________________________
 # Mapping of built-in OOTypes to JVM types
 
-class JvmBuiltInType(jvmtype.JvmClassType):
+class JvmBuiltInType(jvm.JvmClassType):
     
     """
     Represents built-in types to JVM.  May optionally be associated
@@ -18,7 +17,7 @@
     """
     
     def __init__(self, db, classty, OOTYPE):
-        jvmtype.JvmClassType.__init__(self, classty.name)
+        jvm.JvmClassType.__init__(self, classty.name)
         self.db = db
         self.OOTYPE = OOTYPE
         self.gen = Generifier(OOTYPE)
@@ -30,14 +29,14 @@
         return hash(self.name)
 
     def lookup_field(self, fieldnm):
-        """ Given a field name, returns a jvmgen.Field object """
+        """ Given a field name, returns a jvm.Field object """
         _, FIELDTY = self.OOTYPE._lookup_field(fieldnm)
         jfieldty = self.db.lltype_to_cts(FIELDTY)
-        return jvmgen.Field(
+        return jvm.Field(
             self.descriptor.class_name(), fieldnm, jfieldty, False)
 
     def lookup_method(self, methodnm):
-        """ Given the method name, returns a jvmgen.Method object """
+        """ Given the method name, returns a jvm.Method object """
 
         # Look for a shortcut method in our table of remappings:
         try:
@@ -56,14 +55,14 @@
         if self.OOTYPE.__class__ in bridged_objects:
             # Bridged objects are ones where we have written a java class
             # that has methods with the correct names and types already
-            return jvmgen.Method.v(self, methodnm, jargtypes, jrettype)
+            return jvm.Method.v(self, methodnm, jargtypes, jrettype)
         else:
             # By default, we assume it is a static method on the PyPy
             # object, that takes an instance of this object as the first
             # argument.  The other arguments we just convert to java versions,
             # except for generics.
             jargtypes = [self] + jargtypes
-            return jvmgen.Method.s(jPyPy, methodnm, jargtypes, jrettype)
+            return jvm.Method.s(jPyPy, methodnm, jargtypes, jrettype)
 
 # When we lookup a method on a BuiltInClassNode, we first check the
 # 'built_in_methods' and 'bridged_objects' tables.  This allows us to
@@ -80,73 +79,73 @@
     # .__class__ is required
     
     (ootype.StringBuilder.__class__, "ll_allocate"):
-    jvmgen.Method.v(jStringBuilder, "ensureCapacity", (jInt,), jVoid),
+    jvm.Method.v(jStringBuilder, "ensureCapacity", (jInt,), jVoid),
     
     (ootype.StringBuilder.__class__, "ll_build"):
-    jvmgen.Method.v(jStringBuilder, "toString", (), jString),
+    jvm.Method.v(jStringBuilder, "toString", (), jString),
 
     (ootype.String.__class__, "ll_streq"):
-    jvmgen.Method.v(jString, "equals", (jObject,), jBool),
+    jvm.Method.v(jString, "equals", (jObject,), jBool),
 
     (ootype.String.__class__, "ll_strlen"):
-    jvmgen.Method.v(jString, "length", (), jInt),
+    jvm.Method.v(jString, "length", (), jInt),
     
     (ootype.String.__class__, "ll_stritem_nonneg"):
-    jvmgen.Method.v(jString, "charAt", (jInt,), jChar),
+    jvm.Method.v(jString, "charAt", (jInt,), jChar),
 
     (ootype.String.__class__, "ll_startswith"):
-    jvmgen.Method.v(jString, "startsWith", (jString,), jBool),
+    jvm.Method.v(jString, "startsWith", (jString,), jBool),
 
     (ootype.String.__class__, "ll_endswith"):
-    jvmgen.Method.v(jString, "endsWith", (jString,), jBool),
+    jvm.Method.v(jString, "endsWith", (jString,), jBool),
 
     (ootype.String.__class__, "ll_strcmp"):
-    jvmgen.Method.v(jString, "compareTo", (jString,), jInt),
+    jvm.Method.v(jString, "compareTo", (jString,), jInt),
 
     (ootype.String.__class__, "ll_upper"):
-    jvmgen.Method.v(jString, "toUpperCase", (), jString),
+    jvm.Method.v(jString, "toUpperCase", (), jString),
 
     (ootype.String.__class__, "ll_lower"):
-    jvmgen.Method.v(jString, "toLowerCase", (), jString),
+    jvm.Method.v(jString, "toLowerCase", (), jString),
 
     (ootype.String.__class__, "ll_replace_chr_chr"):
-    jvmgen.Method.v(jString, "replace", (jChar, jChar), jString),
+    jvm.Method.v(jString, "replace", (jChar, jChar), jString),
 
     (ootype.Dict, "ll_set"):
-    jvmgen.Method.v(jHashMap, "put", (jObject, jObject), jObject),
+    jvm.Method.v(jHashMap, "put", (jObject, jObject), jObject),
     
     (ootype.Dict, "ll_get"):
-    jvmgen.Method.v(jHashMap, "get", (jObject,), jObject),
+    jvm.Method.v(jHashMap, "get", (jObject,), jObject),
 
     (ootype.Dict, "ll_contains"):
-    jvmgen.Method.v(jHashMap, "containsKey", (jObject,), jBool),
+    jvm.Method.v(jHashMap, "containsKey", (jObject,), jBool),
 
     (ootype.Dict, "ll_length"):
-    jvmgen.Method.v(jHashMap, "size", (), jInt),
+    jvm.Method.v(jHashMap, "size", (), jInt),
     
     (ootype.Dict, "ll_clear"):
-    jvmgen.Method.v(jHashMap, "clear", (), jVoid),
+    jvm.Method.v(jHashMap, "clear", (), jVoid),
 
     (ootype.CustomDict, "ll_set"):
-    jvmgen.Method.v(jPyPyCustomDict, "put", (jObject, jObject), jObject),
+    jvm.Method.v(jPyPyCustomDict, "put", (jObject, jObject), jObject),
     
     (ootype.CustomDict, "ll_get"):
-    jvmgen.Method.v(jPyPyCustomDict, "get", (jObject,), jObject),
+    jvm.Method.v(jPyPyCustomDict, "get", (jObject,), jObject),
 
     (ootype.CustomDict, "ll_contains"):
-    jvmgen.Method.v(jPyPyCustomDict, "containsKey", (jObject,), jBool),
+    jvm.Method.v(jPyPyCustomDict, "containsKey", (jObject,), jBool),
 
     (ootype.CustomDict, "ll_length"):
-    jvmgen.Method.v(jPyPyCustomDict, "size", (), jInt),
+    jvm.Method.v(jPyPyCustomDict, "size", (), jInt),
     
     (ootype.CustomDict, "ll_clear"):
-    jvmgen.Method.v(jPyPyCustomDict, "clear", (), jVoid),
+    jvm.Method.v(jPyPyCustomDict, "clear", (), jVoid),
 
     (ootype.List, "ll_length"):
-    jvmgen.Method.v(jArrayList, "size", (), jInt),
+    jvm.Method.v(jArrayList, "size", (), jInt),
 
     (ootype.List, "ll_getitem_fast"):
-    jvmgen.Method.v(jArrayList, "get", (jInt,), jObject),
+    jvm.Method.v(jArrayList, "get", (jInt,), jObject),
 
     }
 

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/constant.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/constant.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/constant.py	Sun Mar  2 18:48:48 2008
@@ -1,15 +1,14 @@
 from pypy.rpython.ootypesystem import ootype
 from pypy.objspace.flow import model as flowmodel
-from pypy.translator.jvm.generator import \
-     Field, Method, CUSTOMDICTMAKE
+import pypy.translator.jvm.typesystem as jvm
+from pypy.translator.jvm.typesystem import \
+     jVoid, Method, Field
 from pypy.translator.oosupport.constant import \
      BaseConstantGenerator, RecordConst, InstanceConst, ClassConst, \
      StaticMethodConst, CustomDictConst, WeakRefConst, push_constant, \
      MAX_CONST_PER_STEP
-from pypy.translator.jvm.typesystem import \
-     jObject, jVoid, jPyPyWeakRef, JvmClassType
 
-jPyPyConstantInit = JvmClassType('pypy.ConstantInit')
+jPyPyConstantInit = jvm.JvmClassType('pypy.ConstantInit')
 jPyPyConstantInitMethod = Method.s(jPyPyConstantInit, 'init', [], jVoid)
 
 # ___________________________________________________________________________
@@ -51,7 +50,7 @@
         # This prevents any one class from getting too big.
         if (self.num_constants % MAX_CONST_PER_STEP) == 0:
             cc_num = len(self.ccs)
-            self.ccs.append(JvmClassType('pypy.Constant_%d' % cc_num))
+            self.ccs.append(jvm.JvmClassType('pypy.Constant_%d' % cc_num))
         self.num_constants += 1
 
         const.fieldobj = Field(self.ccs[-1].name, const.name, jfieldty, True)
@@ -99,7 +98,7 @@
             except KeyError:
                 constants_by_cls[const.fieldobj.class_name] = [const]
         for cc in self.ccs:
-            ilasm.begin_class(cc, jObject)
+            ilasm.begin_class(cc, jvm.jObject)
             for const in constants_by_cls[cc.name]:
                 ilasm.add_field(const.fieldobj)
             ilasm.end_class()
@@ -122,8 +121,9 @@
             self._push_constant_during_init(gen, const)
 
     def _declare_step(self, gen, stepnum):
-        self.step_classes.append(JvmClassType('pypy.ConstantInit_%d' % stepnum))
-        gen.begin_class(self.step_classes[-1], jObject)
+        self.step_classes.append(jvm.JvmClassType(
+            'pypy.ConstantInit_%d' % stepnum))
+        gen.begin_class(self.step_classes[-1], jvm.jObject)
         gen.begin_function('constant_init', [], [], jVoid, True)
 
     def _close_step(self, gen, stepnum):
@@ -132,7 +132,7 @@
         gen.end_class()       # end pypy.ConstantInit_NNN
     
     def _end_gen_constants(self, gen, numsteps):
-        gen.begin_class(jPyPyConstantInit, jObject)
+        gen.begin_class(jPyPyConstantInit, jvm.jObject)
         gen.begin_j_function(jPyPyConstantInit, jPyPyConstantInitMethod)
         for cls in self.step_classes:
             m = Method.s(cls, "constant_init", [], jVoid)
@@ -156,7 +156,7 @@
         if self.delegate_impl:
             gen.new_with_jtype(self.delegate_impl)
         else:
-            gen.push_null(jObject)
+            gen.push_null(jvm.jObject)
 
     def initialize_data(self, constgen, gen):
         return

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/database.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/database.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/database.py	Sun Mar  2 18:48:48 2008
@@ -7,21 +7,15 @@
 from pypy.rpython.lltypesystem import lltype
 from pypy.rpython.ootypesystem import ootype, rclass
 from pypy.rpython.ootypesystem.module import ll_os
-from pypy.translator.jvm import typesystem as jvmtype
 from pypy.translator.jvm import node, methods
 from pypy.translator.jvm.option import getoption
-import pypy.translator.jvm.generator as jvmgen
-from pypy.translator.jvm.generator import Method, Property, Field
-import pypy.translator.jvm.constant as jvmconst
-from pypy.translator.jvm.typesystem import \
-     jStringBuilder, jInt, jVoid, jString, jChar, jObject, \
-     jThrowable, JvmNativeClass, jPyPy, JvmClassType
 from pypy.translator.jvm.builtin import JvmBuiltInType
-
 from pypy.translator.oosupport.database import Database as OODatabase
 from pypy.rpython.ootypesystem.bltregistry import ExternalType
 from pypy.annotation.signature import annotation
 from pypy.annotation.model import annotation_to_lltype
+import pypy.translator.jvm.constant as jvmconst
+import pypy.translator.jvm.typesystem as jvm
 
 # ______________________________________________________________________
 # Database object
@@ -34,7 +28,7 @@
         self._jasmin_files = [] # list of strings --- .j files we made
         self._classes = {} # Maps ootype class objects to node.Class objects,
                            # and JvmType objects as well
-        self._functions = {}      # graph -> jvmgen.Method
+        self._functions = {}      # graph -> jvm.Method
 
         # (jargtypes, jrettype) -> node.StaticMethodInterface
         self._delegates = {}
@@ -44,7 +38,7 @@
 
         self._function_names = {} # graph --> function_name
 
-        self._constants = {}      # flowmodel.Variable --> jvmgen.Const
+        self._constants = {}      # flowmodel.Variable --> jvm.Const
 
         # Special fields for the Object class, see _translate_Object
         self._object_interf = None
@@ -60,8 +54,8 @@
         #
         #    These are public attributes that are referenced from
         #    elsewhere in the code.
-        self.jPyPyMain = JvmClassType(self._pkg('Main'))
-        self.pypy_field = jvmgen.Field.s(self.jPyPyMain, 'pypy', jPyPy)
+        self.jPyPyMain = jvm.JvmClassType(self._pkg('Main'))
+        self.pypy_field = jvm.Field.s(self.jPyPyMain, 'pypy', jvm.jPyPy)
 
     # _________________________________________________________________
     # Java String vs Byte Array
@@ -85,7 +79,7 @@
 
     def class_name(self, TYPE):
         jtype = self.lltype_to_cts(TYPE)
-        assert isinstance(jtype, jvmtype.JvmClassType)
+        assert isinstance(jtype, jvm.JvmClassType)
         return jtype.name
 
     def add_jasmin_file(self, jfile):
@@ -112,14 +106,14 @@
         like.
 
         The 'methods' argument should be a dictionary whose keys are
-        method names and whose entries are jvmgen.Method objects which
+        method names and whose entries are jvm.Method objects which
         the corresponding method should invoke. """
 
         nm = self._pkg(self._uniq('InterlinkImplementation'))
-        cls = node.Class(nm, supercls=jObject)
+        cls = node.Class(nm, supercls=jvm.jObject)
         for method_name, helper in methods.items():
             cls.add_method(node.InterlinkFunction(cls, method_name, helper))
-        cls.add_interface(jvmtype.jPyPyInterlink)
+        cls.add_interface(jvm.jPyPyInterlink)
         self.jInterlinkImplementation = cls
         self.pending_node(cls)
 
@@ -161,7 +155,7 @@
 
         # Create the class object first
         clsnm = self._pkg(self._uniq('Record'))
-        clsobj = node.Class(clsnm, jObject)
+        clsobj = node.Class(clsnm, jvm.jObject)
         self._classes[OOTYPE] = clsobj
 
         # Add fields:
@@ -197,8 +191,8 @@
         def gen_name(): return self._pkg(self._uniq(OBJ._name))
         internm, implnm, exc_implnm = gen_name(), gen_name(), gen_name()
         self._object_interf = node.Interface(internm)
-        self._object_impl = node.Class(implnm, supercls=jObject)
-        self._object_exc_impl = node.Class(exc_implnm, supercls=jThrowable)
+        self._object_impl = node.Class(implnm, supercls=jvm.jObject)
+        self._object_exc_impl = node.Class(exc_implnm, supercls=jvm.jThrowable)
         self._object_impl.add_interface(self._object_interf)
         self._object_exc_impl.add_interface(self._object_interf)
 
@@ -212,12 +206,12 @@
             methodnm = "_jvm_"+fieldnm
 
             def getter_method_obj(node):
-                return Method.v(node, methodnm+"_g", [], fieldty)
+                return jvm.Method.v(node, methodnm+"_g", [], fieldty)
             def putter_method_obj(node):
-                return Method.v(node, methodnm+"_p", [fieldty], jVoid)
+                return jvm.Method.v(node, methodnm+"_p", [fieldty], jvm.jVoid)
             
             # Add get/put methods to the interface:
-            prop = Property(
+            prop = jvm.Property(
                 fieldnm, 
                 getter_method_obj(self._object_interf),
                 putter_method_obj(self._object_interf),
@@ -227,7 +221,7 @@
             # Generate implementations:
             def generate_impl(clsobj):
                 clsnm = clsobj.name
-                fieldobj = Field(clsnm, fieldnm, fieldty, False, FIELDOOTY)
+                fieldobj = jvm.Field(clsnm, fieldnm, fieldty, False, FIELDOOTY)
                 clsobj.add_field(fieldobj, fielddef)
                 clsobj.add_method(node.GetterFunction(
                     self, clsobj, getter_method_obj(clsobj), fieldobj))
@@ -288,7 +282,7 @@
                 arglist = [self.lltype_to_cts(ARG) for ARG in METH.ARGS
                            if ARG is not ootype.Void]
                 returntype = self.lltype_to_cts(METH.RESULT)
-                clsobj.add_abstract_method(jvmgen.Method.v(
+                clsobj.add_abstract_method(jvm.Method.v(
                     clsobj, mname, arglist, returntype))
             else:
                 # if the first argument's type is not a supertype of
@@ -315,7 +309,7 @@
             if FIELDOOTY is ootype.Void: continue
             fieldty = self.lltype_to_cts(FIELDOOTY)
             clsobj.add_field(
-                jvmgen.Field(clsobj.name, fieldnm, fieldty, False, FIELDOOTY),
+                jvm.Field(clsobj.name, fieldnm, fieldty, False, FIELDOOTY),
                 fielddef)
 
     def pending_class(self, OOTYPE):
@@ -326,7 +320,7 @@
         This is invoked when a standalone function is to be compiled.
         It creates a class named after the function with a single
         method, invoke().  This class is added to the worklist.
-        Returns a jvmgen.Method object that allows this function to be
+        Returns a jvm.Method object that allows this function to be
         invoked.
         """
         if graph in self._functions:
@@ -358,7 +352,7 @@
         """
         Like record_delegate, but the signature is in terms of java
         types.  jargs is a list of JvmTypes, one for each argument,
-        and jret is a JvmType.  Note that jargs does NOT include an
+        and jret is a Jvm.  Note that jargs does NOT include an
         entry for the this pointer of the resulting object.  
         """
         key = (jargs, jret)
@@ -416,17 +410,17 @@
     # any type.
     
     _toString_methods = {
-        ootype.Signed:jvmgen.INTTOSTRINGI,
-        ootype.Unsigned:jvmgen.PYPYSERIALIZEUINT,
-        ootype.SignedLongLong:jvmgen.LONGTOSTRINGL,
-        ootype.UnsignedLongLong: jvmgen.PYPYSERIALIZEULONG,
-        ootype.Float:jvmgen.DOUBLETOSTRINGD,
-        ootype.Bool:jvmgen.PYPYSERIALIZEBOOLEAN,
-        ootype.Void:jvmgen.PYPYSERIALIZEVOID,
-        ootype.Char:jvmgen.PYPYESCAPEDCHAR,
-        ootype.UniChar:jvmgen.PYPYESCAPEDUNICHAR,
-        ootype.String:jvmgen.PYPYESCAPEDSTRING,
-        ootype.Unicode:jvmgen.PYPYESCAPEDUNICODE,
+        ootype.Signed:jvm.INTTOSTRINGI,
+        ootype.Unsigned:jvm.PYPYSERIALIZEUINT,
+        ootype.SignedLongLong:jvm.LONGTOSTRINGL,
+        ootype.UnsignedLongLong: jvm.PYPYSERIALIZEULONG,
+        ootype.Float:jvm.DOUBLETOSTRINGD,
+        ootype.Bool:jvm.PYPYSERIALIZEBOOLEAN,
+        ootype.Void:jvm.PYPYSERIALIZEVOID,
+        ootype.Char:jvm.PYPYESCAPEDCHAR,
+        ootype.UniChar:jvm.PYPYESCAPEDUNICHAR,
+        ootype.String:jvm.PYPYESCAPEDSTRING,
+        ootype.Unicode:jvm.PYPYESCAPEDUNICODE,
         }
 
     def toString_method_for_ootype(self, OOTYPE):
@@ -443,7 +437,7 @@
 
         to print the value of 'var'.
         """
-        return self._toString_methods.get(OOTYPE, jvmgen.PYPYSERIALIZEOBJECT)
+        return self._toString_methods.get(OOTYPE, jvm.PYPYSERIALIZEOBJECT)
 
     # _________________________________________________________________
     # Type translation functions
@@ -463,46 +457,52 @@
     # Dictionary for scalar types; in this case, if we see the key, we
     # will return the value
     ootype_to_scalar = {
-        ootype.Void:             jvmtype.jVoid,
-        ootype.Signed:           jvmtype.jInt,
-        ootype.Unsigned:         jvmtype.jInt,
-        ootype.SignedLongLong:   jvmtype.jLong,
-        ootype.UnsignedLongLong: jvmtype.jLong,
-        ootype.Bool:             jvmtype.jBool,
-        ootype.Float:            jvmtype.jDouble,
-        ootype.Char:             jvmtype.jChar,    # byte would be sufficient, but harder
-        ootype.UniChar:          jvmtype.jChar,
-        ootype.Class:            jvmtype.jClass,
-        ootype.ROOT:             jvmtype.jObject,  # treat like a scalar
+        ootype.Void:             jvm.jVoid,
+        ootype.Signed:           jvm.jInt,
+        ootype.Unsigned:         jvm.jInt,
+        ootype.SignedLongLong:   jvm.jLong,
+        ootype.UnsignedLongLong: jvm.jLong,
+        ootype.Bool:             jvm.jBool,
+        ootype.Float:            jvm.jDouble,
+        ootype.Char:             jvm.jChar,    # byte would be sufficient, but harder
+        ootype.UniChar:          jvm.jChar,
+        ootype.Class:            jvm.jClass,
+        ootype.ROOT:             jvm.jObject,  # treat like a scalar
     }
 
     # Dictionary for non-scalar types; in this case, if we see the key, we
     # will return a JvmBuiltInType based on the value
     ootype_to_builtin = {
-        ootype.String:           jvmtype.jString,
-        ootype.Unicode:          jvmtype.jString,
-        ootype.StringBuilder:    jvmtype.jStringBuilder,
-        ootype.UnicodeBuilder:   jvmtype.jStringBuilder,
-        ootype.List:             jvmtype.jArrayList,
-        ootype.Dict:             jvmtype.jHashMap,
-        ootype.DictItemsIterator:jvmtype.jPyPyDictItemsIterator,
-        ootype.CustomDict:       jvmtype.jPyPyCustomDict,
-        ootype.WeakReference:    jvmtype.jPyPyWeakRef,
-        ll_os.STAT_RESULT:       jvmtype.jPyPyStatResult,
+        ootype.String:           jvm.jString,
+        ootype.Unicode:          jvm.jString,
+        ootype.StringBuilder:    jvm.jStringBuilder,
+        ootype.UnicodeBuilder:   jvm.jStringBuilder,
+        ootype.List:             jvm.jArrayList,
+        ootype.Dict:             jvm.jHashMap,
+        ootype.DictItemsIterator:jvm.jPyPyDictItemsIterator,
+        ootype.CustomDict:       jvm.jPyPyCustomDict,
+        ootype.WeakReference:    jvm.jPyPyWeakRef,
+        ll_os.STAT_RESULT:       jvm.jPyPyStatResult,
 
         # These are some configured records that are generated by Java
         # code.  
         #ootype.Record({"item0": ootype.Signed, "item1": ootype.Signed}):
-        #jvmtype.jPyPyRecordSignedSigned,
+        #jvm.jPyPyRecordSignedSigned,
         #ootype.Record({"item0": ootype.Float, "item1": ootype.Signed}):
-        #jvmtype.jPyPyRecordFloatSigned,
+        #jvm.jPyPyRecordFloatSigned,
         #ootype.Record({"item0": ootype.Float, "item1": ootype.Float}):
-        #jvmtype.jPyPyRecordFloatFloat,
+        #jvm.jPyPyRecordFloatFloat,
         #ootype.Record({"item0": ootype.String, "item1": ootype.String}):
-        #jvmtype.jPyPyRecordStringString,        
+        #jvm.jPyPyRecordStringString,        
         }
 
     def lltype_to_cts(self, OOT):
+        import sys
+        res = self._lltype_to_cts(OOT)
+        print >> sys.stderr, "lltype_to_cts(%r) -> %r" % (OOT, res)
+        return res
+
+    def _lltype_to_cts(self, OOT):
         """ Returns an instance of JvmType corresponding to
         the given OOType """
 
@@ -510,7 +510,7 @@
         if OOT in self.ootype_to_scalar:
             return self.ootype_to_scalar[OOT]
         if isinstance(OOT, lltype.Ptr) and isinstance(t.TO, lltype.OpaqueType):
-            return jObject
+            return jvm.jObject
         if OOT in self.ootype_to_builtin:
             return JvmBuiltInType(self, self.ootype_to_builtin[OOT], OOT)
         if isinstance(OOT, ootype.Array):
@@ -536,19 +536,19 @@
         assert False, "Untranslatable type %s!" % OOT
 
     ooitemtype_to_array = {
-        ootype.Signed   : jvmtype.jIntArray,
-        ootype.Unsigned : jvmtype.jIntArray,
-        ootype.Char     : jvmtype.jCharArray,
-        ootype.Bool     : jvmtype.jByteArray,
-        ootype.UniChar  : jvmtype.jCharArray,
-        ootype.String   : jvmtype.jStringArray,
-        ootype.Void     : jvmtype.jVoidArray,
+        ootype.Signed   : jvm.jIntArray,
+        ootype.Unsigned : jvm.jIntArray,
+        ootype.Char     : jvm.jCharArray,
+        ootype.Bool     : jvm.jByteArray,
+        ootype.UniChar  : jvm.jCharArray,
+        ootype.String   : jvm.jStringArray,
+        ootype.Void     : jvm.jVoidArray,
     }
 
     def _array_type(self, ITEM):
         if ITEM in self.ooitemtype_to_array:
             return self.ooitemtype_to_array[ITEM]
-        return jvmtype.jObjectArray
+        return jvm.jObjectArray
 
     def annotation_to_cts(self, _tp):
         s_tp = annotation(_tp)

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/generator.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/generator.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/generator.py	Sun Mar  2 18:48:48 2008
@@ -12,261 +12,11 @@
 from pypy.rlib.objectmodel import CDefinedIntSymbolic
 from pypy.rlib.rarithmetic import isnan, isinf
 from pypy.translator.oosupport.constant import push_constant
-import pypy.translator.jvm.typesystem as jvmtype
-from pypy.translator.jvm.typesystem import \
-     JvmType, jString, jInt, jLong, jDouble, jBool, jString, \
-     jPyPy, jVoid, jMath, desc_for_method, jPrintStream, jClass, jChar, \
-     jObject, jByteArray, jPyPyExcWrap, jIntegerClass, jLongClass, \
-     jDoubleClass, jCharClass, jStringBuilder, JvmScalarType, jArrayList, \
-     jObjectArray, jPyPyInterlink, jPyPyCustomDict, jPyPyEquals, \
-     jPyPyHashCode, jMap, jPyPyWeakRef, jSystem, jll_os, jPyPyInterlink, \
-     jVoidArray
-
-
-# ___________________________________________________________________________
-# JVM Opcodes:
-#
-#   Map from symbolic name to an instance of the Opcode class
-
-class Opcode(object):
-    def __init__(self, jvmstr):
-        """
-        flags is a set of flags (see above) that describe opcode #UPDATE
-        jvmstr is the name for jasmin printouts
-        """
-        self.jvmstr = jvmstr
-        self.flags = None #Should flags be added to args?
-
-    def __repr__(self):
-        return "<Opcode %s:%x>" % (self.jvmstr, self.flags)
-
-    def specialize(self, args):
-        """ Process the argument list according to the various flags.
-        Returns a tuple (OPCODE, ARGS) where OPCODE is a string representing
-        the new opcode, and ARGS is a list of arguments or empty tuple.
-        Most of these do not do anything. """
-        return (self.jvmstr, args)
-
-class IntConstOpcode(Opcode):
-    """ The ICONST opcode specializes itself for small integer opcodes. """
-    def specialize(self, args):
-        assert len(args) == 1
-        if args[0] == -1:
-            return self.jvmstr + "_m1", ()
-        elif args[0] >= 0 and args[0] <= 5:
-            return self.jvmstr + "_" + str(args[0]), ()
-        # Non obvious: convert ICONST to LDC if the constant is out of
-        # range
-        return "ldc", args
-
-class VarOpcode(Opcode):
-    """ An Opcode which takes a variable index as an argument; specialized
-    to small integer indices. """
-    def specialize(self, args):
-        assert len(args) == 1
-        if args[0] >= 0 and args[0] <= 3:
-            return self.jvmstr + "_" + str(args[0]), ()
-        return Opcode.specialize(self, args)
-
-class IntClassNameOpcode(Opcode):
-    """ An opcode which takes an internal class name as its argument;
-    the actual argument will be a JvmType instance. """
-    def specialize(self, args):
-        args = [args[0].descriptor.int_class_name()]
-        return self.jvmstr, args
-        
-class OpcodeFamily(object):
-    """
-    Many opcodes in JVM have variants that depend on the type of the
-    operands; for example, one must choose the correct ALOAD, ILOAD,
-    or DLOAD depending on whether one is loading a reference, integer,
-    or double variable respectively.  Each instance of this class
-    defines one 'family' of opcodes, such as the LOAD family shown
-    above, and produces Opcode objects specific to a particular type.
-    """
-    def __init__(self, opcclass, suffix):
-        """
-        opcclass is the opcode subclass to use (see above) when
-        instantiating a particular opcode
-        
-        jvmstr is the name for jasmin printouts
-        """
-        self.opcode_class = opcclass
-        self.suffix = suffix
-        self.cache = {}
+import pypy.translator.jvm.typesystem as jvm
 
-    def _o(self, prefix):
-        try:
-            return self.cache[prefix]
-        except KeyError:
-            self.cache[prefix] = obj = self.opcode_class(
-                prefix+self.suffix)
-            return obj
-        
-    def for_type(self, argtype):
-        """ Returns a customized opcode of this family appropriate to
-        'argtype', a JvmType object. """
-
-        desc = argtype.descriptor
-
-        # These are always true:
-        if desc[0] == 'L': return self._o("a")   # Objects
-        if desc[0] == '[': return self._o("a")   # Arrays
-        if desc == 'I':    return self._o("i")   # Integers
-        if desc == 'J':    return self._o("l")   # Integers
-        if desc == 'D':    return self._o("d")   # Doubles
-        if desc == 'V':    return self._o("")    # Void [used by RETURN]
-
-        # Chars/Bytes/Booleans are normally represented as ints
-        # in the JVM, but some opcodes are different.  They use a
-        # different OpcodeFamily (see ArrayOpcodeFamily for ex)
-        if desc == 'C':    return self._o("i")   # Characters
-        if desc == 'B':    return self._o("i")   # Bytes
-        if desc == 'Z':    return self._o("i")   # Boolean
-
-        assert False, "Unknown argtype=%s" % repr(argtype)
-        raise NotImplementedError
-
-class ArrayOpcodeFamily(OpcodeFamily):
-    """ Opcode family specialized for array access instr """
-    def for_type(self, argtype):
-        desc = argtype.descriptor
-        if desc == 'J':    return self._o("l")   # Integers
-        if desc == 'D':    return self._o("d")   # Doubles
-        if desc == 'C':    return self._o("c")   # Characters
-        if desc == 'B':    return self._o("b")   # Bytes
-        if desc == 'Z':    return self._o("b")   # Boolean (access as bytes)
-        return OpcodeFamily.for_type(self, argtype)
-
-class NewArrayOpcodeFamily(object):
-    def __init__(self):
-        # a void array is just an int, therefore oonewarray does not need to
-        # do anything, because it the new can just use the int argument that is
-        # already on the stack
-        self.cache = {jVoidArray: None}
-
-    def for_type(self, arraytype):
-        try:
-            return self.cache[arraytype]
-        except KeyError:
-            pass
-        desc = arraytype.descriptor
-        if desc == '[I':
-            s = "newarray int"
-        elif desc == '[D':
-            s = "newarray double"
-        elif desc == '[C':
-            s = "newarray char"
-        elif desc == '[B':
-            s = "newarray byte"
-        else:
-            s = "anewarray " + arraytype.element_type.descriptor.int_class_name()
-        self.cache[arraytype] = obj = Opcode(s)
-        return obj
-
-NEWARRAY = NewArrayOpcodeFamily()
-ARRAYLENGTH = Opcode("arraylength")
-
-# Define the opcodes for IFNE, IFEQ, IFLT, IF_ICMPLT, etc.  The IFxx
-# variants compare a single integer arg against 0, and the IF_ICMPxx
-# variants compare 2 integer arguments against each other.
-for cmpop in ('ne', 'eq', 'lt', 'gt', 'le', 'ge'):
-    ifop = "if%s" % cmpop
-    if_icmpop = "if_icmp%s" % cmpop
-    globals()[ifop.upper()] = Opcode(ifop)
-    globals()[if_icmpop.upper()] = Opcode(if_icmpop)
-
-# Compare references, either against NULL or against each other
-IFNULL =    Opcode('ifnull')
-IFNONNULL = Opcode('ifnonnull')
-IF_ACMPEQ = Opcode('if_acmpeq')
-IF_ACMPNE = Opcode('if_acmpne')
-
-# Method invocation
-INVOKESTATIC = Opcode('invokestatic')
-INVOKEVIRTUAL = Opcode('invokevirtual')
-INVOKESPECIAL = Opcode('invokespecial')
-INVOKEINTERFACE = Opcode('invokeinterface')
-
-# Other opcodes
-LDC =       Opcode('ldc')       # single-word types
-LDC2 =      Opcode('ldc2_w')    # double-word types: doubles and longs
-GOTO =      Opcode('goto')
-ICONST =    IntConstOpcode('iconst')
-ICONST_0 =  Opcode('iconst_0')  # sometimes convenient to refer to this directly
-ACONST_NULL=Opcode('aconst_null')
-DCONST_0 =  Opcode('dconst_0')
-DCONST_1 =  Opcode('dconst_1')
-LCONST_0 =  Opcode('lconst_0')
-LCONST_1 =  Opcode('lconst_1')
-GETFIELD =  Opcode('getfield')
-PUTFIELD =  Opcode('putfield')
-GETSTATIC = Opcode('getstatic')
-PUTSTATIC = Opcode('putstatic')
-CHECKCAST = IntClassNameOpcode('checkcast')
-INEG =      Opcode('ineg')
-IXOR =      Opcode('ixor')
-IADD =      Opcode('iadd')
-ISUB =      Opcode('isub')
-IMUL =      Opcode('imul')
-IDIV =      Opcode('idiv')
-IREM =      Opcode('irem')
-IAND =      Opcode('iand')
-IOR =       Opcode('ior')
-ISHL =      Opcode('ishl')
-ISHR =      Opcode('ishr')
-IUSHR =     Opcode('iushr')
-LCMP =      Opcode('lcmp')
-DCMPG =     Opcode('dcmpg')
-DCMPL =     Opcode('dcmpl')
-NOP =       Opcode('nop')
-I2D =       Opcode('i2d')
-I2L =       Opcode('i2l')
-D2I=        Opcode('d2i')
-#D2L=        Opcode('d2l') #PAUL
-L2I =       Opcode('l2i')
-L2D =       Opcode('l2d')
-ATHROW =    Opcode('athrow')
-DNEG =      Opcode('dneg')
-DADD =      Opcode('dadd')
-DSUB =      Opcode('dsub')
-DMUL =      Opcode('dmul')
-DDIV =      Opcode('ddiv')
-DREM =      Opcode('drem')
-LNEG =      Opcode('lneg')
-LADD =      Opcode('ladd')
-LSUB =      Opcode('lsub')
-LMUL =      Opcode('lmul')
-LDIV =      Opcode('ldiv')
-LREM =      Opcode('lrem')
-LAND =      Opcode('land')
-LOR =       Opcode('lor')
-LXOR =      Opcode('lxor')
-LSHL =      Opcode('lshl')
-LSHR =      Opcode('lshr')
-LUSHR =     Opcode('lushr')
-NEW =       IntClassNameOpcode('new')
-DUP =       Opcode('dup')
-DUP2 =      Opcode('dup2')
-DUP_X1 =    Opcode('dup_x1')
-POP =       Opcode('pop')
-POP2 =      Opcode('pop2')
-SWAP =      Opcode('swap')
-INSTANCEOF= IntClassNameOpcode('instanceof')
-# Loading/storing local variables
-LOAD =      OpcodeFamily(VarOpcode, "load")
-STORE =     OpcodeFamily(VarOpcode, "store")
-RETURN =    OpcodeFamily(Opcode, "return")
-
-# Loading/storing from arrays
-#   *NOTE*: This family is characterized by the type of the ELEMENT,
-#   not the type of the ARRAY.  
-#   
-#   Also: here I break from convention by naming the objects ARRLOAD
-#   rather than ALOAD, even though the suffix is 'aload'.  This is to
-#   avoid confusion with the ALOAD opcode.
-ARRLOAD =      ArrayOpcodeFamily(Opcode, "aload")
-ARRSTORE =     ArrayOpcodeFamily(Opcode, "astore")
+# Load a few commonly used names, but prefer to use 'jvm.Name'
+from pypy.translator.jvm.typesystem import \
+     jPyPy, jString, jInt, jVoid
 
 # ___________________________________________________________________________
 # Labels
@@ -287,310 +37,6 @@
         return self.label
     
 # ___________________________________________________________________________
-# Methods
-#
-# "Method" objects describe all the information needed to invoke a
-# method.  We create one for each node.Function object, as well as for
-# various helper methods (defined below).  To invoke a method, you
-# push its arguments and then use generator.emit(methobj) where
-# methobj is its Method instance.
-
-class Method(object):
-
-    # Create a constructor:
-    def c(classty, argtypes):
-        return Method(classty.name, "<init>", argtypes, jVoid,
-                      opcode=INVOKESPECIAL)
-    c = staticmethod(c)
-
-    # Create a virtual or interface method:
-    def v(classty, methnm, argtypes, rettype):
-        """
-        Shorthand to create a virtual method.
-        'class' - JvmType object for the class
-        'methnm' - name of the method (Python string)
-        'argtypes' - list of JvmType objects, one for each argument but
-        not the this ptr
-        'rettype' - JvmType for return type
-        """
-        assert argtypes is not None
-        assert rettype is not None
-        classnm = classty.name
-        if isinstance(classty, jvmtype.JvmInterfaceType):
-            opc = INVOKEINTERFACE
-        else:
-            assert isinstance(classty, jvmtype.JvmClassType)
-            opc = INVOKEVIRTUAL
-        return Method(classnm, methnm, argtypes, rettype, opcode=opc)
-    v = staticmethod(v)
-
-    # Create a static method:
-    def s(classty, methnm, argtypes, rettype):
-        """
-        Shorthand to create a static method.
-        'class' - JvmType object for the class
-        'methnm' - name of the method (Python string)
-        'argtypes' - list of JvmType objects, one for each argument but
-        not the this ptr
-        'rettype' - JvmType for return type
-        """
-        assert isinstance(classty, JvmType)
-        classnm = classty.name
-        return Method(classnm, methnm, argtypes, rettype)
-    s = staticmethod(s)
-    
-    def __init__(self, classnm, methnm, argtypes, rettype, opcode=INVOKESTATIC):
-        self.opcode = opcode
-        self.class_name = classnm  # String, ie. "java.lang.Math"
-        self.method_name = methnm  # String "abs"
-        self.argument_types = argtypes # List of jvmtypes
-        self.return_type = rettype     # jvmtype
-
-        # Compute the method descriptior, which is a string like "()I":
-        argtypesdesc = [a.descriptor for a in argtypes]
-        rettypedesc = rettype.descriptor
-        self.descriptor = desc_for_method(argtypesdesc, rettypedesc)  
-    def invoke(self, gen):
-        gen._instr(self.opcode, self)        
-    def is_static(self):
-        return self.opcode == INVOKESTATIC
-    def jasmin_syntax(self):
-        res = "%s/%s%s" % (self.class_name.replace('.','/'),
-                           self.method_name,
-                           self.descriptor)
-        # A weird, inexplicable quirk of Jasmin syntax is that it requires
-        # the number of arguments after an invokeinterface call:
-        if self.opcode == INVOKEINTERFACE:
-            res += " %d" % (len(self.argument_types)+1,)
-        return res
-
-OBJHASHCODE =           Method.v(jObject, 'hashCode', (), jInt)
-OBJTOSTRING =           Method.v(jObject, 'toString', (), jString)
-OBJEQUALS =             Method.v(jObject, 'equals', (jObject,), jBool)
-SYSTEMGC =              Method.s(jSystem, 'gc', (), jVoid)
-INTTOSTRINGI =          Method.s(jIntegerClass, 'toString', (jInt,), jString)
-LONGTOSTRINGL =         Method.s(jLongClass, 'toString', (jLong,), jString)
-DOUBLETOSTRINGD =       Method.s(jDoubleClass, 'toString', (jDouble,), jString)
-CHARTOSTRINGC =         Method.s(jCharClass, 'toString', (jChar,), jString)
-MATHIABS =              Method.s(jMath, 'abs', (jInt,), jInt)
-IABSOVF =               Method.v(jPyPy, 'abs_ovf', (jInt,), jInt)
-MATHLABS =              Method.s(jMath, 'abs', (jLong,), jLong)
-LABSOVF =               Method.v(jPyPy, 'abs_ovf', (jLong,), jLong)
-MATHDABS =              Method.s(jMath, 'abs', (jDouble,), jDouble)
-INEGOVF =               Method.v(jPyPy, 'negate_ovf', (jInt,), jInt)
-LNEGOVF =               Method.v(jPyPy, 'negate_ovf', (jLong,), jLong)
-IADDOVF =               Method.v(jPyPy, 'add_ovf', (jInt, jInt), jInt)
-LADDOVF =               Method.v(jPyPy, 'add_ovf', (jLong, jLong), jLong)
-ISUBOVF =               Method.v(jPyPy, 'subtract_ovf', (jInt, jInt), jInt)
-LSUBOVF =               Method.v(jPyPy, 'subtract_ovf', (jLong, jLong), jLong)
-IMULOVF =               Method.v(jPyPy, 'multiply_ovf', (jInt, jInt), jInt)
-LMULOVF =               Method.v(jPyPy, 'multiply_ovf', (jLong, jLong), jLong)
-MATHFLOOR =             Method.s(jMath, 'floor', (jDouble,), jDouble)
-IFLOORDIVOVF =          Method.v(jPyPy, 'floordiv_ovf', (jInt, jInt), jInt)
-LFLOORDIVOVF =          Method.v(jPyPy, 'floordiv_ovf', (jLong, jLong), jLong)
-IFLOORDIVZEROVF =       Method.v(jPyPy, 'floordiv_zer_ovf', (jInt, jInt), jInt)
-LFLOORDIVZEROVF =       Method.v(jPyPy, 'floordiv_zer_ovf', (jLong, jLong), jLong)
-IREMOVF =               Method.v(jPyPy, 'mod_ovf', (jInt, jInt), jInt)
-LREMOVF =               Method.v(jPyPy, 'mod_ovf', (jLong, jLong), jLong)
-ISHLOVF =               Method.v(jPyPy, 'lshift_ovf', (jInt, jInt), jInt)
-LSHLOVF =               Method.v(jPyPy, 'lshift_ovf', (jLong, jLong), jLong)
-MATHDPOW =              Method.s(jMath, 'pow', (jDouble, jDouble), jDouble)
-PRINTSTREAMPRINTSTR =   Method.v(jPrintStream, 'print', (jString,), jVoid)
-CLASSFORNAME =          Method.s(jClass, 'forName', (jString,), jClass)
-CLASSISASSIGNABLEFROM = Method.v(jClass, 'isAssignableFrom', (jClass,), jBool)
-STRINGBUILDERAPPEND =   Method.v(jStringBuilder, 'append',
-                                 (jString,), jStringBuilder)
-PYPYUINTCMP =           Method.s(jPyPy, 'uint_cmp', (jInt,jInt,), jInt)
-PYPYULONGCMP =          Method.s(jPyPy, 'ulong_cmp', (jLong,jLong), jInt)
-PYPYUINTMOD =           Method.v(jPyPy, 'uint_mod', (jInt, jInt), jInt)
-PYPYUINTMUL =           Method.v(jPyPy, 'uint_mul', (jInt, jInt), jInt)
-PYPYUINTDIV =           Method.v(jPyPy, 'uint_div', (jInt, jInt), jInt)
-PYPYULONGMOD =          Method.v(jPyPy, 'ulong_mod', (jLong, jLong), jLong)
-PYPYUINTTODOUBLE =      Method.s(jPyPy, 'uint_to_double', (jInt,), jDouble)
-PYPYDOUBLETOUINT =      Method.s(jPyPy, 'double_to_uint', (jDouble,), jInt)
-PYPYDOUBLETOLONG =      Method.v(jPyPy, 'double_to_long', (jDouble,), jLong) #PAUL
-PYPYLONGBITWISENEGATE = Method.v(jPyPy, 'long_bitwise_negate', (jLong,), jLong)
-PYPYSTRTOINT =          Method.v(jPyPy, 'str_to_int', (jString,), jInt)
-PYPYSTRTOUINT =         Method.v(jPyPy, 'str_to_uint', (jString,), jInt)
-PYPYSTRTOLONG =         Method.v(jPyPy, 'str_to_long', (jString,), jLong)
-PYPYSTRTOULONG =        Method.v(jPyPy, 'str_to_ulong', (jString,), jLong)
-PYPYSTRTOBOOL =         Method.v(jPyPy, 'str_to_bool', (jString,), jBool)
-PYPYSTRTODOUBLE =       Method.v(jPyPy, 'str_to_double', (jString,), jDouble)
-PYPYSTRTOCHAR =         Method.v(jPyPy, 'str_to_char', (jString,), jChar)
-PYPYBOOLTODOUBLE =      Method.v(jPyPy, 'bool_to_double', (jBool,), jDouble)
-PYPYDUMP          =     Method.s(jPyPy, 'dump', (jString,), jVoid)
-PYPYDUMPEXCWRAPPER =    Method.s(jPyPy, 'dump_exc_wrapper', (jObject,), jVoid)
-PYPYSERIALIZEBOOLEAN =  Method.s(jPyPy, 'serialize_boolean', (jBool,), jString)
-PYPYSERIALIZEUINT  =    Method.s(jPyPy, 'serialize_uint', (jInt,), jString)
-PYPYSERIALIZEULONG =    Method.s(jPyPy, 'serialize_ulonglong', (jLong,),jString)
-PYPYSERIALIZEVOID =     Method.s(jPyPy, 'serialize_void', (), jString)
-PYPYESCAPEDCHAR =       Method.s(jPyPy, 'escaped_char', (jChar,), jString)
-PYPYESCAPEDUNICHAR =    Method.s(jPyPy, 'escaped_unichar', (jChar,), jString)
-PYPYESCAPEDSTRING =     Method.s(jPyPy, 'escaped_string', (jString,), jString)
-PYPYESCAPEDUNICODE =    Method.s(jPyPy, 'escaped_unicode', (jString,), jString)
-PYPYSERIALIZEOBJECT =   Method.s(jPyPy, 'serializeObject', (jObject,), jString)
-PYPYRUNTIMENEW =        Method.s(jPyPy, 'RuntimeNew', (jClass,), jObject)
-PYPYSTRING2BYTES =      Method.s(jPyPy, 'string2bytes', (jString,), jByteArray)
-PYPYARRAYTOLIST =       Method.s(jPyPy, 'array_to_list', (jObjectArray,), jArrayList)
-PYPYOOPARSEFLOAT =      Method.v(jPyPy, 'ooparse_float', (jString,), jDouble)
-OBJECTGETCLASS =        Method.v(jObject, 'getClass', (), jClass)
-CLASSGETNAME =          Method.v(jClass, 'getName', (), jString)
-CUSTOMDICTMAKE =        Method.s(jPyPyCustomDict, 'make',
-                                 (jPyPyEquals, jPyPyHashCode), jPyPyCustomDict)
-PYPYWEAKREFCREATE =     Method.s(jPyPyWeakRef, 'create', (jObject,), jPyPyWeakRef)
-PYPYWEAKREFGET =        Method.s(jPyPyWeakRef, 'll_get', (), jObject)
-
-
-# special methods for arrays that are not really methods in the JVM
-# XXX slightly hackish
-class ArrayMethod(Method):
-    def __init__(self, arraytype, methodname):
-        self.arraytype = arraytype
-        self.ootype_methodname = methodname
-        Method.__init__(self, "<dummy>", "<dummy>", self._argtypes(), self._rettype(),
-                        opcode=None)
-
-    def _argtypes(self):
-        if self.ootype_methodname == "ll_length":
-            return []
-        elif self.ootype_methodname == "ll_getitem_fast":
-            return [jInt]
-        elif self.ootype_methodname == "ll_setitem_fast":
-            return [jInt, self.arraytype.element_type]
-        else:
-            assert 0, "unknown array method"
-
-    def _rettype(self):
-        if self.ootype_methodname == "ll_length":
-            return jInt
-        elif self.ootype_methodname == "ll_getitem_fast":
-            return self.arraytype.element_type
-        elif self.ootype_methodname == "ll_setitem_fast":
-            return jVoid
-        else:
-            assert 0, "unknown array method"
-
-    def invoke(self, gen):
-        if self.ootype_methodname == "ll_length":
-            gen._instr(ARRAYLENGTH)
-        elif self.ootype_methodname == "ll_getitem_fast":
-            gen._instr(ARRLOAD.for_type(self.arraytype.element_type))
-        elif self.ootype_methodname == "ll_setitem_fast":
-            gen._instr(ARRSTORE.for_type(self.arraytype.element_type))
-        else:
-            assert 0, "unknown array method"
-
-class VoidArrayMethod(ArrayMethod):
-    def _argtypes(self):
-        if self.ootype_methodname == "ll_length":
-            return []
-        elif self.ootype_methodname == "ll_getitem_fast":
-            return [jInt]
-        elif self.ootype_methodname == "ll_setitem_fast":
-            return [jInt]
-        else:
-            assert 0, "unknown array method"
-
-    def _rettype(self):
-        if self.ootype_methodname == "ll_length":
-            return jInt
-        return jVoid
-
-    def invoke(self, gen):
-        if self.ootype_methodname == "ll_length":
-            pass
-        elif self.ootype_methodname == "ll_getitem_fast":
-            gen.emit(POP); gen.emit(POP)
-        elif self.ootype_methodname == "ll_setitem_fast":
-            gen.emit(POP); gen.emit(POP)
-        else:
-            assert 0, "unknown array method"
-
-# ___________________________________________________________________________
-# Fields
-#
-# Field objects encode information about fields.
-
-class Field(object):
-
-    @staticmethod
-    def i(classty, fieldnm, fieldty, OOTYPE=None):
-        """
-        Shorthand to create an instance field.
-        'class' - JvmType object for the class containing the field
-        'fieldnm' - name of the field (Python string)
-        'fieldty' - JvmType object for the type of the field
-        'OOTYPE' - optional OOTYPE object for the type of the field
-        """
-        return Field(classty.name, fieldnm, fieldty, False, OOTYPE)
-    
-    @staticmethod
-    def s(classty, fieldnm, fieldty, OOTYPE=None):
-        """
-        Shorthand to create a static field.
-        'class' - JvmType object for the class containing the field
-        'fieldnm' - name of the field (Python string)
-        'fieldty' - JvmType object for the type of the field
-        'OOTYPE' - optional OOTYPE object for the type of the field
-        """
-        return Field(classty.name, fieldnm, fieldty, True, OOTYPE)
-
-    def __init__(self, classnm, fieldnm, jtype, static, OOTYPE=None):
-        # All fields are public
-        self.class_name = classnm  # String, ie. "java.lang.Math"
-        self.field_name = fieldnm  # String "someField"
-        self.OOTYPE = OOTYPE       # OOTYPE equivalent of JvmType, may be None
-        self.jtype = jtype         # JvmType
-        self.is_static = static    # True or False
-    def load(self, gen):
-        if self.is_static:
-            gen._instr(GETSTATIC, self)
-        else:
-            gen._instr(GETFIELD, self)
-    def store(self, gen):
-        if self.is_static:
-            gen._instr(PUTSTATIC, self)
-        else:
-            gen._instr(PUTFIELD, self)
-    def jasmin_syntax(self):
-        return "%s/%s %s" % (
-            self.class_name.replace('.','/'),
-            self.field_name,
-            self.jtype.descriptor)
-
-class Property(object):
-    """
-    An object which acts like a Field, but when a value is loaded or
-    stored it actually invokes accessor methods.
-    """
-    def __init__(self, field_name, get_method, put_method, OOTYPE=None):
-        self.get_method = get_method
-        self.put_method = put_method
-        self.field_name = field_name
-        self.OOTYPE = OOTYPE
-        
-        # Synthesize the Field attributes from the get_method/put_method:
-        self.class_name = get_method.class_name
-        assert put_method.class_name == self.class_name
-        self.jtype = get_method.return_type
-        self.is_static = get_method.is_static
-    def load(self, gen):
-        self.get_method.invoke(gen)
-    def store(self, gen):
-        self.put_method.invoke(gen)
-    # jasmin_syntax is not needed, since this object itself never appears
-    # as an argument an Opcode
-
-SYSTEMOUT =    Field.s(jSystem, 'out', jPrintStream)
-SYSTEMERR =    Field.s(jSystem, 'err', jPrintStream)
-DOUBLENAN =    Field.s(jDoubleClass, 'NaN', jDouble)
-DOUBLEPOSINF = Field.s(jDoubleClass, 'POSITIVE_INFINITY', jDouble)
-DOUBLENEGINF = Field.s(jDoubleClass, 'NEGATIVE_INFINITY', jDouble)
-
-PYPYINTERLINK= Field.i(jPyPy, 'interlink', jPyPyInterlink)
-PYPYOS =       Field.i(jPyPy, 'os', jll_os)
-
-# ___________________________________________________________________________
 # Generator State
 
 class ClassState(object):
@@ -721,8 +167,7 @@
         """
         self.begin_function("<init>", [], [self.current_type()], jVoid)
         self.load_jvm_var(self.current_type(), 0)
-        jmethod = Method(self.curclass.superclass_type.name, "<init>",
-                         (), jVoid, opcode=INVOKESPECIAL)
+        jmethod = jvm.Method.c(self.curclass.superclass_type, ())
         jmethod.invoke(self)
 
     def end_constructor(self):
@@ -796,14 +241,14 @@
 
     def return_val(self, jtype):
         """ Returns a value from top of stack of the JvmType 'jtype' """
-        self._instr(RETURN.for_type(jtype))
+        self._instr(jvm.RETURN.for_type(jtype))
 
     def load_class_name(self):
         """ Loads the name of the *Java* class of the object on the top of
         the stack as a Java string.  Note that the result for a PyPy
         generated class will look something like 'pypy.some.pkg.cls' """
-        self.emit(OBJECTGETCLASS)
-        self.emit(CLASSGETNAME)
+        self.emit(jvm.OBJECTGETCLASS)
+        self.emit(jvm.CLASSGETNAME)
 
     def load_string(self, str):
         """ Pushes a Java version of a Python string onto the stack.
@@ -820,7 +265,7 @@
                '"')
         # Use LDC to load the Java version:
         #     XXX --- support byte arrays here?  Would be trickier!
-        self._instr(LDC, res)
+        self._instr(jvm.LDC, res)
 
     def load_jvm_var(self, jvartype, varidx):
         """ Loads from jvm slot #varidx, which is expected to hold a value of
@@ -828,7 +273,7 @@
         assert varidx < self.curfunc.next_offset
         if jvartype is jVoid:
             return
-        opc = LOAD.for_type(jvartype)
+        opc = jvm.LOAD.for_type(jvartype)
         self.add_comment("     load_jvm_jar: jvartype=%s varidx=%s" % (
             repr(jvartype), repr(varidx)))
         self._instr(opc, varidx)
@@ -838,14 +283,14 @@
         type vartype """
         self.add_comment("     store_jvm_jar: vartype=%s varidx=%s" % (
             repr(vartype), repr(varidx)))
-        self._instr(STORE.for_type(vartype), varidx)
+        self._instr(jvm.STORE.for_type(vartype), varidx)
 
     def load_from_array(self, elemtype):
         """ Loads something from an array; the result will be of type 'elemtype'
         (and hence the array is of type 'array_of(elemtype)'), where
         'elemtype' is a JvmType.  Assumes that the array ref and index are
         already pushed onto stack (in that order). """
-        self._instr(ARRLOAD.for_type(elemtype))
+        self._instr(jvm.ARRLOAD.for_type(elemtype))
 
     def store_to_array(self, elemtype):
         """ Stores something into an array; the result will be of type
@@ -853,7 +298,7 @@
         'array_of(elemtype)'), where 'elemtype' is a JvmType.  Assumes
         that the array ref, index, and value are already pushed onto
         stack (in that order)."""
-        self._instr(ARRLOAD.for_type(elemtype))
+        self._instr(jvm.ARRLOAD.for_type(elemtype))
 
     def unique_label(self, desc, mark=False):
         """ Returns an opaque, unique label object that can be passed an
@@ -873,7 +318,7 @@
     def load_this_ptr(self):
         """ Convenience method.  Be sure you only call it from a
         virtual method, not static methods. """
-        self.load_jvm_var(jObject, 0)
+        self.load_jvm_var(jvm.jObject, 0)
 
     def load_function_argument(self, index):
         """ Convenience method.  Loads function argument #index; note that
@@ -886,9 +331,9 @@
         self.prepare_generic_argument_with_jtype(jty)
         
     def prepare_generic_argument_with_jtype(self, jty):
-        if jty is jvmtype.jVoid:
-            self.emit(ACONST_NULL)
-        elif isinstance(jty, JvmScalarType):
+        if jty is jVoid:
+            self.emit(jvm.ACONST_NULL)
+        elif isinstance(jty, jvm.JvmScalarType):
             self.box_value(jty)
 
     def prepare_generic_result(self, ITEMTYPE):
@@ -896,9 +341,9 @@
         self.prepare_generic_result_with_jtype(jresty)
         
     def prepare_generic_result_with_jtype(self, jresty):
-        if jresty is jvmtype.jVoid:
-            self.emit(POP)
-        elif isinstance(jresty, JvmScalarType):
+        if jresty is jVoid:
+            self.emit(jvm.POP)
+        elif isinstance(jresty, jvm.JvmScalarType):
             # Perform any un-boxing required:
             self.downcast_jtype(jresty.box_type)
             self.unbox_value(jresty)
@@ -910,20 +355,21 @@
         """ Assuming that an value of type jscalartype is on the stack,
         boxes it into an Object. """
         jclasstype = jscalartype.box_type
-        jmethod = Method.s(jclasstype, 'valueOf', (jscalartype,), jclasstype)
+        jmethod = jvm.Method.s(
+            jclasstype, 'valueOf', (jscalartype,), jclasstype)
         self.emit(jmethod)
 
     def unbox_value(self, jscalartype):
         """ Assuming that a boxed value of type jscalartype is on the stack,
         unboxes it.  """        
         jclasstype = jscalartype.box_type
-        jmethod = Method.v(
+        jmethod = jvm.Method.v(
             jclasstype, jscalartype.unbox_method, (), jscalartype)
         self.emit(jmethod)
 
     def swap(self):
         """ Swaps the two words highest on the stack. """
-        self.emit(SWAP)
+        self.emit(jvm.SWAP)
 
     # __________________________________________________________________
     # Exception Handling
@@ -976,14 +422,14 @@
 
     _equals = {
         ootype.Void:             (None,None),
-        ootype.SignedLongLong:   (LCMP,IFEQ),
-        ootype.UnsignedLongLong: (LCMP,IFEQ),
-        ootype.Float:            (DCMPG,IFEQ),
-        ootype.Signed:           (None,IF_ICMPNE),
-        ootype.Unsigned:         (None,IF_ICMPNE),
-        ootype.Bool:             (None,IF_ICMPNE),
-        ootype.Char:             (None,IF_ICMPNE),
-        ootype.UniChar:          (None,IF_ICMPNE),
+        ootype.SignedLongLong:   (jvm.LCMP,  jvm.IFEQ),
+        ootype.UnsignedLongLong: (jvm.LCMP,  jvm.IFEQ),
+        ootype.Float:            (jvm.DCMPG, jvm.IFEQ),
+        ootype.Signed:           (None,jvm.IF_ICMPNE),
+        ootype.Unsigned:         (None,jvm.IF_ICMPNE),
+        ootype.Bool:             (None,jvm.IF_ICMPNE),
+        ootype.Char:             (None,jvm.IF_ICMPNE),
+        ootype.UniChar:          (None,jvm.IF_ICMPNE),
         }
     def compare_values(self, OOTYPE, unequal_lbl):
         """ Assumes that two instances of OOTYPE are pushed on the stack;
@@ -993,14 +439,14 @@
             if i1: self.emit(i1)
             if i2: self.emit(i2, unequal_lbl)
             return
-        self.emit(OBJEQUALS)
-        self.emit(IFEQ, unequal_lbl)
+        self.emit(jvm.OBJEQUALS)
+        self.emit(jvm.IFEQ, unequal_lbl)
 
     _hash = {
-        ootype.Void:             ICONST_0,
-        ootype.SignedLongLong:   L2I,
-        ootype.UnsignedLongLong: L2I,
-        ootype.Float:            D2I,
+        ootype.Void:             jvm.ICONST_0,
+        ootype.SignedLongLong:   jvm.L2I,
+        ootype.UnsignedLongLong: jvm.L2I,
+        ootype.Float:            jvm.D2I,
         ootype.Signed:           None,
         ootype.Unsigned:         None,
         ootype.Bool:             None,
@@ -1014,7 +460,7 @@
             i1 = self._hash[OOTYPE]
             if i1: self.emit(i1)
             return
-        self.emit(OBJHASHCODE)
+        self.emit(jvm.OBJHASHCODE)
 
     # __________________________________________________________________
     # Generator methods and others that are invoked by MicroInstructions
@@ -1032,13 +478,13 @@
         if isinstance(instr, str):
             return getattr(self, instr)(*args)
 
-        if isinstance(instr, Opcode):
+        if isinstance(instr, jvm.Opcode):
             return self._instr(instr, *args)
 
-        if isinstance(instr, Method):
+        if isinstance(instr, jvm.BaseMethod):
             return instr.invoke(self)
 
-        if isinstance(instr, Field) or isinstance(instr, Property):
+        if isinstance(instr, jvm.Field) or isinstance(instr, jvm.Property):
             return instr.load(self)
 
         raise Exception("Unknown object in call to emit(): "+repr(instr))
@@ -1046,6 +492,8 @@
     def _var_data(self, v):
         # Determine java type:
         jty = self.db.lltype_to_cts(v.concretetype)
+        import sys
+        print >> sys.stderr, "_var_data(%s) -> %r" % (v.name, jty)
         # Determine index in stack frame slots:
         #   note that arguments and locals can be treated the same here
         return jty, self.curfunc.var_offset(v, jty)
@@ -1094,11 +542,11 @@
         self.downcast_jtype(jtype)
 
     def downcast_jtype(self, jtype):
-        self._instr(CHECKCAST, jtype)
+        self._instr(jvm.CHECKCAST, jtype)
         
     def instanceof(self, TYPE):
         jtype = self.db.lltype_to_cts(TYPE)
-        self._instr(INSTANCEOF, jtype)
+        self._instr(jvm.INSTANCEOF, jtype)
 
     # included for compatibility with oosupport, but instanceof_jtype
     # follows our naming convention better
@@ -1106,22 +554,22 @@
         return self.instanceof_jtype(jtype)
     
     def instanceof_jtype(self, jtype):
-        self._instr(INSTANCEOF, jtype)
+        self._instr(jvm.INSTANCEOF, jtype)
 
     def branch_unconditionally(self, target_label):
         self.goto(target_label)
 
     def branch_conditionally(self, cond, target_label):
         if cond:
-            self._instr(IFNE, target_label)
+            self._instr(jvm.IFNE, target_label)
         else:
-            self._instr(IFEQ, target_label)
+            self._instr(jvm.IFEQ, target_label)
 
     def branch_if_equal(self, target_label):
-        self._instr(IF_ICMPEQ, target_label)
+        self._instr(jvm.IF_ICMPEQ, target_label)
 
     def branch_if_not_equal(self, target_label):
-        self._instr(IF_ICMPNE, target_label)
+        self._instr(jvm.IF_ICMPNE, target_label)
 
     def call_graph(self, graph):
         mthd = self.db.pending_function(graph)
@@ -1133,7 +581,7 @@
         mthd.invoke(self)
 
         # Check if we have to convert the result type at all:
-        gener = jvmtype.Generifier(OOCLASS)
+        gener = jvm.Generifier(OOCLASS)
         RETTYPE = gener.full_types(method_name)[1]
         jrettype = self.db.lltype_to_cts(RETTYPE)
         if jrettype != mthd.return_type:
@@ -1148,7 +596,7 @@
 
         # If necessary, load the ll_os object pointer instead:
         if module == 'll_os':
-            PYPYOS.load(self)
+            jvm.PYPYOS.load(self)
         
     def call_primitive(self, op, module, name):
         callee = op.args[0].value
@@ -1157,7 +605,7 @@
 
         # Determine what class the primitive is implemented in:
         if module == 'll_os':
-            jcls = jll_os
+            jcls = jvm.jll_os
         else:
             jcls = jPyPy
 
@@ -1167,9 +615,9 @@
         #    the method cannot directly refer to the Java type in
         #    .java source, as its name is not yet known.
         if jrettype.is_generated():
-            mthd = Method.v(jcls, name, jargtypes, jObject)
+            mthd = jvm.Method.v(jcls, name, jargtypes, jvm.jObject)
         else:
-            mthd = Method.v(jcls, name, jargtypes, jrettype)
+            mthd = jvm.Method.v(jcls, name, jargtypes, jrettype)
 
         # Invoke the method
         self.emit(mthd)
@@ -1186,13 +634,13 @@
         cts_type = self.db.lltype_to_cts(OOTYPE)
 
         # treat all objects the same:
-        if isinstance(cts_type, jvmtype.JvmClassType):
-            cts_type = jObject
+        if isinstance(cts_type, jvm.JvmClassType):
+            cts_type = jvm.jObject
             
-        mthd = Method.v(jPyPy, 'oostring', [cts_type, jInt], jString)
+        mthd = jvm.Method.v(jPyPy, 'oostring', [cts_type, jInt], jString)
         self.emit(mthd)
         if self.db.using_byte_array:
-            self.emit(PYPYSTRING2BYTES)
+            self.emit(jvm.PYPYSTRING2BYTES)
 
     def prepare_call_oounicode(self, OOTYPE):
         # Load the PyPy object pointer onto the stack:
@@ -1200,10 +648,10 @@
 
     def call_oounicode(self, OOTYPE):
         cts_type = self.db.lltype_to_cts(OOTYPE)
-        mthd = Method.v(jPyPy, 'oounicode', [cts_type], jString)
+        mthd = jvm.Method.v(jPyPy, 'oounicode', [cts_type], jString)
         self.emit(mthd)
         if self.db.using_byte_array:
-            self.emit(PYPYSTRING2BYTES)
+            self.emit(jvm.PYPYSTRING2BYTES)
         
     def new(self, TYPE):
         jtype = self.db.lltype_to_cts(TYPE)
@@ -1211,43 +659,43 @@
 
     def new_with_jtype(self, jtype, ctor=None):
         if ctor is None:
-            ctor = Method.c(jtype, ())
-        self.emit(NEW, jtype)
-        self.emit(DUP)
+            ctor = jvm.Method.c(jtype, ())
+        self.emit(jvm.NEW, jtype)
+        self.emit(jvm.DUP)
         self.emit(ctor)
         
     def oonewarray(self, TYPE, length):
         jtype = self.db.lltype_to_cts(TYPE)
         self.load(length)
-        self.emit(NEWARRAY.for_type(jtype))
+        jtype.make(self)
 
     def instantiate(self):
-        self.emit(PYPYRUNTIMENEW)
+        self.emit(jvm.PYPYRUNTIMENEW)
 
     def getclassobject(self, OOINSTANCE):
-        jvmtype = self.db.lltype_to_cts(OOINSTANCE)
-        self.load_string(jvmtype.name)
-        CLASSFORNAME.invoke(self)
+        jtype = self.db.lltype_to_cts(OOINSTANCE)
+        self.load_string(jtype.name)
+        jvm.CLASSFORNAME.invoke(self)
         
     def dup(self, OOTYPE):
-        jvmtype = self.db.lltype_to_cts(OOTYPE)
-        self.dup_jtype(jvmtype)
+        jtype = self.db.lltype_to_cts(OOTYPE)
+        self.dup_jtype(jtype)
 
-    def dup_jtype(self, jvmtype):
-        if jvmtype.descriptor.type_width() == 1:
-            self.emit(DUP)
+    def dup_jtype(self, jtype):
+        if jtype.descriptor.type_width() == 1:
+            self.emit(jvm.DUP)
         else:
-            self.emit(DUP2)
+            self.emit(jvm.DUP2)
             
     def pop(self, OOTYPE):
-        jvmtype = self.db.lltype_to_cts(OOTYPE)
-        if jvmtype.descriptor.type_width() == 1:
-            self.emit(POP)
+        jtype = self.db.lltype_to_cts(OOTYPE)
+        if jtype.descriptor.type_width() == 1:
+            self.emit(jvm.POP)
         else:
-            self.emit(POP2)
+            self.emit(jvm.POP2)
 
     def push_null(self, OOTYPE):
-        self.emit(ACONST_NULL)
+        self.emit(jvm.ACONST_NULL)
 
     # we can't assume MALLOC_ZERO_FILLED, because for scalar type the
     # default item for ArrayList is null, not e.g. Integer(0) or
@@ -1260,16 +708,16 @@
         if TYPE is ootype.Void:
             return
         elif isinstance(value, CDefinedIntSymbolic):
-            self.emit(ICONST, self.DEFINED_INT_SYMBOLICS[value.expr])
+            self.emit(jvm.ICONST, self.DEFINED_INT_SYMBOLICS[value.expr])
         elif TYPE in (ootype.Bool, ootype.Signed):
-            self.emit(ICONST, int(value))
+            self.emit(jvm.ICONST, int(value))
         elif TYPE is ootype.Unsigned:
             # Converts the unsigned int into its corresponding signed value:
             if value > 0x7FFFFFFF:
                 value = -((int(value) ^ 0xFFFFFFFF)+1)
-            self.emit(ICONST, value)
+            self.emit(jvm.ICONST, value)
         elif TYPE is ootype.Char or TYPE is ootype.UniChar:
-            self.emit(ICONST, ord(value))
+            self.emit(jvm.ICONST, ord(value))
         elif TYPE is ootype.SignedLongLong:
             self._push_long_constant(long(value))
         elif TYPE is ootype.UnsignedLongLong:
@@ -1281,7 +729,7 @@
             self._push_double_constant(float(value))
         elif TYPE in (ootype.String, ootype.Unicode):
             if value == ootype.null(TYPE):
-                self.emit(ACONST_NULL)
+                self.emit(jvm.ACONST_NULL)
             else:
                 self.load_string(value._str)
         else:
@@ -1289,25 +737,25 @@
 
     def _push_long_constant(self, value):
         if value == 0:
-            self.emit(LCONST_0)
+            self.emit(jvm.LCONST_0)
         elif value == 1:
-            self.emit(LCONST_1)
+            self.emit(jvm.LCONST_1)
         else:
-            self.emit(LDC2, value)
+            self.emit(jvm.LDC2, value)
 
     def _push_double_constant(self, value):
         if isnan(value):
-            DOUBLENAN.load(self)
+            jvm.DOUBLENAN.load(self)
         elif isinf(value):
-            if value > 0: DOUBLEPOSINF.load(self)
-            else: DOUBLENEGINF.load(self)
+            if value > 0: jvm.DOUBLEPOSINF.load(self)
+            else: jvm.DOUBLENEGINF.load(self)
         elif value == 0.0:
-            self.emit(DCONST_0)
+            self.emit(jvm.DCONST_0)
         elif value == 1.0:
-            self.emit(DCONST_1)
+            self.emit(jvm.DCONST_1)
         else:
             # Big hack to avoid exponential notation:
-            self.emit(LDC2, "%22.22f" % value)
+            self.emit(jvm.LDC2, "%22.22f" % value)
         
     def create_weakref(self, OOTYPE):
         """
@@ -1317,7 +765,7 @@
         The result will be that at the top of the stack is a weak reference.
         """
         self.prepare_generic_argument(OOTYPE) 
-        self.emit(PYPYWEAKREFCREATE)
+        self.emit(jvm.PYPYWEAKREFCREATE)
     
     def deref_weakref(self, OOTYPE):
         """
@@ -1325,7 +773,7 @@
         that this weak ref is a pointer to.  OOTYPE is the kind of object
         you had a weak reference to.
         """
-        self.emit(PYPYWEAKREFGET)
+        self.emit(jvm.PYPYWEAKREFGET)
         self.prepare_generic_result(OOTYPE)
 
     # __________________________________________________________________
@@ -1333,30 +781,30 @@
 
     def throw(self):
         """ Throw the object from top of the stack as an exception """
-        self._instr(ATHROW)
+        self._instr(jvm.ATHROW)
 
     def iabs(self):
-        MATHIABS.invoke(self)
+        jvm.MATHIABS.invoke(self)
 
     def dbl_abs(self):
-        MATHDABS.invoke(self)
+        jvm.MATHDABS.invoke(self)
 
     def bitwise_negate(self):
         """ Invert all the bits in the "int" on the top of the stack """
-        self._instr(ICONST, -1)
-        self._instr(IXOR)
+        self._instr(jvm.ICONST, -1)
+        self._instr(jvm.IXOR)
 
     def goto(self, label):
         """ Jumps unconditionally """
-        self._instr(GOTO, label)
+        self._instr(jvm.GOTO, label)
 
     def goto_if_true(self, label):
         """ Jumps if the top of stack is true """
-        self._instr(IFNE, label)
+        self._instr(jvm.IFNE, label)
 
     def goto_if_false(self, label):
         """ Jumps if the top of stack is false """
-        self._instr(IFEQ, label)
+        self._instr(jvm.IFEQ, label)
 
     ##### Comparison methods
     
@@ -1371,27 +819,27 @@
         midlbl = self.unique_label('cmpop')
         endlbl = self.unique_label('cmpop')
         self._instr(cmpopcode, midlbl)
-        self._instr(ICONST, 0)
-        self._instr(GOTO, endlbl)
+        self._instr(jvm.ICONST, 0)
+        self._instr(jvm.GOTO, endlbl)
         self.mark(midlbl)
-        self._instr(ICONST, 1)
+        self._instr(jvm.ICONST, 1)
         self.mark(endlbl)
 
-    is_null = lambda self: self._compare_op(IFNULL)
-    is_not_null = lambda self: self._compare_op(IFNONNULL)
+    is_null = lambda self: self._compare_op(jvm.IFNULL)
+    is_not_null = lambda self: self._compare_op(jvm.IFNONNULL)
 
-    ref_is_eq = lambda self: self._compare_op(IF_ACMPEQ)
-    ref_is_neq = lambda self: self._compare_op(IF_ACMPNEQ)
+    ref_is_eq = lambda self: self._compare_op(jvm.IF_ACMPEQ)
+    ref_is_neq = lambda self: self._compare_op(jvm.IF_ACMPNEQ)
 
-    logical_not = lambda self: self._compare_op(IFEQ)
+    logical_not = lambda self: self._compare_op(jvm.IFEQ)
     equals_zero = logical_not
-    not_equals_zero = lambda self: self._compare_op(IFNE)
-    equals = lambda self: self._compare_op(IF_ICMPEQ)
-    not_equals = lambda self: self._compare_op(IF_ICMPNE)
-    less_than = lambda self: self._compare_op(IF_ICMPLT)
-    greater_than = lambda self: self._compare_op(IF_ICMPGT)
-    less_equals = lambda self: self._compare_op(IF_ICMPLE)
-    greater_equals = lambda self: self._compare_op(IF_ICMPGE)
+    not_equals_zero = lambda self: self._compare_op(jvm.IFNE)
+    equals = lambda self: self._compare_op(jvm.IF_ICMPEQ)
+    not_equals = lambda self: self._compare_op(jvm.IF_ICMPNE)
+    less_than = lambda self: self._compare_op(jvm.IF_ICMPLT)
+    greater_than = lambda self: self._compare_op(jvm.IF_ICMPGT)
+    less_equals = lambda self: self._compare_op(jvm.IF_ICMPLE)
+    greater_equals = lambda self: self._compare_op(jvm.IF_ICMPGE)
 
     def _uint_compare_op(self, cmpopcode):
         PYPYUINTCMP.invoke(self)
@@ -1399,33 +847,33 @@
 
     u_equals = equals
     u_not_equals = not_equals
-    u_less_than = lambda self: self._uint_compare_op(IFLT)
-    u_greater_than = lambda self: self._uint_compare_op(IFGT)
-    u_less_equals = lambda self: self._uint_compare_op(IFLE)
-    u_greater_equals = lambda self: self._uint_compare_op(IFGE)
+    u_less_than = lambda self: self._uint_compare_op(jvm.IFLT)
+    u_greater_than = lambda self: self._uint_compare_op(jvm.IFGT)
+    u_less_equals = lambda self: self._uint_compare_op(jvm.IFLE)
+    u_greater_equals = lambda self: self._uint_compare_op(jvm.IFGE)
 
     def _dbl_compare_op(self, cmpopcode):
         # XXX --- NaN behavior?
-        self.emit(DCMPG)
+        self.emit(jvm.DCMPG)
         self._compare_op(cmpopcode)
 
-    dbl_equals = lambda self: self._dbl_compare_op(IFEQ)
-    dbl_not_equals = lambda self: self._dbl_compare_op(IFNE)
-    dbl_less_than = lambda self: self._dbl_compare_op(IFLT)
-    dbl_greater_than = lambda self: self._dbl_compare_op(IFGT)
-    dbl_less_equals = lambda self: self._dbl_compare_op(IFLE)
-    dbl_greater_equals = lambda self: self._dbl_compare_op(IFGE)
+    dbl_equals = lambda self: self._dbl_compare_op(jvm.IFEQ)
+    dbl_not_equals = lambda self: self._dbl_compare_op(jvm.IFNE)
+    dbl_less_than = lambda self: self._dbl_compare_op(jvm.IFLT)
+    dbl_greater_than = lambda self: self._dbl_compare_op(jvm.IFGT)
+    dbl_less_equals = lambda self: self._dbl_compare_op(jvm.IFLE)
+    dbl_greater_equals = lambda self: self._dbl_compare_op(jvm.IFGE)
 
     def _long_compare_op(self, cmpopcode):
-        self.emit(LCMP)
+        self.emit(jvm.LCMP)
         self._compare_op(cmpopcode)
 
-    long_equals = lambda self: self._long_compare_op(IFEQ)
-    long_not_equals = lambda self: self._long_compare_op(IFNE)
-    long_less_than = lambda self: self._long_compare_op(IFLT)
-    long_greater_than = lambda self: self._long_compare_op(IFGT)
-    long_less_equals = lambda self: self._long_compare_op(IFLE)
-    long_greater_equals = lambda self: self._long_compare_op(IFGE)
+    long_equals = lambda self: self._long_compare_op(jvm.IFEQ)
+    long_not_equals = lambda self: self._long_compare_op(jvm.IFNE)
+    long_less_than = lambda self: self._long_compare_op(jvm.IFLT)
+    long_greater_than = lambda self: self._long_compare_op(jvm.IFGT)
+    long_less_equals = lambda self: self._long_compare_op(jvm.IFLE)
+    long_greater_equals = lambda self: self._long_compare_op(jvm.IFGE)
 
     def _ulong_compare_op(self, cmpopcode):
         PYPYULONGCMP.invoke(self)
@@ -1433,10 +881,10 @@
 
     ulong_equals = long_equals
     ulong_not_equals = long_not_equals
-    ulong_less_than = lambda self: self._ulong_compare_op(IFLT)
-    ulong_greater_than = lambda self: self._ulong_compare_op(IFGT)
-    ulong_less_equals = lambda self: self._ulong_compare_op(IFLE)
-    ulong_greater_equals = lambda self: self._ulong_compare_op(IFGE)
+    ulong_less_than = lambda self: self._ulong_compare_op(jvm.IFLT)
+    ulong_greater_than = lambda self: self._ulong_compare_op(jvm.IFGT)
+    ulong_less_equals = lambda self: self._ulong_compare_op(jvm.IFLE)
+    ulong_greater_equals = lambda self: self._ulong_compare_op(jvm.IFGE)
         
 class JasminGenerator(JVMGenerator):
 

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/metavm.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/metavm.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/metavm.py	Sun Mar  2 18:48:48 2008
@@ -1,8 +1,7 @@
 from pypy.rpython.ootypesystem import ootype
 from pypy.translator.oosupport.metavm import MicroInstruction
 from pypy.translator.jvm.typesystem import JvmScalarType, JvmClassType
-import pypy.translator.jvm.generator as jvmgen
-import pypy.translator.jvm.typesystem as jvmtype
+import pypy.translator.jvm.typesystem as jvm
 from pypy.translator.jvm.builtin import JvmBuiltInType
 
 class _IndirectCall(MicroInstruction):
@@ -73,8 +72,8 @@
         just find the class to throw normally, but I don't know how.
         """
         self.java_exc = jexc
-        self.pypy_method = jvmgen.Method.v(
-            jvmtype.jPyPyInterlink, pexcmthd, [], jvmtype.jVoid)
+        self.pypy_method = jvm.Method.v(
+            jvm.jPyPyInterlink, pexcmthd, [], jvm.jVoid)
         self.instruction = inst
         
     def render(self, gen, op):
@@ -88,16 +87,16 @@
         gen.goto(donelbl)
         # } catch (JavaExceptionType) {
         gen.mark(catchlbl)
-        gen.emit(jvmgen.POP)            # throw away the exception object
+        gen.emit(jvm.POP)            # throw away the exception object
         gen.push_pypy()                 # load the PyPy object
-        gen.emit(jvmgen.PYPYINTERLINK)  # load the interlink field from it
+        gen.emit(jvm.PYPYINTERLINK)  # load the interlink field from it
         gen.emit(self.pypy_method)      # invoke the method
         # Note: these instructions will never execute, as we expect
         # the pypy_method to throw an exception and not to return.  We
         # need them here to satisfy the Java verifier, however, as it
         # does not know that the pypy_method will never return.
-        gen.emit(jvmgen.ACONST_NULL)
-        gen.emit(jvmgen.ATHROW)
+        gen.emit(jvm.ACONST_NULL)
+        gen.emit(jvm.ATHROW)
         # }
         gen.mark(donelbl)
 
@@ -126,7 +125,7 @@
     def render(self, generator, op):
         self._load_func(generator, *op.args[1:4])
         self._load_func(generator, *op.args[4:7])
-        generator.emit(jvmgen.CUSTOMDICTMAKE)
+        generator.emit(jvm.CUSTOMDICTMAKE)
 NewCustomDict = _NewCustomDict()
 
 #XXX These classes have been adapted to the new
@@ -148,8 +147,8 @@
 
 CASTS = {
 #   FROM                      TO
-    (ootype.Signed,           ootype.UnsignedLongLong): jvmgen.I2L,
-    (ootype.SignedLongLong,   ootype.Signed):           jvmgen.L2I,
+    (ootype.Signed,           ootype.UnsignedLongLong): jvm.I2L,
+    (ootype.SignedLongLong,   ootype.Signed):           jvm.L2I,
     (ootype.UnsignedLongLong, ootype.SignedLongLong):   None,
     }
 

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/methods.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/methods.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/methods.py	Sun Mar  2 18:48:48 2008
@@ -7,8 +7,7 @@
 
 """
 
-import pypy.translator.jvm.generator as jvmgen
-import pypy.translator.jvm.typesystem as jvmtype
+import pypy.translator.jvm.typesystem as jvm
 from pypy.rpython.ootypesystem import ootype, rclass
 
 class BaseDumpMethod(object):
@@ -19,7 +18,7 @@
         self.clsobj = clsobj
         self.name = "toString"
         self.jargtypes = [clsobj]
-        self.jrettype = jvmtype.jString
+        self.jrettype = jvm.jString
 
     def _print_field_value(self, fieldnm, FIELDOOTY):
         self.gen.load_this_ptr()
@@ -27,21 +26,21 @@
         fieldobj.load(self.gen)
         dumpmethod = self.db.toString_method_for_ootype(FIELDOOTY)
         self.gen.emit(dumpmethod)
-        self.gen.emit(jvmgen.STRINGBUILDERAPPEND)
+        self.gen.emit(jvm.STRINGBUILDERAPPEND)
 
     def _print(self, str):
         self.gen.load_string(str)
-        self.gen.emit(jvmgen.STRINGBUILDERAPPEND)
+        self.gen.emit(jvm.STRINGBUILDERAPPEND)
 
     def render(self, gen):
         self.gen = gen
         gen.begin_function(
             self.name, (), self.jargtypes, self.jrettype, static=False)
 
-        gen.new_with_jtype(jvmtype.jStringBuilder)
+        gen.new_with_jtype(jvm.jStringBuilder)
         self._render_guts(gen)
-        gen.emit(jvmgen.OBJTOSTRING)
-        gen.emit(jvmgen.RETURN.for_type(jvmtype.jString))
+        gen.emit(jvm.OBJTOSTRING)
+        gen.emit(jvm.RETURN.for_type(jvm.jString))
         gen.end_function()
         self.gen = None
 
@@ -117,8 +116,8 @@
         self.OOCLASS = OOCLASS
         self.clsobj = clsobj
         self.name = "equals"
-        self.jargtypes = [clsobj, jvmtype.jObject]
-        self.jrettype = jvmtype.jBool
+        self.jargtypes = [clsobj, jvm.jObject]
+        self.jrettype = jvm.jBool
 
     def render(self, gen):
         self.gen = gen
@@ -156,10 +155,10 @@
 
         # Return true or false as appropriate
         gen.push_primitive_constant(ootype.Bool, True)
-        gen.return_val(jvmtype.jBool)
+        gen.return_val(jvm.jBool)
         gen.mark(unequal_lbl)
         gen.push_primitive_constant(ootype.Bool, False)
-        gen.return_val(jvmtype.jBool)
+        gen.return_val(jvm.jBool)
 
         gen.end_function()
 
@@ -171,7 +170,7 @@
         self.clsobj = clsobj
         self.name = "hashCode"
         self.jargtypes = [clsobj]
-        self.jrettype = jvmtype.jInt
+        self.jrettype = jvm.jInt
 
     def render(self, gen):
         self.gen = gen
@@ -194,10 +193,10 @@
             gen.hash_value(FIELDOOTY)
 
             # XOR that with the main hash
-            gen.emit(jvmgen.IXOR)
+            gen.emit(jvm.IXOR)
 
         # Return the final hash
-        gen.return_val(jvmtype.jInt)
+        gen.return_val(jvm.jInt)
 
         gen.end_function()
 

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/node.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/node.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/node.py	Sun Mar  2 18:48:48 2008
@@ -34,7 +34,7 @@
 from pypy.translator.oosupport.constant import \
      push_constant
 
-import pypy.translator.jvm.generator as jvmgen
+import pypy.translator.jvm.typesystem as jvm
 from pypy.translator.jvm.log import log
 
 class Node(object):
@@ -79,14 +79,14 @@
     # XXX --- perhaps this table would be better placed in typesystem.py
     # so as to constrain the knowledge of lltype and ootype
     _type_conversion_methods = {
-        ootype.Signed:jvmgen.PYPYSTRTOINT,
-        ootype.Unsigned:jvmgen.PYPYSTRTOUINT,
-        lltype.SignedLongLong:jvmgen.PYPYSTRTOLONG,
-        lltype.UnsignedLongLong:jvmgen.PYPYSTRTOULONG,
-        ootype.Bool:jvmgen.PYPYSTRTOBOOL,
-        ootype.Float:jvmgen.PYPYSTRTODOUBLE,
-        ootype.Char:jvmgen.PYPYSTRTOCHAR,
-        ootype.UniChar:jvmgen.PYPYSTRTOCHAR,
+        ootype.Signed:jvm.PYPYSTRTOINT,
+        ootype.Unsigned:jvm.PYPYSTRTOUINT,
+        lltype.SignedLongLong:jvm.PYPYSTRTOLONG,
+        lltype.UnsignedLongLong:jvm.PYPYSTRTOULONG,
+        ootype.Bool:jvm.PYPYSTRTOBOOL,
+        ootype.Float:jvm.PYPYSTRTODOUBLE,
+        ootype.Char:jvm.PYPYSTRTOCHAR,
+        ootype.UniChar:jvm.PYPYSTRTOCHAR,
         ootype.String:None
         }
 
@@ -101,12 +101,11 @@
         #
         #    2. Run the initialization method for the constant class.
         #
-        gen.begin_function(
-            '<clinit>', (), [], jVoid, static=True)
-        gen.emit(jvmgen.NEW, jPyPy)
-        gen.emit(jvmgen.DUP)
+        gen.begin_function('<clinit>', (), [], jVoid, static=True)
+        gen.emit(jvm.NEW, jPyPy)
+        gen.emit(jvm.DUP)
         gen.new_with_jtype(gen.db.jInterlinkImplementation)
-        gen.emit(jvmgen.Method.c(jPyPy, [jPyPyInterlink]))
+        gen.emit(jvm.Method.c(jPyPy, [jPyPyInterlink]))
         gen.db.pypy_field.store(gen)
         gen.db.constant_generator.runtime_init(gen)
         gen.return_val(jVoid)
@@ -133,7 +132,7 @@
                 conv = self._type_conversion_methods[arg.concretetype]
                 if conv: gen.push_pypy()
                 gen.load_jvm_var(jStringArray, 0)
-                gen.emit(jvmgen.ICONST, i)
+                gen.emit(jvm.ICONST, i)
                 gen.load_from_array(jString)
                 if conv: gen.emit(conv)
         else:
@@ -143,7 +142,7 @@
             assert isinstance(arg0.concretetype, ootype.List), str(arg0.concretetype)
             assert arg0.concretetype.ITEM is ootype.String
             gen.load_jvm_var(jStringArray, 0)
-            gen.emit(jvmgen.PYPYARRAYTOLIST)
+            gen.emit(jvm.PYPYARRAYTOLIST)
 
         # Generate a call to this method
         gen.emit(self.db.pending_function(self.graph))
@@ -161,13 +160,13 @@
             gen.add_comment('Invoking dump method for result of type '
                             +str(RESOOTYPE))
             gen.emit(dumpmethod)      # generate the string
-            gen.emit(jvmgen.PYPYDUMP) # dump to stdout
+            gen.emit(jvm.PYPYDUMP) # dump to stdout
             gen.goto(done_printing)
             gen.end_try()
 
             jexc = self.db.exception_root_object()
             gen.begin_catch(jexc)
-            gen.emit(jvmgen.PYPYDUMPEXCWRAPPER) # dumps to stdout
+            gen.emit(jvm.PYPYDUMPEXCWRAPPER) # dumps to stdout
             gen.end_catch()
 
             gen.mark(done_printing)
@@ -188,12 +187,12 @@
     name = None                       
     
     def render(self, gen):
-        """ Uses the gen argument, a jvmgen.Generator, to create the
+        """ Uses the gen argument, a jvm.Generator, to create the
         appropriate JVM assembly for this method. """
         raise NotImplementedError
     
     def method(self):
-        """ Returns a jvmgen.Method object that would allow this
+        """ Returns a jvm.Method object that would allow this
         function to be invoked. """
         raise NotImplementedError
 
@@ -262,12 +261,12 @@
         return self.generator.unique_label(prefix)
 
     def method(self):
-        """ Returns a jvmgen.Method that can invoke this function """
+        """ Returns a jvm.Method that can invoke this function """
         if not self.is_method:
-            ctor = jvmgen.Method.s
+            ctor = jvm.Method.s
             startidx = 0
         else:
-            ctor = jvmgen.Method.v
+            ctor = jvm.Method.v
             startidx = 1
         return ctor(self.classty, self.name,
                     self.jargtypes[startidx:], self.jrettype)
@@ -334,7 +333,7 @@
         else:
             # the exception value is on the stack, store it in the proper place
             if isinstance(link.last_exception, flowmodel.Variable):
-                self.ilasm.emit(jvmgen.DUP)
+                self.ilasm.emit(jvm.DUP)
                 self.ilasm.store(link.last_exc_value)
                 fld = self.db.lltype_to_cts(rclass.OBJECT).lookup_field('meta')
                 self.ilasm.emit(fld)
@@ -394,9 +393,9 @@
     def _trace(self, str, writeline=False):
         if writeline:
             str += '\n'
-        jvmgen.SYSTEMERR.load(self.generator)
+        jvm.SYSTEMERR.load(self.generator)
         self.generator.load_string(str)
-        jvmgen.PRINTSTREAMPRINTSTR.invoke(self.generator)
+        jvm.PRINTSTREAMPRINTSTR.invoke(self.generator)
 
     def _is_printable(self, res):
 
@@ -431,10 +430,10 @@
                 res.concretetype)
             
             self._trace("  "+prompt+": ")
-            self.generator.emit(jvmgen.SYSTEMERR)
+            self.generator.emit(jvm.SYSTEMERR)
             self.generator.load(res)
             self.generator.emit(jmethod)
-            self.generator.emit(jvmgen.PRINTSTREAMPRINTSTR)
+            self.generator.emit(jvm.PRINTSTREAMPRINTSTR)
             self._trace("\n")
 
     def _trace_enabled(self):
@@ -473,7 +472,7 @@
         self.java_return_type = jrettype
         self.dump_method = ConstantStringDumpMethod(
             self, "StaticMethodInterface")
-        self.invoke_method_obj = jvmgen.Method.v(
+        self.invoke_method_obj = jvm.Method.v(
                 self, 'invoke',
                 self.java_argument_types[1:], self.java_return_type)
         
@@ -481,7 +480,7 @@
         raise KeyError(fieldnm) # no fields
     
     def lookup_method(self, methodnm):
-        """ Given the method name, returns a jvmgen.Method object """
+        """ Given the method name, returns a jvm.Method object """
         assert isinstance(self.java_return_type, JvmType)
         if methodnm == 'invoke':
             return self.invoke_method_obj
@@ -575,9 +574,9 @@
 
         if bound_to_jty:
             self.bound_to_jty = bound_to_jty
-            self.bound_to_fld = jvmgen.Field(
+            self.bound_to_fld = jvm.Field(
                 self.name, 'bound_to', bound_to_jty, False)
-            self.bind_method = jvmgen.Method.s(
+            self.bind_method = jvm.Method.s(
                 self, 'bind', (self.bound_to_jty,), self)                
         else:
             self.bound_to_jty = None
@@ -608,7 +607,7 @@
             gen.begin_function(
                 'bind', [], (self.bound_to_jty,), self, static=True)
             gen.new_with_jtype(self)
-            gen.emit(jvmgen.DUP)
+            gen.emit(jvm.DUP)
             gen.load_jvm_var(self.bound_to_jty, 0)
             self.bound_to_fld.store(gen)
             gen.return_val(self)
@@ -688,10 +687,10 @@
         JvmGeneratedClassType.__init__(self, name)
         self.rendered = False       # has rendering occurred?
         self.abstract = False       # is this an abstract class?
-        self.fields = {}            # maps field name to jvmgen.Field object
+        self.fields = {}            # maps field name to jvm.Field object
         self.interfaces = []        # list of JvmTypes
         self.methods = {}           # maps method name to a Function object*
-        self.abstract_methods = {}  # maps method name to jvmgen.Method object
+        self.abstract_methods = {}  # maps method name to jvm.Method object
         self.set_super_class(supercls)
 
         # * --- actually maps to an object that defines the
@@ -711,9 +710,9 @@
             self.throwable = True
 
     def add_field(self, fieldobj, fielddef):
-        """ Creates a new field accessed via the jvmgen.Field
+        """ Creates a new field accessed via the jvm.Field
         descriptor 'fieldobj'.  Must be called before render()."""
-        assert not self.rendered and isinstance(fieldobj, jvmgen.Field)
+        assert not self.rendered and isinstance(fieldobj, jvm.Field)
         self.fields[fieldobj.field_name] = (fieldobj, fielddef)
 
     def add_interface(self, inter):
@@ -726,7 +725,7 @@
         return self.super_class.lookup_field(fieldnm)
 
     def lookup_method(self, methodnm):
-        """ Given the method name, returns a jvmgen.Method object """
+        """ Given the method name, returns a jvm.Method object """
         if methodnm in self.methods:
             return self.methods[methodnm].method()
         if methodnm in self.abstract_methods:
@@ -742,7 +741,7 @@
 
     def add_abstract_method(self, jmethod):
         """ Adds an abstract method to our list of methods; jmethod should
-        be a jvmgen.Method object """
+        be a jvm.Method object """
         assert jmethod.method_name not in self.methods
         self.abstract = True
         self.abstract_methods[jmethod.method_name] = jmethod
@@ -789,7 +788,7 @@
         """
         interlink:  the JvmType of the Interlink implementation
         name:       the name of the method
-        helper:     a jvmgen.Method object for the helper func we should invoke
+        helper:     a jvm.Method object for the helper func we should invoke
         """
         self.interlink = interlink
         self.name = name
@@ -803,7 +802,7 @@
         else:
             self.return_type = self.helper.return_type
             
-        self.method_obj = jvmgen.Method.v(interlink,
+        self.method_obj = jvm.Method.v(interlink,
                                           self.name,
                                           self.helper.argument_types,
                                           self.return_type)

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/opcodes.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/opcodes.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/opcodes.py	Sun Mar  2 18:48:48 2008
@@ -14,19 +14,18 @@
      CastPrimitive, PushPyPy
 from pypy.rpython.ootypesystem import ootype
 
-import pypy.translator.jvm.generator as jvmgen
-import pypy.translator.jvm.typesystem as jvmtype
+import pypy.translator.jvm.typesystem as jvm
 
 def _proc(val):
     if isinstance(val, list):
         # Lists of instructions we leave alone:
         return InstructionList(val)
-    elif isinstance(val, jvmgen.Method) and not val.is_static():
+    elif isinstance(val, jvm.Method) and not val.is_static():
         # For virtual methods, we first push an instance of the relevant
         # class, then the arguments, and then invoke the method.  Note
         # that we only allow virtual methods of certain pre-designated
         # classes to be in the table.
-        if val.class_name == jvmtype.jPyPy.name:
+        if val.class_name == jvm.jPyPy.name:
             return InstructionList(
                 (PushPyPy, PushAllArgs, val, StoreResult))
         else:
@@ -48,7 +47,7 @@
 
 def _check_zer(op):
     return [TranslateException(
-        jvmtype.jArithmeticException,
+        jvm.jArithmeticException,
         'throwZeroDivisionError',
         _proc(op))]
 
@@ -73,19 +72,19 @@
     'oois':                     'ref_is_eq',
     'oononnull':                'is_not_null',
     'instanceof':               [CastTo, StoreResult],
-    'subclassof':               [PushAllArgs, jvmgen.SWAP, jvmgen.CLASSISASSIGNABLEFROM, StoreResult],
-    'ooidentityhash':           [PushAllArgs, jvmgen.OBJHASHCODE, StoreResult], 
-    'oohash':                   [PushAllArgs, jvmgen.OBJHASHCODE, StoreResult], 
+    'subclassof':               [PushAllArgs, jvm.SWAP, jvm.CLASSISASSIGNABLEFROM, StoreResult],
+    'ooidentityhash':           [PushAllArgs, jvm.OBJHASHCODE, StoreResult], 
+    'oohash':                   [PushAllArgs, jvm.OBJHASHCODE, StoreResult], 
     'oostring':                 [OOString, StoreResult],
     'oounicode':                [OOUnicode, StoreResult],
-    'ooparse_float':            jvmgen.PYPYOOPARSEFLOAT,
+    'ooparse_float':            jvm.PYPYOOPARSEFLOAT,
     'oonewcustomdict':          [NewCustomDict, StoreResult],
     'same_as':                  DoNothing,
     'hint':                     [PushArg(0), StoreResult],
     'direct_call':              [Call, StoreResult],
     'indirect_call':            [PushAllArgs, IndirectCall, StoreResult],
 
-    'gc__collect':              jvmgen.SYSTEMGC,
+    'gc__collect':              jvm.SYSTEMGC,
     'gc_set_max_heap_size':     Ignore,
     'resume_point':             Ignore,
 
@@ -106,83 +105,83 @@
     'unichar_ne':               'not_equals',
 
     'int_is_true':              'not_equals_zero',
-    'int_neg':                  jvmgen.INEG,
-    'int_neg_ovf':              jvmgen.INEGOVF,
+    'int_neg':                  jvm.INEG,
+    'int_neg_ovf':              jvm.INEGOVF,
     'int_abs':                  'iabs',
-    'int_abs_ovf':              jvmgen.IABSOVF,
+    'int_abs_ovf':              jvm.IABSOVF,
     'int_invert':               'bitwise_negate',
 
-    'int_add':                  jvmgen.IADD,
-    'int_sub':                  jvmgen.ISUB,
-    'int_mul':                  jvmgen.IMUL,
-    'int_floordiv':             jvmgen.IDIV,
-    'int_floordiv_zer':         _check_zer(jvmgen.IDIV),
-    'int_mod':                  jvmgen.IREM,
+    'int_add':                  jvm.IADD,
+    'int_sub':                  jvm.ISUB,
+    'int_mul':                  jvm.IMUL,
+    'int_floordiv':             jvm.IDIV,
+    'int_floordiv_zer':         _check_zer(jvm.IDIV),
+    'int_mod':                  jvm.IREM,
     'int_lt':                   'less_than',
     'int_le':                   'less_equals',
     'int_eq':                   'equals',
     'int_ne':                   'not_equals',
     'int_gt':                   'greater_than',
     'int_ge':                   'greater_equals',
-    'int_and':                  jvmgen.IAND,
-    'int_or':                   jvmgen.IOR,
-    'int_lshift':               jvmgen.ISHL,
-    'int_rshift':               jvmgen.ISHR,
-    'int_xor':                  jvmgen.IXOR,
-    'int_add_ovf':              jvmgen.IADDOVF,
-    'int_add_nonneg_ovf':       jvmgen.IADDOVF,
-    'int_sub_ovf':              jvmgen.ISUBOVF,
-    'int_mul_ovf':              jvmgen.IMULOVF,
-    'int_floordiv_ovf':         jvmgen.IDIV, # these can't overflow!
-    'int_mod_zer':              _check_zer(jvmgen.IREM),
-    'int_mod_ovf':              jvmgen.IREMOVF,
+    'int_and':                  jvm.IAND,
+    'int_or':                   jvm.IOR,
+    'int_lshift':               jvm.ISHL,
+    'int_rshift':               jvm.ISHR,
+    'int_xor':                  jvm.IXOR,
+    'int_add_ovf':              jvm.IADDOVF,
+    'int_add_nonneg_ovf':       jvm.IADDOVF,
+    'int_sub_ovf':              jvm.ISUBOVF,
+    'int_mul_ovf':              jvm.IMULOVF,
+    'int_floordiv_ovf':         jvm.IDIV, # these can't overflow!
+    'int_mod_zer':              _check_zer(jvm.IREM),
+    'int_mod_ovf':              jvm.IREMOVF,
     'int_lt_ovf':               'less_than',
     'int_le_ovf':               'less_equals',
     'int_eq_ovf':               'equals',
     'int_ne_ovf':               'not_equals',
     'int_gt_ovf':               'greater_than',
     'int_ge_ovf':               'greater_equals',
-    'int_and_ovf':              jvmgen.IAND,
-    'int_or_ovf':               jvmgen.IOR,
+    'int_and_ovf':              jvm.IAND,
+    'int_or_ovf':               jvm.IOR,
 
-    'int_lshift_ovf':           jvmgen.ISHLOVF,
-    'int_lshift_ovf_val':       jvmgen.ISHLOVF, # VAL... what is val used for??
+    'int_lshift_ovf':           jvm.ISHLOVF,
+    'int_lshift_ovf_val':       jvm.ISHLOVF, # VAL... what is val used for??
 
-    'int_rshift_ovf':           jvmgen.ISHR, # these can't overflow!
-    'int_xor_ovf':              jvmgen.IXOR,
-    'int_floordiv_ovf_zer':     _check_zer(jvmgen.IDIV),
-    'int_mod_ovf_zer':          _check_zer(jvmgen.IREMOVF),
+    'int_rshift_ovf':           jvm.ISHR, # these can't overflow!
+    'int_xor_ovf':              jvm.IXOR,
+    'int_floordiv_ovf_zer':     _check_zer(jvm.IDIV),
+    'int_mod_ovf_zer':          _check_zer(jvm.IREMOVF),
 
     'uint_is_true':             'not_equals_zero',
     'uint_invert':              'bitwise_negate',
 
-    'uint_add':                 jvmgen.IADD,
-    'uint_sub':                 jvmgen.ISUB,
-    'uint_mul':                 jvmgen.PYPYUINTMUL,
-    'uint_div':                 jvmgen.PYPYUINTDIV,
+    'uint_add':                 jvm.IADD,
+    'uint_sub':                 jvm.ISUB,
+    'uint_mul':                 jvm.PYPYUINTMUL,
+    'uint_div':                 jvm.PYPYUINTDIV,
     'uint_truediv':             None,    # TODO
-    'uint_floordiv':            jvmgen.PYPYUINTDIV,
-    'uint_mod':                 jvmgen.PYPYUINTMOD,
+    'uint_floordiv':            jvm.PYPYUINTDIV,
+    'uint_mod':                 jvm.PYPYUINTMOD,
     'uint_lt':                  'u_less_than',
     'uint_le':                  'u_less_equals',
     'uint_eq':                  'u_equals',
     'uint_ne':                  'u_not_equals',
     'uint_gt':                  'u_greater_than',
     'uint_ge':                  'u_greater_equals',
-    'uint_and':                 jvmgen.IAND,
-    'uint_or':                  jvmgen.IOR,
-    'uint_lshift':              jvmgen.ISHL,
-    'uint_rshift':              jvmgen.IUSHR,
-    'uint_xor':                 jvmgen.IXOR,
+    'uint_and':                 jvm.IAND,
+    'uint_or':                  jvm.IOR,
+    'uint_lshift':              jvm.ISHL,
+    'uint_rshift':              jvm.IUSHR,
+    'uint_xor':                 jvm.IXOR,
 
-    'float_is_true':            [PushAllArgs, jvmgen.DCONST_0, 'dbl_not_equals', StoreResult],
-    'float_neg':                jvmgen.DNEG,
+    'float_is_true':            [PushAllArgs, jvm.DCONST_0, 'dbl_not_equals', StoreResult],
+    'float_neg':                jvm.DNEG,
     'float_abs':                'dbl_abs',
 
-    'float_add':                jvmgen.DADD,
-    'float_sub':                jvmgen.DSUB,
-    'float_mul':                jvmgen.DMUL,
-    'float_truediv':            jvmgen.DDIV,
+    'float_add':                jvm.DADD,
+    'float_sub':                jvm.DSUB,
+    'float_mul':                jvm.DMUL,
+    'float_truediv':            jvm.DDIV,
     'float_lt':                 'dbl_less_than',     
     'float_le':                 'dbl_less_equals',   
     'float_eq':                 'dbl_equals',        
@@ -190,56 +189,56 @@
     'float_gt':                 'dbl_greater_than',  
     'float_ge':                 'dbl_greater_equals',
 
-    'llong_is_true':            [PushAllArgs, jvmgen.LCONST_0, 'long_not_equals', StoreResult],
-    'llong_neg':                jvmgen.LNEG,
-    'llong_neg_ovf':            jvmgen.LNEGOVF,
-    'llong_abs':                jvmgen.MATHLABS,
-    'llong_abs_ovf':            jvmgen.LABSOVF,
-    'llong_invert':             jvmgen.PYPYLONGBITWISENEGATE,
-
-    'llong_add':                jvmgen.LADD,
-    'llong_sub':                jvmgen.LSUB,
-    'llong_mul':                jvmgen.LMUL,
-    'llong_div':                jvmgen.LDIV,
+    'llong_is_true':            [PushAllArgs, jvm.LCONST_0, 'long_not_equals', StoreResult],
+    'llong_neg':                jvm.LNEG,
+    'llong_neg_ovf':            jvm.LNEGOVF,
+    'llong_abs':                jvm.MATHLABS,
+    'llong_abs_ovf':            jvm.LABSOVF,
+    'llong_invert':             jvm.PYPYLONGBITWISENEGATE,
+
+    'llong_add':                jvm.LADD,
+    'llong_sub':                jvm.LSUB,
+    'llong_mul':                jvm.LMUL,
+    'llong_div':                jvm.LDIV,
     'llong_truediv':            None, # TODO
-    'llong_floordiv':           jvmgen.LDIV,
-    'llong_floordiv_zer':       _check_zer(jvmgen.LDIV),
-    'llong_mod':                jvmgen.LREM,
-    'llong_mod_zer':            _check_zer(jvmgen.LREM),
+    'llong_floordiv':           jvm.LDIV,
+    'llong_floordiv_zer':       _check_zer(jvm.LDIV),
+    'llong_mod':                jvm.LREM,
+    'llong_mod_zer':            _check_zer(jvm.LREM),
     'llong_lt':                 'long_less_than',     
     'llong_le':                 'long_less_equals',   
     'llong_eq':                 'long_equals',        
     'llong_ne':                 'long_not_equals',    
     'llong_gt':                 'long_greater_than',  
     'llong_ge':                 'long_greater_equals',
-    'llong_and':                jvmgen.LAND,
-    'llong_or':                 jvmgen.LOR,
-    'llong_lshift':             jvmgen.LSHL,
-    'llong_rshift':             [PushAllArgs, jvmgen.L2I, jvmgen.LSHR, StoreResult],
-    'llong_xor':                jvmgen.LXOR,
-    'llong_floordiv_ovf':       jvmgen.LDIV, # these can't overflow!
-    'llong_mod_ovf':            jvmgen.LREMOVF,
-    'llong_lshift_ovf':         jvmgen.LSHLOVF,
-
-    'ullong_is_true':           [PushAllArgs, jvmgen.LCONST_0, 'long_not_equals', StoreResult],
-    'ullong_invert':            jvmgen.PYPYLONGBITWISENEGATE,
-
-    'ullong_add':               jvmgen.LADD,
-    'ullong_sub':               jvmgen.LSUB,
-    'ullong_mul':               jvmgen.LMUL,
-    'ullong_div':               jvmgen.LDIV, # valid?
+    'llong_and':                jvm.LAND,
+    'llong_or':                 jvm.LOR,
+    'llong_lshift':             jvm.LSHL,
+    'llong_rshift':             [PushAllArgs, jvm.L2I, jvm.LSHR, StoreResult],
+    'llong_xor':                jvm.LXOR,
+    'llong_floordiv_ovf':       jvm.LDIV, # these can't overflow!
+    'llong_mod_ovf':            jvm.LREMOVF,
+    'llong_lshift_ovf':         jvm.LSHLOVF,
+
+    'ullong_is_true':           [PushAllArgs, jvm.LCONST_0, 'long_not_equals', StoreResult],
+    'ullong_invert':            jvm.PYPYLONGBITWISENEGATE,
+
+    'ullong_add':               jvm.LADD,
+    'ullong_sub':               jvm.LSUB,
+    'ullong_mul':               jvm.LMUL,
+    'ullong_div':               jvm.LDIV, # valid?
     'ullong_truediv':           None, # TODO
-    'ullong_floordiv':          jvmgen.LDIV, # valid?
-    'ullong_mod':               jvmgen.PYPYULONGMOD,
+    'ullong_floordiv':          jvm.LDIV, # valid?
+    'ullong_mod':               jvm.PYPYULONGMOD,
     'ullong_lt':                'ulong_less_than',     
     'ullong_le':                'ulong_less_equals',   
     'ullong_eq':                'ulong_equals',        
     'ullong_ne':                'ulong_not_equals',    
     'ullong_gt':                'ulong_greater_than',  
     'ullong_ge':                'ulong_greater_equals',
-    'ullong_lshift':            [PushAllArgs, jvmgen.L2I, jvmgen.LSHL, StoreResult],
-    'ullong_rshift':            [PushAllArgs, jvmgen.L2I, jvmgen.LUSHR, StoreResult],
-    'ullong_mod_zer':           jvmgen.PYPYULONGMOD,
+    'ullong_lshift':            [PushAllArgs, jvm.L2I, jvm.LSHL, StoreResult],
+    'ullong_rshift':            [PushAllArgs, jvm.L2I, jvm.LUSHR, StoreResult],
+    'ullong_mod_zer':           jvm.PYPYULONGMOD,
 
     # when casting from bool we want that every truth value is casted
     # to 1: we can't simply DoNothing, because the CLI stack could
@@ -247,21 +246,21 @@
     # trick. #THIS COMMENT NEEDS TO BE VALIDATED AND UPDATED
     'cast_bool_to_int':         DoNothing,
     'cast_bool_to_uint':        DoNothing,
-    'cast_bool_to_float':       jvmgen.PYPYBOOLTODOUBLE, #PAUL, inefficient    
+    'cast_bool_to_float':       jvm.PYPYBOOLTODOUBLE, #PAUL, inefficient    
     'cast_char_to_int':         DoNothing,
     'cast_unichar_to_int':      DoNothing,
     'cast_int_to_char':         DoNothing,
     'cast_int_to_unichar':      DoNothing,
     'cast_int_to_uint':         DoNothing,
-    'cast_int_to_float':        jvmgen.I2D,
-    'cast_int_to_longlong':     jvmgen.I2L,
+    'cast_int_to_float':        jvm.I2D,
+    'cast_int_to_longlong':     jvm.I2L,
     'cast_uint_to_int':         DoNothing,
-    'cast_uint_to_float':       jvmgen.PYPYUINTTODOUBLE, 
-    'cast_float_to_int':        jvmgen.D2I,
-    'cast_float_to_longlong':   jvmgen.PYPYDOUBLETOLONG, #PAUL
-    'cast_float_to_uint':       jvmgen.PYPYDOUBLETOUINT,
-    'truncate_longlong_to_int': jvmgen.L2I,
-    'cast_longlong_to_float':   jvmgen.L2D,
+    'cast_uint_to_float':       jvm.PYPYUINTTODOUBLE, 
+    'cast_float_to_int':        jvm.D2I,
+    'cast_float_to_longlong':   jvm.PYPYDOUBLETOLONG, #PAUL
+    'cast_float_to_uint':       jvm.PYPYDOUBLETOUINT,
+    'truncate_longlong_to_int': jvm.L2I,
+    'cast_longlong_to_float':   jvm.L2D,
     'cast_primitive':           [PushAllArgs, CastPrimitive, StoreResult],
     'is_early_constant':        [PushPrimitive(ootype.Bool, False), StoreResult]
     

Added: pypy/branch/fixed-list-ootype/pypy/translator/jvm/src/pypy/VoidArray.java
==============================================================================
--- (empty file)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/src/pypy/VoidArray.java	Sun Mar  2 18:48:48 2008
@@ -0,0 +1,24 @@
+package pypy;
+
+class VoidArray {
+    public final int length;
+
+    public VoidArray(int length) {
+        this.length = length;
+    }
+
+    /** invoked by generated code because it is easier than the constructor */
+    public static VoidArray make(int length) {
+        return new VoidArray(length);
+    }
+
+    public int ll_length() {
+        return length;
+    }
+
+    public void ll_getitem_fast(int index) {
+    }
+
+    public void ll_setitem_fast(int index) {
+    }
+}
\ No newline at end of file

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/test/test_class.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/test/test_class.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/test/test_class.py	Sun Mar  2 18:48:48 2008
@@ -24,7 +24,8 @@
 
         assert self.interpret(fn, [2]) == 42
             
-        
+    def test_specialize_methods(self):
+        py.test.skip('ABSTRACT METHOD FIX: RE-TEST AFTER MERGE')
 
 class TestJvmSpecialCase(JvmTest, BaseTestSpecialcase):
     pass

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py	Sun Mar  2 18:48:48 2008
@@ -1,33 +1,28 @@
 """
-Definition and some basic translations between PyPy ootypesystem and
-JVM type system.
-
-Here are some tentative non-obvious decisions:
-
-Signed scalar types mostly map as is.  
-
-Unsigned scalar types are a problem; the basic idea is to store them
-as signed values, but execute special code when working with them.  Another
-option would be to use classes, or to use the "next larger" type and remember to use appropriate modulos.  The jury is out on
-this.  Another idea would be to add a variant type system that does
-not have unsigned values, and write the required helper and conversion
-methods in RPython --- then it could be used for multiple backends.
-
-Python strings are mapped to byte arrays, not Java Strings, since
-Python strings are really sets of bytes, not unicode code points.
-Jury is out on this as well; this is not the approach taken by cli,
-for example.
-
-Python Unicode strings, on the other hand, map directly to Java Strings.
-
-WeakRefs are mapped to a thin wrapper class, PyPyWeakRef, to allow for
-mutation of the object being referenced (the ll_set method).
-
-Collections can hopefully map to Java collections instances.  Note
-that JVM does not have an idea of generic typing at its lowest level
-(well, they do have signature attributes, but those don't really count
-for much).
+Defines the basic structures which are used to represent JVM abstraction,
+such as Java types, fields, methods and opcodes.
 
+The structures in this file generally two different, but related,
+roles.  First, they describe a JVM abstraction.  For example, jObject
+describes some of the properties of the built-in class
+java.lang.Object.  Second, they can represent the concrete realization
+of an OOTYPE construct.  For example, JvmType instances are used to
+represent the translated class which will be generated for some OOTYPE
+class.
+
+This file itself is intended to be imported from a wide variety of
+locations, and thus generally restricts itself to classes and global
+variables that describe intrinsic parts of the JVM.  For example,
+there are objects representing different opcodes, type definitions for
+built-in types like java.lang.Object and java.lang.System, and
+method/field declarations for well-known methods and fields on those
+types.
+
+Other files extend this set with objects that represent the JVM
+realization of some OOTYPE construct.  For example, the module
+builtin.py describes the JVM types that are used to define the
+built-in OOTYPE types, such as lists or dictionaries.  The module
+node.py contains code for representing user-defined classes.  
 """
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.ootypesystem import ootype
@@ -105,6 +100,13 @@
 
 # ______________________________________________________________________
 # Basic JVM Types
+#
+# As described above, some of these define well-known types in the JVM
+# or standard Java library.  In addition, there are subtypes of
+# JvmType which represent the translated version of some RPython
+# class, such as a list, dictionary, or user-defined class.  Those
+# subtypes are generally defined in other modules, as they have
+# dependencies that would cause circular imports.
 
 class JvmType(object):
     """
@@ -119,15 +121,23 @@
                                       # (None for scalars and arrays)
 
     def lookup_field(self, fieldnm):
-        """ If the class has a field named 'fieldnm', returns a
-        jvmgen.Field or jvmgen.Property object that represents it and can
-        be used with the interpreter to load/store it.  If no such field
-        exists, or this is not a class, then raises KeyError. """
+        """ Returns a Field or Property object that represents the
+        field named 'fieldnm', or raises KeyError if no such field
+        exists.  'fieldnm' generally represents an OOTYPE field, and
+        thus this method is generally not implemenented by the JvmType
+        classes that just represent native Java classes, even if they
+        have fields.  Instead, such fields are described as global
+        Field constants, either in this file or elsewhere. """
         raise NotImplementedException
+    
     def lookup_method(self, methodnm):
-        """ Returns a jvm.generator.Method object representing the method
-        with the given name, or raises KeyError if that field does not
-        exist on this type. """
+        """ Returns a BaseMethod object that represents the method
+        named 'methodnm', or raises KeyError if no such field exists.
+        'methodnm' represents an OOTYPE method, and thus this method
+        is generally not implemenented by the JvmType classes that
+        just represent native Java classes, even if they have methods.
+        Instead, such methods are described as global Method constants
+        in this file, either in this file or elsewhere. """
         raise NotImplementedException
 
     def is_generated(self):
@@ -226,38 +236,6 @@
 jByte = JvmScalarType('B', jByteClass, 'byteValue')
 jChar = JvmScalarType('C', jCharClass, 'charValue')
 
-class JvmArrayType(JvmType):
-    """
-    Subclass used for all array instances.
-    """
-    def __init__(self, elemtype):
-        JvmType.__init__(self, desc_for_array_of(elemtype.descriptor))
-        self.element_type = elemtype
-    def lookup_field(self, fieldnm):
-        raise KeyError(fieldnm)  # TODO adjust interface to permit opcode here
-    def lookup_method(self, methodnm):
-        # Arrays don't have methods in Java, but they do in the ootype system
-        from pypy.translator.jvm.generator import ArrayMethod
-        return ArrayMethod(self, methodnm)
-
-class JvmVoidArrayType(JvmArrayType):
-    def __init__(self):
-        JvmType.__init__(self, JvmTypeDescriptor("I"))
-        self.element_type = jVoid
-    def lookup_method(self, methodnm):
-        # Arrays don't have methods in Java, but they do in the ootype system
-        from pypy.translator.jvm.generator import VoidArrayMethod
-        return VoidArrayMethod(self, methodnm)
-
-        
-jByteArray = JvmArrayType(jByte)
-jObjectArray = JvmArrayType(jObject)
-jStringArray = JvmArrayType(jString)
-jDoubleArray = JvmArrayType(jDouble)
-jCharArray = JvmArrayType(jChar)
-jIntArray = JvmArrayType(jInt)
-jVoidArray = JvmVoidArrayType()
-
 class Generifier(object):
 
     """
@@ -317,7 +295,7 @@
 # Java Callback Interfaces
 #
 # A list of interfaces which static functions that we generate will
-# automatically implement if application.  See the pypy/Callback.java,
+# automatically implement if applicable.  See the pypy/Callback.java,
 # node.py/StaticMethodInterface for more information.
 
 jCallbackInterfaces = [] # collects all of the defined JvmCallbackInterfaces
@@ -374,3 +352,621 @@
             restype = self.db.annotation_to_cts(methspec.retval._type)
             self.methods[methname] = Method.v(self, methname,
                                               argtypes, restype)
+
+# ______________________________________________________________________
+# The bridge between RPython array and JVM arrays.  The main differences
+# are that (a) RPython has arrays of void type, and (b) RPython arrays
+# have methods, whereas Java methods don't.  We inline those methods
+# into the appropriate bytecode.
+
+class _JvmVoidArray(JvmClassType):
+    """
+    A special case for void arrays. These are represented by an instance
+    of the VoidArray class, which implements the required methods.
+    """
+
+    method_types = {
+        'll_length': ([], jInt),
+        'll_getitem_fast': ([jInt], jVoid),
+        'll_setitem_fast': ([jInt], jVoid),
+        }
+
+    def __init__(self):
+        JvmClassType.__init__(self, 'pypy.VoidArray')
+
+    def make(self, gen):
+        # Construct a new VoidArray object, assuming the length has
+        # been pushed onto the stack already.
+        gen.emit(PYPYVOIDARRAYMAKE)
+        
+    def lookup_field(self, fieldnm):
+        raise KeyError(fieldnm) # no fields
+
+    def lookup_method(self, methodnm):
+        jargtypes, jrettype = self.method_types[methodnm]
+        return jvmgen.Method.v(self, methodnm, jargtypes, jrettype)
+    
+class JvmArrayType(JvmType):
+    """
+    Subclass used for all array instances.
+    """
+    def __init__(self, elemtype):
+        JvmType.__init__(self, desc_for_array_of(elemtype.descriptor))
+        self.element_type = elemtype
+    def make(self, gen):
+        # Issues the opcode to build a new array of the appropriate type.
+        # Assumes the length has been pushed onto the stack already.
+        gen.emit(NEWARRAY.for_type(self))
+    def lookup_field(self, fieldnm):
+        raise KeyError(fieldnm)
+    def lookup_method(self, methodnm):
+        # Arrays don't have methods in Java, but they do in the ootype system
+        if methodnm == "ll_length":
+            return OpcodeMethod([], jInt, ARRAYLENGTH)
+        elif methodnm == "ll_getitem_fast":
+            return OpcodeMethod([jInt], self.element_type,
+                                ARRLOAD.for_type(self.element_type))
+        elif methodnm == "ll_setitem_fast":
+            return OpcodeMethod([jInt, self.element_type], jVoid,
+                                ARRSTORE.for_type(self.element_type))
+        else:
+            raise KeyError(methodnm)
+        
+jByteArray = JvmArrayType(jByte)
+jObjectArray = JvmArrayType(jObject)
+jStringArray = JvmArrayType(jString)
+jDoubleArray = JvmArrayType(jDouble)
+jCharArray = JvmArrayType(jChar)
+jIntArray = JvmArrayType(jInt)
+jVoidArray = _JvmVoidArray()
+            
+# ______________________________________________________________________
+# Opcodes
+#
+# Objects describing the various opcodes which we use.  In some cases,
+# there are also opcode families, which consist of a set of related
+# opcodes that are specialized by the types they operate on (i.e.,
+# IADD, DADD, etc).  
+
+class Opcode(object):
+    def __init__(self, jvmstr):
+        """
+        flags is a set of flags (see above) that describe opcode #UPDATE
+        jvmstr is the name for jasmin printouts
+        """
+        self.jvmstr = jvmstr
+        self.flags = None #Should flags be added to args?
+
+    def __repr__(self):
+        return "<Opcode %s:%x>" % (self.jvmstr, self.flags)
+
+    def specialize(self, args):
+        """ Process the argument list according to the various flags.
+        Returns a tuple (OPCODE, ARGS) where OPCODE is a string representing
+        the new opcode, and ARGS is a list of arguments or empty tuple.
+        Most of these do not do anything. """
+        return (self.jvmstr, args)
+
+class IntConstOpcode(Opcode):
+    """ The ICONST opcode specializes itself for small integer opcodes. """
+    def specialize(self, args):
+        assert len(args) == 1
+        if args[0] == -1:
+            return self.jvmstr + "_m1", ()
+        elif args[0] >= 0 and args[0] <= 5:
+            return self.jvmstr + "_" + str(args[0]), ()
+        # Non obvious: convert ICONST to LDC if the constant is out of
+        # range
+        return "ldc", args
+
+class VarOpcode(Opcode):
+    """ An Opcode which takes a variable index as an argument; specialized
+    to small integer indices. """
+    def specialize(self, args):
+        assert len(args) == 1
+        if args[0] >= 0 and args[0] <= 3:
+            return self.jvmstr + "_" + str(args[0]), ()
+        return Opcode.specialize(self, args)
+
+class IntClassNameOpcode(Opcode):
+    """ An opcode which takes an internal class name as its argument;
+    the actual argument will be a JvmType instance. """
+    def specialize(self, args):
+        args = [args[0].descriptor.int_class_name()]
+        return self.jvmstr, args
+        
+class OpcodeFamily(object):
+    """
+    Many opcodes in JVM have variants that depend on the type of the
+    operands; for example, one must choose the correct ALOAD, ILOAD,
+    or DLOAD depending on whether one is loading a reference, integer,
+    or double variable respectively.  Each instance of this class
+    defines one 'family' of opcodes, such as the LOAD family shown
+    above, and produces Opcode objects specific to a particular type.
+    """
+    def __init__(self, opcclass, suffix):
+        """
+        opcclass is the opcode subclass to use (see above) when
+        instantiating a particular opcode
+        
+        jvmstr is the name for jasmin printouts
+        """
+        self.opcode_class = opcclass
+        self.suffix = suffix
+        self.cache = {}
+
+    def _o(self, prefix):
+        try:
+            return self.cache[prefix]
+        except KeyError:
+            self.cache[prefix] = obj = self.opcode_class(
+                prefix+self.suffix)
+            return obj
+        
+    def for_type(self, argtype):
+        """ Returns a customized opcode of this family appropriate to
+        'argtype', a JvmType object. """
+
+        desc = argtype.descriptor
+
+        # These are always true:
+        if desc[0] == 'L': return self._o("a")   # Objects
+        if desc[0] == '[': return self._o("a")   # Arrays
+        if desc == 'I':    return self._o("i")   # Integers
+        if desc == 'J':    return self._o("l")   # Integers
+        if desc == 'D':    return self._o("d")   # Doubles
+        if desc == 'V':    return self._o("")    # Void [used by RETURN]
+
+        # Chars/Bytes/Booleans are normally represented as ints
+        # in the JVM, but some opcodes are different.  They use a
+        # different OpcodeFamily (see ArrayOpcodeFamily for ex)
+        if desc == 'C':    return self._o("i")   # Characters
+        if desc == 'B':    return self._o("i")   # Bytes
+        if desc == 'Z':    return self._o("i")   # Boolean
+
+        assert False, "Unknown argtype=%s" % repr(argtype)
+        raise NotImplementedError
+
+class ArrayOpcodeFamily(OpcodeFamily):
+    """ Opcode family specialized for array access instr """
+    def for_type(self, argtype):
+        desc = argtype.descriptor
+        if desc == 'J':    return self._o("l")   # Integers
+        if desc == 'D':    return self._o("d")   # Doubles
+        if desc == 'C':    return self._o("c")   # Characters
+        if desc == 'B':    return self._o("b")   # Bytes
+        if desc == 'Z':    return self._o("b")   # Boolean (access as bytes)
+        return OpcodeFamily.for_type(self, argtype)
+
+class NewArrayOpcodeFamily(object):
+    def __init__(self):
+        self.cache = {}
+
+    def for_type(self, arraytype):
+        try:
+            return self.cache[arraytype]
+        except KeyError:
+            pass
+        desc = arraytype.descriptor
+        if desc == '[I':
+            s = "newarray int"
+        elif desc == '[D':
+            s = "newarray double"
+        elif desc == '[C':
+            s = "newarray char"
+        elif desc == '[B':
+            s = "newarray byte"
+        else:
+            s = "anewarray " + arraytype.element_type.descriptor.int_class_name()
+        self.cache[arraytype] = obj = Opcode(s)
+        return obj
+
+NEWARRAY = NewArrayOpcodeFamily()
+ARRAYLENGTH = Opcode("arraylength")
+
+# Define the opcodes for IFNE, IFEQ, IFLT, IF_ICMPLT, etc.  The IFxx
+# variants compare a single integer arg against 0, and the IF_ICMPxx
+# variants compare 2 integer arguments against each other.
+for cmpop in ('ne', 'eq', 'lt', 'gt', 'le', 'ge'):
+    ifop = "if%s" % cmpop
+    if_icmpop = "if_icmp%s" % cmpop
+    globals()[ifop.upper()] = Opcode(ifop)
+    globals()[if_icmpop.upper()] = Opcode(if_icmpop)
+
+# Compare references, either against NULL or against each other
+IFNULL =    Opcode('ifnull')
+IFNONNULL = Opcode('ifnonnull')
+IF_ACMPEQ = Opcode('if_acmpeq')
+IF_ACMPNE = Opcode('if_acmpne')
+
+# Method invocation
+INVOKESTATIC = Opcode('invokestatic')
+INVOKEVIRTUAL = Opcode('invokevirtual')
+INVOKESPECIAL = Opcode('invokespecial')
+INVOKEINTERFACE = Opcode('invokeinterface')
+
+# Other opcodes
+LDC =       Opcode('ldc')       # single-word types
+LDC2 =      Opcode('ldc2_w')    # double-word types: doubles and longs
+GOTO =      Opcode('goto')
+ICONST =    IntConstOpcode('iconst')
+ICONST_0 =  Opcode('iconst_0')  # sometimes convenient to refer to this directly
+ACONST_NULL=Opcode('aconst_null')
+DCONST_0 =  Opcode('dconst_0')
+DCONST_1 =  Opcode('dconst_1')
+LCONST_0 =  Opcode('lconst_0')
+LCONST_1 =  Opcode('lconst_1')
+GETFIELD =  Opcode('getfield')
+PUTFIELD =  Opcode('putfield')
+GETSTATIC = Opcode('getstatic')
+PUTSTATIC = Opcode('putstatic')
+CHECKCAST = IntClassNameOpcode('checkcast')
+INEG =      Opcode('ineg')
+IXOR =      Opcode('ixor')
+IADD =      Opcode('iadd')
+ISUB =      Opcode('isub')
+IMUL =      Opcode('imul')
+IDIV =      Opcode('