javaclass

Changeset

173:c99763aa736f
2005-02-21 Paul Boddie raw files shortlog changelog graph Fixed circular import (again).
java/_object.py (file) java/io.py (file)
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/java/_object.py	Mon Feb 21 00:07:32 2005 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +#!/usr/bin/env python
     1.5 +
     1.6 +"Special module used to avoid circular imports."
     1.7 +
     1.8 +class Object(object):
     1.9 +    def getClass(self):
    1.10 +        import java.lang.reflect
    1.11 +        return java.lang.reflect.Class(self)
    1.12 +    getClass___ = getClass
    1.13 +
    1.14 +# NOTE: Establish a better exception hierarchy.
    1.15 +
    1.16 +class Error(Object):
    1.17 +    def __init__(self, *args):
    1.18 +        self.args = args
    1.19 +
    1.20 +setattr(Error, "__init_____", Error.__init__)
    1.21 +setattr(Error, "__init_____java__lang__String", Error.__init__)
    1.22 +
    1.23 +class Exception(Object):
    1.24 +    def __init__(self, *args):
    1.25 +        self.args = args
    1.26 +
    1.27 +setattr(Exception, "__init_____", Exception.__init__)
    1.28 +setattr(Exception, "__init_____java__lang__String", Exception.__init__)
    1.29 +
    1.30 +class IndexOutOfBoundsException(Exception):
    1.31 +    pass
    1.32 +
    1.33 +setattr(IndexOutOfBoundsException, "__init_____", IndexOutOfBoundsException.__init__)
    1.34 +setattr(IndexOutOfBoundsException, "__init_____java__lang__String", IndexOutOfBoundsException.__init__)
    1.35 +
    1.36 +class IllegalArgumentException(Exception):
    1.37 +    pass
    1.38 +
    1.39 +setattr(IllegalArgumentException, "__init_____", IllegalArgumentException.__init__)
    1.40 +setattr(IllegalArgumentException, "__init_____java__lang__String", IllegalArgumentException.__init__)
    1.41 +
    1.42 +class NoSuchMethodException(Exception):
    1.43 +    pass
    1.44 +
    1.45 +setattr(NoSuchMethodException, "__init_____", NoSuchMethodException.__init__)
    1.46 +setattr(NoSuchMethodException, "__init_____java__lang__String", NoSuchMethodException.__init__)
    1.47 +
    1.48 +class NullPointerException(Exception):
    1.49 +    pass
    1.50 +
    1.51 +setattr(NullPointerException, "__init_____", NullPointerException.__init__)
    1.52 +setattr(NullPointerException, "__init_____java__lang__String", NullPointerException.__init__)
    1.53 +
    1.54 +class SecurityException(Exception):
    1.55 +    pass
    1.56 +
    1.57 +setattr(SecurityException, "__init_____", SecurityException.__init__)
    1.58 +setattr(SecurityException, "__init_____java__lang__String", SecurityException.__init__)
    1.59 +
    1.60 +# vim: tabstop=4 expandtab shiftwidth=4
     2.1 --- a/java/io.py	Sun Feb 20 23:02:23 2005 +0100
     2.2 +++ b/java/io.py	Mon Feb 21 00:07:32 2005 +0100
     2.3 @@ -1,6 +1,6 @@
     2.4  #!/usr/bin/env python
     2.5  
     2.6 -from java.lang._object import Object, NullPointerException, IndexOutOfBoundsException, Exception as _Exception
     2.7 +from java._object import Object, NullPointerException, IndexOutOfBoundsException, Exception as _Exception
     2.8  
     2.9  class InputStream(Object):
    2.10      def __init__(self, stream):