1.1 --- a/bytecode.py Wed Nov 10 16:00:09 2004 +0100
1.2 +++ b/bytecode.py Wed Nov 10 16:23:37 2004 +0100
1.3 @@ -905,7 +905,7 @@
1.4
1.5 def checkcast(self, arguments, program):
1.6 index = (arguments[0] << 8) + arguments[1]
1.7 - target_name = self.class_file.constants[index - 1].get_name()
1.8 + target_name = self.class_file.constants[index - 1].get_python_name()
1.9 # NOTE: Using the string version of the name which may contain incompatible characters.
1.10 target_components = str(target_name).split("/")
1.11
1.12 @@ -1210,7 +1210,7 @@
1.13
1.14 def instanceof(self, arguments, program):
1.15 index = (arguments[0] << 8) + arguments[1]
1.16 - target_name = self.class_file.constants[index - 1].get_name()
1.17 + target_name = self.class_file.constants[index - 1].get_python_name()
1.18 # NOTE: Using the string version of the name which may contain incompatible characters.
1.19 target_components = str(target_name).split("/")
1.20
1.21 @@ -1252,11 +1252,12 @@
1.22 count = len(target.get_descriptor()[0])
1.23
1.24 # Check for the method name and invoke superclasses where appropriate.
1.25 - if str(self.method.get_name()) == "<init>":
1.26 + if str(self.method.get_python_name()) == "__init__":
1.27 program.build_tuple(count + 1) # Stack: tuple
1.28 - # NOTE: Assume that local 0 is always self.
1.29 - program.load_fast(0) # Stack: tuple, objectref
1.30 - program.load_attr("__class__") # Stack: tuple, classref
1.31 + # Must use the actual class.
1.32 + # NOTE: Verify this.
1.33 + program.load_global(str(self.class_file.this_class.get_python_name()))
1.34 + # Stack: tuple, classref
1.35 program.load_attr("__bases__") # Stack: tuple, bases
1.36 program.dup_top() # Stack: tuple, bases, bases
1.37 program.load_global("len") # Stack: tuple, bases, bases, len
1.38 @@ -1525,7 +1526,7 @@
1.39 # This operation is considered to be the same as the calling of the
1.40 # initialisation method of the given class with no arguments.
1.41 index = (arguments[0] << 8) + arguments[1]
1.42 - target_name = self.class_file.constants[index - 1].get_name()
1.43 + target_name = self.class_file.constants[index - 1].get_python_name()
1.44 # NOTE: Using the string version of the name which may contain incompatible characters.
1.45 program.load_global(str(target_name))
1.46 # NOTE: Unlike Java, we do not provide an object reference. Instead, a
1.47 @@ -1656,7 +1657,11 @@
1.48 fn = new.function(code, global_names)
1.49 namespace[method_name] = fn
1.50 # NOTE: Define superclasses properly.
1.51 - cls = new.classobj(str(c.this_class.get_name()), (), namespace)
1.52 + if str(c.super_class.get_name()) not in ("java/lang/Object", "java/lang/Exception"):
1.53 + bases = (global_names[str(c.super_class.get_python_name())],)
1.54 + else:
1.55 + bases = ()
1.56 + cls = new.classobj(str(c.this_class.get_python_name()), bases, namespace)
1.57 global_names[cls.__name__] = cls
1.58
1.59 # vim: tabstop=4 expandtab shiftwidth=4